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

Stuart Bishop zen at shangri-la.dropbear.id.au
Tue Mar 23 01:51:13 EST 2004


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

Modified Files:
	ObjectManager.py 
Log Message:
ObjectManager no longer raises string exceptions


=== Zope/lib/python/OFS/ObjectManager.py 1.172 => 1.173 ===
--- Zope/lib/python/OFS/ObjectManager.py:1.172	Wed Mar 17 18:51:23 2004
+++ Zope/lib/python/OFS/ObjectManager.py	Tue Mar 23 01:51:13 2004
@@ -49,8 +49,6 @@
 
 bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# ]').search #TS
 
-BadRequestException = 'Bad Request'
-
 def checkValidId(self, id, allow_dup=0):
     # If allow_dup is false, an error will be raised if an object
     # with the given id already exists. If allow_dup is true,
@@ -60,17 +58,17 @@
 
     if not id or not isinstance(id, StringType):
         if isinstance(id, UnicodeType): id = escape(id)
-        raise BadRequestException, ('Empty or invalid id specified', id)
+        raise BadRequest, ('Empty or invalid id specified', id)
     if bad_id(id) is not None:
-        raise BadRequestException, (
+        raise BadRequest, (
             'The id "%s" contains characters illegal in URLs.' % escape(id))
-    if id in ('.', '..'): raise BadRequestException, (
+    if id in ('.', '..'): raise BadRequest, (
         'The id "%s" is invalid because it is not traversable.' % id)
-    if id.startswith('_'): raise BadRequestException, (
+    if id.startswith('_'): raise BadRequest, (
         'The id "%s" is invalid because it begins with an underscore.' % id)
-    if id.startswith('aq_'): raise BadRequestException, (
+    if id.startswith('aq_'): raise BadRequest, (
         'The id "%s" is invalid because it begins with "aq_".' % id)
-    if id.endswith('__'): raise BadRequestException, (
+    if id.endswith('__'): raise BadRequest, (
         'The id "%s" is invalid because it ends with two underscores.' % id)
     if not allow_dup:
         obj = getattr(self, id, None)
@@ -81,16 +79,16 @@
             if hasattr(aq_base(self), id):
                 # The object is located in this ObjectManager.
                 if not flags & REPLACEABLE:
-                    raise BadRequestException, (
+                    raise BadRequest, (
                         '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:
-                raise BadRequestException, ('The id "%s" is reserved.' % id)
+                raise BadRequest, ('The id "%s" is reserved.' % id)
     if id == 'REQUEST':
-        raise BadRequestException, 'REQUEST is a reserved name.'
+        raise BadRequest, 'REQUEST is a reserved name.'
     if '/' in id:
-        raise BadRequestException, (
+        raise BadRequest, (
             'The id "%s" contains characters illegal in URLs.' % id)
 
 class BeforeDeleteException( Exception ): pass # raise to veto deletion
@@ -528,7 +526,7 @@
         """Import an object from a file"""
         dirname, file=os.path.split(file)
         if dirname:
-            raise BadRequestException, 'Invalid file name %s' % escape(file)
+            raise BadRequest, 'Invalid file name %s' % escape(file)
 
         cfg = getConfiguration()
         for impath in (cfg.instancehome, cfg.zopehome):
@@ -536,7 +534,7 @@
             if os.path.exists(filepath):
                 break
         else:
-            raise BadRequestException, 'File does not exist: %s' % escape(file)
+            raise BadRequest, 'File does not exist: %s' % escape(file)
 
         self._importObjectFromFile(filepath, verify=not not REQUEST,
                                    set_owner=set_owner)




More information about the Zope-Checkins mailing list