[CMF-checkins] CVS: CMF/CMFCore - PortalFolder.py:1.29.10.1

Shane Hathaway shane@cvs.zope.org
Fri, 8 Feb 2002 16:52:55 -0500


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

Modified Files:
      Tag: cmf-pre-1_3-branch
	PortalFolder.py 
Log Message:
Added checkIdAvailable() method, making it easier to write friendly handlers
for ID conflicts.


=== CMF/CMFCore/PortalFolder.py 1.29 => 1.29.10.1 ===
 ADD_CONTENT_PERMISSION = 'Add portal content'
 
+import sys
 import Globals, re, base64, marshal, string
 import CMFCorePermissions
 
@@ -328,6 +329,17 @@
              , (type_name, self, id, RESPONSE) + args
              , kw
              )
+
+    security.declareProtected(AddPortalContent, 'checkIdAvailable')
+    def checkIdAvailable(self, id):
+        try:
+            self._checkId(id)
+        except:
+            if sys.exc_info()[0] == 'Bad Request':
+                return 0
+            raise  # Some other exception.
+        else:
+            return 1
 
     def MKCOL_handler(self,id,REQUEST=None,RESPONSE=None):
         """