[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate - PageTemplate.py:1.1.2.9 PageTemplateFile.py:1.1.2.10
Andreas Jung
andreas@digicool.com
Thu, 10 Jan 2002 14:33:45 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate
In directory cvs.zope.org:/tmp/cvs-serv18258/PageTemplate
Modified Files:
Tag: Zope-3x-branch
PageTemplate.py PageTemplateFile.py
Log Message:
- changed ViewMapper to use getRequestView
- changed PageTemplates to plum the request to the view mapper
=== Zope3/lib/python/Zope/PageTemplate/PageTemplate.py 1.1.2.8 => 1.1.2.9 ===
from Zope.TAL.TALGenerator import TALGenerator
from Zope.TAL.TALInterpreter import TALInterpreter
-from Zope.ComponentArchitecture import getView
-from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
+from Zope.ComponentArchitecture import getRequestView
from Expressions import getEngine
from string import join, strip, rstrip, split, replace, lower, find
from cStringIO import StringIO
@@ -92,7 +91,7 @@
extra_context = {'options': kwargs}
if inst is not None:
extra_context['here'] = inst.getContext()
- extra_context['views'] = ViewMapper(inst.getContext())
+ extra_context['views'] = ViewMapper(inst.getContext(), None)
extra_context['container'] = inst
return self.pt_render(extra_context=extra_context)
@@ -184,11 +183,12 @@
class ViewMapper:
- def __init__(self, ob):
+ def __init__(self, ob, request):
self.ob = ob
+ self.request = request
def __getitem__(self, name):
- return getView(self.ob, name, IBrowserPublisher)
+ return getRequestView(self.ob, name, self.request)
class _ModuleImporter:
=== Zope3/lib/python/Zope/PageTemplate/PageTemplateFile.py 1.1.2.9 => 1.1.2.10 ===
self.filename = os.path.join(_prefix, filename)
- def pt_getContext(self, inst=None):
+ def pt_getContext(self, inst=None, request=None):
#root = self.getPhysicalRoot()
c = {'template': self,
'nothing': None,
@@ -65,14 +65,14 @@
if inst is not None:
c['here'] = inst.getContext()
c['container'] = inst
- c['views'] = ViewMapper(inst.getContext())
+ c['views'] = ViewMapper(inst.getContext(), request)
return c
def __call__(self, inst, REQUEST=None, **kw):
"""Call a Page Template"""
self._cook_check()
bound_names = {}
- bound_names.update(self.pt_getContext(inst))
+ bound_names.update(self.pt_getContext(inst, REQUEST))
bound_names['options'] = kw
bound_names['request'] = REQUEST