[Zope-CVS] CVS: Products/CompositePage - composite.py:1.6
Shane Hathaway
shane at zope.com
Tue Oct 14 17:42:53 EDT 2003
Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv23725
Modified Files:
composite.py
Log Message:
Made it easier to override the use_macro and template_path properties.
Created two methods, getMacro() and hasTemplate(). getMacro(), if it
returns something other than None, takes precedence over getTemplate().
=== Products/CompositePage/composite.py 1.5 => 1.6 ===
--- Products/CompositePage/composite.py:1.5 Thu Oct 9 17:29:15 2003
+++ Products/CompositePage/composite.py Tue Oct 14 17:42:52 2003
@@ -94,10 +94,23 @@
f._setId("filled_slots")
self._setObject(f.getId(), f)
+ security.declareProtected(perm_names.view, "hasTemplate")
+ def hasTemplate(self):
+ if self.template_path:
+ return 1
+ return 0
+
security.declareProtected(perm_names.view, "getTemplate")
def getTemplate(self):
return self.restrictedTraverse(str(self.template_path))
+ security.declareProtected(perm_names.view, "getMacro")
+ def getMacro(self):
+ if not self.use_macro:
+ return None
+ template = self.getTemplate()
+ return template.restrictedTraverse(("macros", str(self.use_macro)))
+
security.declareProtected(perm_names.change_composites, "generateSlots")
def generateSlots(self):
"""Creates the slots defined by the template.
@@ -116,13 +129,12 @@
raise CompositeError("Circular composite reference")
self._v_rendering = 1
try:
- template = self.getTemplate()
- if not self.use_macro:
- return template()
- else:
- macro = template.restrictedTraverse(
- ("macros", str(self.use_macro)))
+ macro = self.getMacro()
+ if macro is not None:
return renderMacro(macro, self)
+ else:
+ template = self.getTemplate()
+ return template()
finally:
self._v_rendering = 0
More information about the Zope-CVS
mailing list