[CMF-checkins] CVS: CMF/CMFStaging - StagingTool.py:1.20

Ken Manheimer klm at zope.com
Wed Mar 31 16:53:54 EST 2004


Update of /cvs-repository/CMF/CMFStaging
In directory cvs.zope.org:/tmp/cvs-serv13799

Modified Files:
	StagingTool.py 
Log Message:
.stageExists(): New method by which the existence of a stage can be tested
without having to catch an exception.


=== CMF/CMFStaging/StagingTool.py 1.19 => 1.20 ===
--- CMF/CMFStaging/StagingTool.py:1.19	Fri Mar 19 17:10:56 2004
+++ CMF/CMFStaging/StagingTool.py	Wed Mar 31 16:53:54 2004
@@ -365,6 +365,17 @@
                     % (p, stage))
 
 
+    security.declarePublic('stageExists')
+    def stageExists(self, stage):
+        """Return 1 if named stage exists, else 0."""
+        portal = aq_parent(aq_inner(self))
+        for stage_name, stage_title, stage_path in self._stages:
+            if stage_name == stage:
+                stage = self._getStage(portal, stage_path)
+                if stage: return 1
+                else: return 0
+        return 0
+
     security.declarePublic('checkContainers')
     def checkContainers(self, obj, stages):
         """Verifies that the container exists on the given stages.




More information about the CMF-checkins mailing list