[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/PageTemplate - Engine.py:1.4 SimpleViewClass.py:1.3

Jim Fulton jim@zope.com
Tue, 18 Jun 2002 10:17:20 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/PageTemplate
In directory cvs.zope.org:/tmp/cvs-serv30310/lib/python/Zope/App/PageTemplate

Modified Files:
	Engine.py SimpleViewClass.py 
Log Message:
Added the ability to specify templates in view pages rather than in
Python view classes.

Added the ability to supply a class when defiening views from
templates. In this case, the class becomes a base class of the
generated view class.

Added the ability to supply base classes to simple view classes.

Changed the zope page-template engine to use
Zope.App.Traversers.Traverser.Traverser directly, wo looking it up as
an adapter. I suspect that we'll stop making this pluggable, as it's
too much bother, given that adapters are used for each step anyway.



=== Zope3/lib/python/Zope/App/PageTemplate/Engine.py 1.3 => 1.4 ===
 from Zope.PageTemplate.PythonExpr import PythonExpr
 from Zope.Security.Proxy import ProxyFactory
-from Zope.ComponentArchitecture import getAdapter
 from Zope.App.Traversing.ITraverser import ITraverser
 from Zope.Security.RestrictedBuiltins import RestrictedBuiltins
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
 from Zope.I18n.GlobalTranslationService import translationService
+from Zope.App.Traversing.Traverser import Traverser
 import sys
 
 def zopeTraverser(object, path_items, econtext):
     """Traverses a sequence of names, first trying attributes then items.
     """
-    traverser = getAdapter(object, ITraverser)
+    traverser = Traverser(object)
     return traverser.traverse(path_items,
                               request=getattr(econtext, 'request', None))
 


=== Zope3/lib/python/Zope/App/PageTemplate/SimpleViewClass.py 1.2 => 1.3 ===
         return self.index(self.request, *args, **kw)
 
-def SimpleViewClass(src, offering=None, used_for=None):
+def SimpleViewClass(src, offering=None, used_for=None, bases=()):
     if offering is None:
         offering = sys._getframe(1).f_globals
 
-    class_ = type("SimpleViewClass from %s" % src, (simple,),
+    bases += (simple, )
+
+    class_ = type("SimpleViewClass from %s" % src, bases,
                   {'index': ViewPageTemplateFile(src, offering)})
 
     if used_for is not None: