[Zope-Checkins] CVS: Zope/lib/python/OFS - ObjectManager.py:1.160

Andreas Jung andreas@andreas-jung.com
Sun, 2 Feb 2003 07:19:10 -0500


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv8025/lib/python/OFS

Modified Files:
	ObjectManager.py 
Log Message:
- Collector #695: Object IDs "." and ".." are no longer permitted.


=== Zope/lib/python/OFS/ObjectManager.py 1.159 => 1.160 ===
--- Zope/lib/python/OFS/ObjectManager.py:1.159	Mon Jan  6 08:40:34 2003
+++ Zope/lib/python/OFS/ObjectManager.py	Sun Feb  2 07:19:07 2003
@@ -27,6 +27,7 @@
 from webdav.Collection import Collection
 from Acquisition import aq_base
 from AccessControl.SecurityInfo import ClassSecurityInfo
+from webdav.Lockable import ResourceLockedError
 from urllib import quote
 from cStringIO import StringIO
 import marshal
@@ -59,12 +60,14 @@
     if bad_id(id) is not None:
         raise BadRequestException, (
             'The id "%s" contains characters illegal in URLs.' % escape(id))
-    if id[0]=='_': raise BadRequestException, (
-        'The id "%s" is invalid - it begins with an underscore.'  % id)
-    if id[:3]=='aq_': raise BadRequestException, (
-        'The id "%s" is invalid - it begins with "aq_".'  % id)
-    if id[-2:]=='__': raise BadRequestException, (
-        'The id "%s" is invalid - it ends with two underscores.'  % id)
+    if id in ('.', '..'): raise BadRequestException, (
+        'The id "%s" is invalid because it is not traversable.' % id)
+    if id.startswith('_'): raise BadRequestException, (
+        'The id "%s" is invalid because it begins with an underscore.' % id)
+    if id.startswith('aq_'): raise BadRequestException, (
+        'The id "%s" is invalid because it begins with "aq_".' % id)
+    if id.endswith('__'): raise BadRequestException, (
+        'The id "%s" is invalid because it ends with two underscores.' % id)
     if not allow_dup:
         obj = getattr(self, id, None)
         if obj is not None:
@@ -74,8 +77,8 @@
             if hasattr(aq_base(self), id):
                 # The object is located in this ObjectManager.
                 if not flags & REPLACEABLE:
-                    raise BadRequestException, ('The id "%s" is invalid--'
-                                          'it is already in use.' % id)
+                    raise BadRequestException, (
+                        'The id "%s" is invalid - it is already in use.' % id)
                 # else the object is replaceable even if the UNIQUE
                 # flag is set.
             elif flags & UNIQUE:
@@ -84,8 +87,7 @@
         raise BadRequestException, 'REQUEST is a reserved name.'
     if '/' in id:
         raise BadRequestException, (
-            'The id "%s" contains characters illegal in URLs.' % id
-            )
+            'The id "%s" contains characters illegal in URLs.' % id)
 
 class BeforeDeleteException( Exception ): pass # raise to veto deletion
 class BreakoutException ( Exception ): pass  # raised to break out of loops
@@ -440,6 +442,10 @@
         while ids:
             id=ids[-1]
             v=self._getOb(id, self)
+
+            if v.wl_isLocked():
+                raise ResourceLockedError, 'Object "%s" is locked via WebDAV' % v.getId()
+
             if v is self:
                 raise 'BadRequest', '%s does not exist' % escape(ids[-1])
             self._delObject(id)