[Zope3-checkins] CVS: Zope3/src/zope/app/pagetemplate - viewpagetemplatefile.py:1.2.8.1 simpleviewclass.py:1.3.6.1
Godefroid Chapelle
gotcha@swing.be
Tue, 25 Feb 2003 17:34:20 -0500
Update of /cvs-repository/Zope3/src/zope/app/pagetemplate
In directory cvs.zope.org:/tmp/cvs-serv19473
Modified Files:
Tag: template_usage-branch
viewpagetemplatefile.py simpleviewclass.py
Log Message:
First steps for usage top level variable in TAL namespace
This is meant to maintain a unique template
while allowing to differentiate between ways of using the template.
For example, in action dialogs you need to hide some boxes showed in
tab views.
=== Zope3/src/zope/app/pagetemplate/viewpagetemplatefile.py 1.2 => 1.2.8.1 ===
--- Zope3/src/zope/app/pagetemplate/viewpagetemplatefile.py:1.2 Wed Dec 25 09:13:06 2002
+++ Zope3/src/zope/app/pagetemplate/viewpagetemplatefile.py Tue Feb 25 17:34:19 2003
@@ -26,6 +26,11 @@
"""Page Templates used as methods of views defined as Python classes.
"""
+ def __init__(self, filename, _prefix=None, usage=u''):
+# super(ViewPageTemplateFile, self).__init__(filename, _prefix)
+ PageTemplateFile.__init__(self, filename, _prefix)
+ self.usage = usage
+
def pt_getContext(self, instance, request, **_kw):
# instance is a View component
namespace = super(ViewPageTemplateFile, self).pt_getContext(**_kw)
@@ -35,10 +40,12 @@
namespace['views'] = ViewMapper(context, request)
return namespace
- def __call__(self, instance, *args, **keywords):
+ def __call__(self, instance, template_usage=u'', *args, **keywords):
+ if not template_usage:
+ template_usage = self.usage
namespace = self.pt_getContext(
request=instance.request,
- instance=instance,
+ instance=instance, template_usage=template_usage,
args=args, options=keywords)
return self.pt_render(namespace)
@@ -63,8 +70,8 @@
object.__setattr__(self, 'im_func', pt)
object.__setattr__(self, 'im_self', ob)
- def __call__(self, REQUEST=None, **kw):
- return self.im_func(self.im_self, REQUEST, **kw)
+ def __call__(self, template_usage=u'', **kw):
+ return self.im_func(self.im_self, template_usage, **kw)
def __getattr__(self, name):
return getattr(self.im_func, name)
=== Zope3/src/zope/app/pagetemplate/simpleviewclass.py 1.3 => 1.3.6.1 ===
--- Zope3/src/zope/app/pagetemplate/simpleviewclass.py:1.3 Fri Jan 31 05:46:18 2003
+++ Zope3/src/zope/app/pagetemplate/simpleviewclass.py Tue Feb 25 17:34:19 2003
@@ -40,17 +40,17 @@
def __getitem__(self, name):
return self.index.macros[name]
- def __call__(self, *args, **kw):
- return self.index(self.request, *args, **kw)
+ def __call__(self, template_usage=u'', *args, **kw):
+ return self.index(template_usage, *args, **kw)
-def SimpleViewClass(src, offering=None, used_for=None, bases=()):
+def SimpleViewClass(src, offering=None, used_for=None, bases=(), usage=u''):
if offering is None:
offering = sys._getframe(1).f_globals
bases += (simple, )
class_ = type("SimpleViewClass from %s" % src, bases,
- {'index': ViewPageTemplateFile(src, offering)})
+ {'index': ViewPageTemplateFile(src, offering, usage)})
if used_for is not None:
class_.__used_for__ = used_for