[Zope-CVS] CVS: Products/CompositePage - composite.py:1.17

Shane Hathaway shane at zope.com
Fri Mar 12 13:46:47 EST 2004


Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv637

Modified Files:
	composite.py 
Log Message:
Added a method for discovering the class name of a slot


=== Products/CompositePage/composite.py 1.16 => 1.17 ===
--- Products/CompositePage/composite.py:1.16	Fri Mar 12 11:11:30 2004
+++ Products/CompositePage/composite.py	Fri Mar 12 13:46:16 2004
@@ -195,7 +195,7 @@
     def getSlotSpecs(self):
         """Returns the slot specs within the template.
 
-        Returns [{'name', 'class', 'title'}].  May return duplicates.
+        Returns [{'name', 'class_name', 'title'}].  May return duplicates.
         """
         self._v_slot_specs = []
         try:
@@ -204,6 +204,19 @@
             slots = self._v_slot_specs
             self._v_slot_specs = None
             return slots
+
+    security.declareProtected(perm_names.change_composites, "getSlotClassName")
+    def getSlotClassName(self, slot_name):
+        """Returns the class_name of a slot.
+
+        Returns None if no class is defined for the slot.  Raises
+        KeyError if no such slot exists.
+        """
+        specs = self.getSlotSpecs()
+        for spec in specs:
+            if spec['name'] == slot_name:
+                return spec['class_name']
+        raise KeyError(slot_name)
 
     security.declareProtected(perm_names.change_composites, "getManifest")
     def getManifest(self):




More information about the Zope-CVS mailing list