[CMF-checkins] CVS: CMF/CMFCore - CatalogTool.py:1.21.2.1 PortalContent.py:1.32.2.1 TypesTool.py:1.26.2.1

Tres Seaver tseaver@zope.com
Mon, 10 Dec 2001 17:36:32 -0500


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv25479/CMFCore

Modified Files:
      Tag: CMF-1_2-branch
	CatalogTool.py PortalContent.py TypesTool.py 
Log Message:


  - Assorted Zope 2.3 compatibility hacks^H^H^H^H^Hfixes:

    o CatalogTool: Accomodate both versions of 'ZCatalog.catalog_object'
      (Zope 2.4 adds new 'idxs' argument).

    o PortalContent: test for present of WebDAV locking; patch around
      its absence in Zope 2.3.

    o TypesTool: patch around absence of named Unauthorized exception
      in Zope 2.3 and Zope 2.4.

    o Document: patch around absence of WebDAV locking in 2.3.

    o Link: patch around different return value (trailing slash) from
      Python 1.5.2's 'urlparse.urlunparse'.


=== CMF/CMFCore/CatalogTool.py 1.21 => 1.21.2.1 ===
 from Acquisition import aq_base
 
+try:
+    from Products import PluginIndexes
+    _Z24 = 1
+except ImportError:
+    _Z24 = 0
+
 
 class IndexableObjectWrapper:
 
@@ -202,7 +208,10 @@
         else:
             vars = {}
         w = IndexableObjectWrapper(vars, object)
-        ZCatalog.catalog_object(self, w, uid, idxs)
+        if _Z24:
+            ZCatalog.catalog_object(self, w, uid, idxs)
+        else:
+            ZCatalog.catalog_object(self, w, uid)
 
     security.declarePrivate('indexObject')
     def indexObject(self, object):


=== CMF/CMFCore/PortalContent.py 1.32 => 1.32.2.1 ===
 from DateTime import DateTime
 from Globals import InitializeClass
+from Acquisition import aq_base
 from OFS.SimpleItem import SimpleItem
 from AccessControl import ClassSecurityInfo
-from CMFCorePermissions import AccessContentsInformation, View, \
-     ReviewPortalContent, ModifyPortalContent
-import CMFCorePermissions
+
+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 webdav.Lockable import ResourceLockedError
+
+try:
+    from webdav.Lockable import ResourceLockedError
+except ImportError:
+    class ResourceLockedError( Exception ):
+        pass
+
 try: 
     from webdav.WriteLockInterface import WriteLockInterface
     NoWL = 0
-except ImportError: NoWL = 1
-from Acquisition import aq_base
+except ImportError:
+    NoWL = 1
 
 
 class PortalContent(DynamicType, SimpleItem):
@@ -67,11 +75,11 @@
 
     security = ClassSecurityInfo()
 
-    security.declareObjectProtected(CMFCorePermissions.View)
+    security.declareObjectProtected(View)
 
     # The security for FTP methods aren't set up by default in our
     # superclasses...  :(
-    security.declareProtected(CMFCorePermissions.FTPAccess,
+    security.declareProtected(FTPAccess,
                               'manage_FTPstat',
                               'manage_FTPget',
                               'manage_FTPlist',)
@@ -80,7 +88,7 @@
         """
         Check if isLocked via webDav
         """
-        if self.wl_isLocked():
+        if not NoWL and self.wl_isLocked():
             raise ResourceLockedError, 'This resource is locked via webDAV'
         return 0
 
@@ -160,7 +168,7 @@
 
     index_html = None  # This special value informs ZPublisher to use __call__
 
-    security.declareProtected(CMFCorePermissions.View, 'view')
+    security.declareProtected(View, 'view')
     def view(self):
         '''
         Returns the default view even if index_html is overridden.


=== CMF/CMFCore/TypesTool.py 1.26 => 1.26.2.1 ===
 import string
 from AccessControl import getSecurityManager, ClassSecurityInfo
+try:
+    from AccessControl import Unauthorized
+except:
+    Unauthorized = 'Unauthorized'
 from Acquisition import aq_base
 import Products, CMFCorePermissions
 
@@ -412,7 +416,7 @@
         m = self._getFactoryMethod(container, raise_exc=1)
 
         if m is None:
-            raise 'Unauthorized', ('Cannot create %s' % self.getId())
+            raise Unauthorized, ('Cannot create %s' % self.getId())
 
         id = str(id)
 
@@ -472,7 +476,7 @@
         of its "immediate" view (typically the metadata form).
         """
         if not self.isConstructionAllowed(container):
-            raise 'Unauthorized'
+            raise Unauthorized
 
         constructor = self.restrictedTraverse( self.constructor_path )
         #   Rewrap to get into container's context.