[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.16
CatalogTool.py:1.47
Yvo Schubbe
cvs-admin at zope.org
Sun Dec 7 12:31:51 EST 2003
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv25567/CMFCore
Modified Files:
CMFCatalogAware.py CatalogTool.py
Log Message:
- updated CatalogTool interface (Collector #206)
- reindexObjectSecurity() now uses update_metadata=0
=== CMF/CMFCore/CMFCatalogAware.py 1.15 => 1.16 ===
--- CMF/CMFCore/CMFCatalogAware.py:1.15 Sun Feb 2 11:06:17 2003
+++ CMF/CMFCore/CMFCatalogAware.py Sun Dec 7 12:31:20 2003
@@ -1,26 +1,31 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
+""" Base class for catalog aware content items.
-import Globals
+$Id$
+"""
+
+from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from ExtensionClass import Base
+from Globals import DTMLFile
+from Globals import InitializeClass
-from AccessControl import ClassSecurityInfo
-from CMFCorePermissions import ModifyPortalContent
from CMFCorePermissions import AccessContentsInformation
from CMFCorePermissions import ManagePortal
-from utils import getToolByName
+from CMFCorePermissions import ModifyPortalContent
from utils import _dtmldir
+from utils import getToolByName
class CMFCatalogAware(Base):
@@ -83,11 +88,13 @@
# Ignore old references to deleted objects.
continue
s = getattr(ob, '_p_changed', 0)
- catalog.reindexObject(ob, idxs=['allowedRolesAndUsers'])
+ catalog.reindexObject(ob, idxs=['allowedRolesAndUsers'],
+ update_metadata=0)
if s is None: ob._p_deactivate()
# Reindex the object itself, as the PathIndex only gave us
# the descendants.
- self.reindexObject(idxs=['allowedRolesAndUsers'])
+ catalog.reindexObject(self, idxs=['allowedRolesAndUsers'],
+ update_metadata=0)
# Workflow methods
# ----------------
@@ -185,7 +192,7 @@
},
)
- _manage_workflowsTab = Globals.DTMLFile('zmi_workflows', _dtmldir)
+ _manage_workflowsTab = DTMLFile('zmi_workflows', _dtmldir)
security.declareProtected(ManagePortal, 'manage_workflowsTab')
def manage_workflowsTab(self, REQUEST, manage_tabs_message=None):
@@ -220,5 +227,4 @@
management_view='Workflows',
manage_tabs_message=manage_tabs_message)
-
-Globals.InitializeClass(CMFCatalogAware)
+InitializeClass(CMFCatalogAware)
=== CMF/CMFCore/CatalogTool.py 1.46 => 1.47 ===
--- CMF/CMFCore/CatalogTool.py:1.46 Fri Nov 28 09:52:00 2003
+++ CMF/CMFCore/CatalogTool.py Sun Dec 7 12:31:20 2003
@@ -15,17 +15,18 @@
$Id$
"""
-from Products.ZCatalog.ZCatalog import ZCatalog
-from DateTime import DateTime
-from AccessControl.PermissionRole import rolesForPermissionOn
from AccessControl import ClassSecurityInfo
+from AccessControl.PermissionRole import rolesForPermissionOn
+from DateTime import DateTime
from Globals import DTMLFile
from Globals import InitializeClass
+from Products.ZCatalog.ZCatalog import ZCatalog
from utils import _checkPermission
from utils import _dtmldir
from utils import _getAuthenticatedUser
from utils import _mergedLocalRoles
+from utils import getToolByName
from utils import UniqueObject
from ActionProviderBase import ActionProviderBase
from CMFCorePermissions import AccessInactivePortalContent
@@ -69,11 +70,13 @@
del allowed['Owner']
return list(allowed.keys())
+
class CatalogTool (UniqueObject, ZCatalog, ActionProviderBase):
""" This is a ZCatalog that filters catalog queries.
"""
- __implements__ = (ICatalogTool, ActionProviderBase.__implements__)
+ __implements__ = (ICatalogTool, ZCatalog.__implements__,
+ ActionProviderBase.__implements__)
id = 'portal_catalog'
meta_type = 'CMF Catalog'
@@ -204,16 +207,20 @@
manage_catalogFind = DTMLFile( 'catalogFind', _dtmldir )
- def catalog_object(self, object, uid, idxs=[]):
+ def catalog_object(self, obj, uid, idxs=None, update_metadata=1):
# Wraps the object with workflow and accessibility
# information just before cataloging.
- wf = getattr(self, 'portal_workflow', None)
- if wf is not None:
- vars = wf.getCatalogVariablesFor(object)
+ wftool = getToolByName(self, 'portal_workflow', None)
+ if wftool is not None:
+ vars = wftool.getCatalogVariablesFor(obj)
else:
vars = {}
- w = IndexableObjectWrapper(vars, object)
- ZCatalog.catalog_object(self, w, uid, idxs)
+ w = IndexableObjectWrapper(vars, obj)
+ try:
+ ZCatalog.catalog_object(self, w, uid, idxs, update_metadata)
+ except TypeError:
+ # for Zope versions until 2.6.2
+ ZCatalog.catalog_object(self, w, uid, idxs)
security.declarePrivate('indexObject')
def indexObject(self, object):
@@ -230,7 +237,7 @@
self.uncatalog_object(url)
security.declarePrivate('reindexObject')
- def reindexObject(self, object, idxs=[]):
+ def reindexObject(self, object, idxs=[], update_metadata=1):
'''Update catalog after object data has changed.
The optional idxs argument is a list of specific indexes
to update (all of them by default).
@@ -240,6 +247,6 @@
# Filter out invalid indexes.
valid_indexes = self._catalog.indexes.keys()
idxs = [i for i in idxs if i in valid_indexes]
- self.catalog_object(object, url, idxs=idxs)
+ self.catalog_object(object, url, idxs, update_metadata)
InitializeClass(CatalogTool)
More information about the CMF-checkins
mailing list