[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.1.2.1 PortalContent.py:1.33.20.1
Shane Hathaway
shane@cvs.zope.org
Wed, 23 Jan 2002 16:17:56 -0500
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv22054
Modified Files:
Tag: cmf-pre-1_3-branch
PortalContent.py
Added Files:
Tag: cmf-pre-1_3-branch
CMFCatalogAware.py
Log Message:
Split the catalog aware functionality of PortalContent into a separate base
class so SkinnedFolder can make use of it.
=== Added File CMF/CMFCore/CMFCatalogAware.py ===
##############################################################################
#
# 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
#
##############################################################################
import Globals
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
from CMFCorePermissions import ModifyPortalContent
from utils import getToolByName
class CMFCatalogAware:
"""Mix-in for notifying portal_catalog and portal_workflow
"""
security = ClassSecurityInfo()
# Cataloging methods
# ------------------
security.declareProtected(ModifyPortalContent, 'indexObject')
def indexObject(self):
catalog = getToolByName(self, 'portal_catalog', None)
if catalog is not None:
catalog.indexObject(self)
security.declareProtected(ModifyPortalContent, 'unindexObject')
def unindexObject(self):
catalog = getToolByName(self, 'portal_catalog', None)
if catalog is not None:
catalog.unindexObject(self)
security.declareProtected(ModifyPortalContent, 'reindexObject')
def reindexObject(self):
catalog = getToolByName(self, 'portal_catalog', None)
if catalog is not None:
catalog.reindexObject(self)
def manage_afterAdd(self, item, container):
"""
Add self to the workflow and catalog.
"""
#
# Are we being added (or moved)?
#
if aq_base(container) is not aq_base(self):
wf = getToolByName(self, 'portal_workflow', None)
if wf is not None:
wf.notifyCreated(self)
self.indexObject()
def manage_beforeDelete(self, item, container):
"""
Remove self from the catalog.
"""
#
# Are we going away?
#
if aq_base(container) is not aq_base(self):
self.unindexObject()
#
# Now let our "aspects" know we are going away.
#
for item_id, subitem in self.objectItems():
m = getattr(subitem, 'manage_beforeDelete', None)
if m is not None:
m(item, container)
Globals.InitializeClass(CMFCatalogAware)
=== CMF/CMFCore/PortalContent.py 1.33 => 1.33.20.1 ===
from CMFCorePermissions import AccessContentsInformation, View, FTPAccess
-from CMFCorePermissions import ReviewPortalContent, ModifyPortalContent
from interfaces.Contentish import Contentish
from DynamicType import DynamicType
-from utils import getToolByName, _checkPermission, _getViewFor
+from utils import _checkPermission, _getViewFor
+
+from CMFCatalogAware import CMFCatalogAware
try:
from webdav.Lockable import ResourceLockedError
@@ -43,7 +44,7 @@
NoWL = 1
-class PortalContent(DynamicType, SimpleItem):
+class PortalContent(DynamicType, CMFCatalogAware, SimpleItem):
"""
Base class for portal objects.
@@ -100,58 +101,6 @@
"Returns a concatination of all searchable text"
# Should be overriden by portal objects
return "%s %s" % (self.Title(), self.Description())
-
- # Cataloging methods
- # ------------------
-
- security.declareProtected(ModifyPortalContent, 'indexObject')
- def indexObject(self):
- catalog = getToolByName(self, 'portal_catalog', None)
- if catalog is not None:
- catalog.indexObject(self)
-
- security.declareProtected(ModifyPortalContent, 'unindexObject')
- def unindexObject(self):
- catalog = getToolByName(self, 'portal_catalog', None)
- if catalog is not None:
- catalog.unindexObject(self)
-
- security.declareProtected(ModifyPortalContent, 'reindexObject')
- def reindexObject(self):
- catalog = getToolByName(self, 'portal_catalog', None)
- if catalog is not None:
- catalog.reindexObject(self)
-
- def manage_afterAdd(self, item, container):
- """
- Add self to the workflow and catalog.
- """
- #
- # Are we being added (or moved)?
- #
- if aq_base(container) is not aq_base(self):
- wf = getToolByName(self, 'portal_workflow', None)
- if wf is not None:
- wf.notifyCreated(self)
- self.indexObject()
-
- def manage_beforeDelete(self, item, container):
- """
- Remove self from the catalog.
- """
- #
- # Are we going away?
- #
- if aq_base(container) is not aq_base(self):
- self.unindexObject()
- #
- # Now let our "aspects" know we are going away.
- #
- for it, subitem in self.objectItems():
- si_m_bD = getattr( subitem, 'manage_beforeDelete', None )
- if si_m_bD is not None:
- si_m_bD( item, container )
-
# Contentish interface methods
# ----------------------------