[Checkins] SVN: five.customerize/branches/plone-3.0-branch-with-viewlet-support/src/five/customerize/zpt.py `update` should actually not do nothing, but call the viewlet's `update` function; to avoid doing is in `render` the viewlet instance created by `_getViewlet` has to be reused, too...

Andreas Zeidler az at zitc.de
Thu Aug 16 09:17:36 EDT 2007


Log message for revision 78881:
  `update` should actually not do nothing, but call the viewlet's `update` function;  to avoid doing is in `render` the viewlet instance created by `_getViewlet` has to be reused, too...

Changed:
  U   five.customerize/branches/plone-3.0-branch-with-viewlet-support/src/five/customerize/zpt.py

-=-
Modified: five.customerize/branches/plone-3.0-branch-with-viewlet-support/src/five/customerize/zpt.py
===================================================================
--- five.customerize/branches/plone-3.0-branch-with-viewlet-support/src/five/customerize/zpt.py	2007-08-16 12:09:50 UTC (rev 78880)
+++ five.customerize/branches/plone-3.0-branch-with-viewlet-support/src/five/customerize/zpt.py	2007-08-16 13:17:36 UTC (rev 78881)
@@ -112,11 +112,11 @@
         self.view = view
         self.viewlet = viewlet
         self.manager = manager
+        self.ttwviewlet = None
 
     def update(self):
-        # TODO: do we have to do anything here in regard to the customized
-        #    template?  i don't think so...
-        return
+        """ update the viewlet before `render` is called """
+        view = self._getViewlet().update()
 
     def render(self, *args, **kwargs):
         """ render the viewlet using the customized template """
@@ -136,6 +136,8 @@
         return template._exec(bound_names, args, kwargs)
 
     def _getViewlet(self):
+        if self.ttwviewlet is not None:
+            return self.ttwviewlet
         view = self.view
         if view is not None:
             # Filesystem-based view templates are trusted code and
@@ -146,6 +148,7 @@
             class TTWViewlet(view):
                 __allow_access_to_unprotected_subobjects__ = 1
             view = TTWViewlet(self.context, self.request, self.viewlet, self.manager)
+        self.ttwviewlet = view
         return view
 
     # Zope 2 wants to acquisition-wrap every view object (via __of__).



More information about the Checkins mailing list