Skip to content

Commit

Permalink
Quick fix to make this work in Zope 2.12. Tests are still failing badly.
Browse files Browse the repository at this point in the history
  • Loading branch information
optilude committed Feb 8, 2010
1 parent 429c745 commit 4508ebd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion z3c/jbot/Five.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To play nicely we'll put the template inside a view.
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.
Expand Down
32 changes: 29 additions & 3 deletions z3c/jbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

logger = logging.getLogger('jbot')

# Standard PageTemplateFile

PT_CLASSES = [PageTemplateFile]

try:
Expand Down Expand Up @@ -42,6 +44,32 @@ def get(template, view=None, cls=None):

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:
Expand All @@ -60,9 +88,7 @@ def get_and_bind(template, view=None, cls=None):
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
Expand Down

0 comments on commit 4508ebd

Please sign in to comment.