Commit 670765dd authored by Amos Latteier's avatar Amos Latteier

Added a 'getobject' method to ZCatalog. This makes it easy to retrieve a...

Added a 'getobject' method to ZCatalog. This makes it easy to retrieve a cataloged object from the searchResults list.
parent 4fd2ad30
......@@ -151,7 +151,8 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
('Search ZCatalog',
['searchResults', '__call__', 'uniqueValuesFor',
'getpath', 'schema', 'indexes', 'index_objects',
'all_meta_types', 'valid_roles', 'resolve_url',],
'all_meta_types', 'valid_roles', 'resolve_url',
'getobject'],
['Anonymous', 'Manager']),
)
......@@ -349,13 +350,23 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
def getpath(self, rid):
"""
Return the path to a cataloged object given a 'data_record_id_'
"""
return self._catalog.paths[rid]
def getobject(self, rid, REQUEST=None):
"""
Return a cataloged object given a 'data_record_id_'
"""
if REQUEST is None:
REQUEST=self.REQUEST
url='%s/%s' %(REQUEST.script, self.getpath(rid))
return REQUEST.clone().resolve_url(url)
def schema(self):
return self._catalog.schema.keys()
def indexes(self):
return self._catalog.indexes.keys()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment