[Zope-Checkins] CVS: Zope2 - ZCatalog.py:1.74.2.8.4.5
Jim Fulton
jim@digiciool.com
Wed, 14 Mar 2001 11:27:59 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog
In directory korak:/tmp/cvs-serv6862
Modified Files:
Tag: Catalog-BTrees-Integration
ZCatalog.py
Log Message:
Moved the uid string check from Catalog to ZCatalog, where it belongs.
Made uid argument to catalog_object optional, using
join(getPhysicalPath(),'/') when the uid is ommitted.
--- Updated File ZCatalog.py in package Zope2 --
--- ZCatalog.py 2001/03/12 16:28:54 1.74.2.8.4.4
+++ ZCatalog.py 2001/03/14 16:27:58 1.74.2.8.4.5
@@ -97,13 +97,15 @@
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from DocumentTemplate.DT_Util import Eval, expr_globals
from AccessControl.Permission import name_trans
-from Catalog import Catalog, orify
+from Catalog import Catalog, orify, CatalogError
from SearchIndex import UnIndex, UnTextIndex
from Vocabulary import Vocabulary
from Shared.DC.ZRDB.TM import TM
from AccessControl import getSecurityManager
from zLOG import LOG, ERROR
+StringType=type('')
+
manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals())
def manage_addZCatalog(self, id, title,
@@ -405,8 +407,20 @@
RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted')
- def catalog_object(self, obj, uid):
+ def catalog_object(self, obj, uid=None):
""" wrapper around catalog """
+
+ if uid is None:
+ try: uid = obj.getPhysicalPath
+ except AttributeError:
+ raise CatalogError(
+ "A cataloged object must support the 'getPhysicalPath' "
+ "method if no unique id is provided when cataloging"
+ )
+ else: uid=string.join(uid(), '/')
+ elif type(uid) is not StringType:
+ raise CatalogError('The object unique id must be a string.')
+
self._catalog.catalogObject(obj, uid, None)
# None passed in to catalogObject as third argument indicates
# that we shouldn't try to commit subtransactions within any