[Zope-Checkins]
SVN: Products.Five/trunk/browser/pagetemplatefile.py
moved Engine out
Andreas Jung
andreas at andreas-jung.com
Wed Mar 1 18:07:35 EST 2006
Log message for revision 65687:
moved Engine out
Changed:
U Products.Five/trunk/browser/pagetemplatefile.py
-=-
Modified: Products.Five/trunk/browser/pagetemplatefile.py
===================================================================
--- Products.Five/trunk/browser/pagetemplatefile.py 2006-03-01 23:07:10 UTC (rev 65686)
+++ Products.Five/trunk/browser/pagetemplatefile.py 2006-03-01 23:07:35 UTC (rev 65687)
@@ -26,71 +26,7 @@
from Products.Five.browser.ReuseUtils import rebindFunction
from Products.Five.browser.TrustedExpression import getEngine, ModuleImporter
-from zope.tales.tales import ExpressionEngine
-from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr, SubPathExpr
-from zope.tales.expressions import SimpleModuleImporter, _marker
-from zope.tales.pythonexpr import PythonExpr
-from zope.tales.tales import _valid_name, _parse_expr, NAME_RE, Undefined
-
-def BoboTraverseAwareSimpleTraverse(object, path_items, econtext):
- """ a slightly modified version of zope.tales.expressions.simpleTraverse()
- that interacts correctly with objects implementing bobo_traverse().
- """
-
- for name in path_items:
- next = getattr(object, name, _marker)
- if next is not _marker:
- object = next
- else:
- try:
- object = object.restrictedTraverse(name)
- except (KeyError, AttributeError):
- try:
- object = object[name]
- except:
- object = getattr(object, name)
-
- return object
-
-
-class PathExpr(PathExpr):
- """We need to subclass PathExpr at this point since there is no other
- away to pass our own traverser because we do not instantiate
- PathExpr on our own...this sucks!
- """
-
- def __init__(self, name, expr, engine, traverser=BoboTraverseAwareSimpleTraverse):
- self._s = expr
- self._name = name
- paths = expr.split('|')
- self._subexprs = []
- add = self._subexprs.append
- for i in range(len(paths)):
- path = paths[i].lstrip()
- if _parse_expr(path):
- # This part is the start of another expression type,
- # so glue it back together and compile it.
- add(engine.compile('|'.join(paths[i:]).lstrip()))
- break
- add(SubPathExpr(path, traverser, engine)._eval)
-
-
-def Engine():
- e = ExpressionEngine()
- reg = e.registerType
- for pt in PathExpr._default_type_names:
- reg(pt, PathExpr)
- reg('string', StringExpr)
- reg('python', PythonExpr)
- reg('not', NotExpr)
- reg('defer', DeferExpr)
- e.registerBaseName('modules', SimpleModuleImporter())
- return e
-
-Engine = Engine()
-
-
class ZopeTwoPageTemplateFile(PageTemplateFile):
"""A strange hybrid between Zope 2 and Zope 3 page template.
@@ -134,9 +70,6 @@
pt_render = rebindFunction(PageTemplateFile.pt_render,
getEngine=getEngine)
- def pt_getEngine(self):
- return Engine
-
def _pt_getContext(self):
try:
root = self.getPhysicalRoot()
More information about the Zope-Checkins
mailing list