[Checkins] SVN: z3c.jbot/trunk/z3c/jbot/ Quick fix to make this work in Zope 2.12. Tests are still failing badly.

Martin Aspeli optilude at gmx.net
Mon Feb 8 00:27:20 EST 2010


Log message for revision 108867:
  Quick fix to make this work in Zope 2.12. Tests are still failing badly.

Changed:
  U   z3c.jbot/trunk/z3c/jbot/Five.txt
  U   z3c.jbot/trunk/z3c/jbot/__init__.py

-=-
Modified: z3c.jbot/trunk/z3c/jbot/Five.txt
===================================================================
--- z3c.jbot/trunk/z3c/jbot/Five.txt	2010-02-08 03:59:02 UTC (rev 108866)
+++ z3c.jbot/trunk/z3c/jbot/Five.txt	2010-02-08 05:27:18 UTC (rev 108867)
@@ -17,7 +17,7 @@
 Let's instantiate the view with a test request.
   
   >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest("en")  
+  >>> request = TestRequest("en")
   >>> view = MockView(None, request)
 
 Verify that the original template is rendered.

Modified: z3c.jbot/trunk/z3c/jbot/__init__.py
===================================================================
--- z3c.jbot/trunk/z3c/jbot/__init__.py	2010-02-08 03:59:02 UTC (rev 108866)
+++ z3c.jbot/trunk/z3c/jbot/__init__.py	2010-02-08 05:27:18 UTC (rev 108867)
@@ -10,6 +10,8 @@
 
 logger = logging.getLogger('jbot')
 
+# Standard PageTemplateFile
+
 PT_CLASSES = [PageTemplateFile]
 
 try:
@@ -42,7 +44,33 @@
 
     return inst
 
+for pt_class in PT_CLASSES:
+    pt_class.__get__ = get
+    logger.info(repr(pt_class))
+
+# Zope 2.12 ViewPageTemplateFile
+
 try:
+    from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile as FiveViewPageTemplateFile
+    from Products.Five.browser.pagetemplatefile import BoundPageTemplate as FiveBoundPageTemplate
+except ImportError:
+    pass
+else:
+    pt_class = FiveViewPageTemplateFile
+    bind = pt_class.__get__
+
+    def five_get_and_bind(template, view=None, cls=None):
+        inst = get(template, view, cls)
+        if inst._v_last_read is False:
+            inst.read()
+        return bind(inst, view, cls)
+
+    pt_class.__get__ = five_get_and_bind
+    logger.info(repr(pt_class))
+
+# five.pt / Chameleon
+
+try:
     import five.pt.pagetemplate
 except ImportError:
     pass
@@ -60,9 +88,7 @@
     pt_class.__get__ = get_and_bind
     logger.info(repr(pt_class))
 
-for pt_class in PT_CLASSES:
-    pt_class.__get__ = get
-    logger.info(repr(pt_class))
+# CMF skin layer resources
 
 try:
     import Products.CMFCore.FSObject



More information about the checkins mailing list