[Checkins] SVN: five.pt/trunk/src/five/pt/ refactor the five.pt monkey-patch some more

Leonardo Rochael Almeida leorochael at gmail.com
Wed Feb 23 07:53:41 EST 2011


Log message for revision 120533:
  refactor the five.pt monkey-patch some more

Changed:
  U   five.pt/trunk/src/five/pt/patches.py
  U   five.pt/trunk/src/five/pt/tests/test_persistenttemplate.py

-=-
Modified: five.pt/trunk/src/five/pt/patches.py
===================================================================
--- five.pt/trunk/src/five/pt/patches.py	2011-02-23 10:43:01 UTC (rev 120532)
+++ five.pt/trunk/src/five/pt/patches.py	2011-02-23 12:53:41 UTC (rev 120533)
@@ -90,11 +90,7 @@
     template = self._get_five_pt_template()
     return template(self, *args, **kw)
 
-def call_template_and_wrap(self, *args, **kw):
-    template = self._get_five_pt_template_wrapped()
-    return template(self, *args, **kw)
-
-def call_template_file(self, *args, **kw):
+def _get_five_pt_template_file_wrapped(self, *args, **kw):
     template = getattr(self, '_v_template', _marker)
     if template is _marker:
         self._v_template = template = BaseTemplateFile(self.filename)
@@ -104,32 +100,23 @@
     else:
         template = ImplicitAcquisitionWrapper(template, aq_parent(self))
 
-    return template(self, *args, **kw)
+    return template
 
 
 def get_macros(self):
-    template = self._get_five_pt_template_wrapped()
+    template = self._get_five_pt_template()
     return template.macros
 
-def get_macros_file(self):
-    template = getattr(self, '_v_template', _marker)
-    if template is _marker:
-        self._v_template = template = BaseTemplateFile(self.filename)
-
-    if IAcquirer.providedBy(template):
-        return template.__of__(aq_parent(self)).macros
-    else:
-        return template.macros
-
 FiveViewPageTemplateFile.__get__ = get_bound_template
 ZopeViewPageTemplateFile.__get__ = get_bound_template
-PageTemplate.__call__ = call_template
 PageTemplate._get_five_pt_template = _get_five_pt_template
+PageTemplate.__call__ = call_template
 PageTemplate.macros = ComputedAttribute(get_macros, 1)
-PageTemplateFile.__call__ = call_template_file
-PageTemplateFile.macros = property(get_macros_file)
-ZopePageTemplate._get_five_pt_template_wrapped = _get_five_pt_template_wrapped
-ZopePageTemplate._bindAndExec = call_template_and_wrap
+PageTemplateFile._get_five_pt_template = _get_five_pt_template_file_wrapped
+PageTemplateFile.__call__ = call_template
+PageTemplateFile.macros = property(get_macros)
+ZopePageTemplate._get_five_pt_template = _get_five_pt_template_wrapped
+ZopePageTemplate._bindAndExec = call_template
 ZopePageTemplate.macros = ComputedAttribute(get_macros, 1)
 
 try:

Modified: five.pt/trunk/src/five/pt/tests/test_persistenttemplate.py
===================================================================
--- five.pt/trunk/src/five/pt/tests/test_persistenttemplate.py	2011-02-23 10:43:01 UTC (rev 120532)
+++ five.pt/trunk/src/five/pt/tests/test_persistenttemplate.py	2011-02-23 12:53:41 UTC (rev 120533)
@@ -29,7 +29,7 @@
 </metal:use>
 """.strip()
 
-class TestPageTemplateFile(ZopeTestCase):
+class TestPersistent(ZopeTestCase):
     def afterSetUp(self):
         from Products.Five import zcml
         import Products.Five
@@ -38,7 +38,6 @@
         zcml.load_config("configure.zcml", Products.Five)
         zcml.load_config("configure.zcml", five.pt)
         zcml.load_config("configure.zcml", z3c.pt)
-        #import IPython;IPython.Shell.IPShellEmbed(())()
         self.setRoles(['Manager'])
 
     def _makeOne(self, template_id, source):



More information about the checkins mailing list