[Zope-Checkins] SVN: Zope/trunk/src/Products/Five/ - use the same constructor names and signatures as in zope.browserpage

Yvo Schubbe cvs-admin at zope.org
Tue Jul 10 12:35:06 UTC 2012


Log message for revision 127295:
  - use the same constructor names and signatures as in zope.browserpage

Changed:
  U   Zope/trunk/src/Products/Five/browser/metaconfigure.py
  U   Zope/trunk/src/Products/Five/viewlet/README.txt

-=-
Modified: Zope/trunk/src/Products/Five/browser/metaconfigure.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/metaconfigure.py	2012-07-10 12:27:26 UTC (rev 127294)
+++ Zope/trunk/src/Products/Five/browser/metaconfigure.py	2012-07-10 12:35:00 UTC (rev 127295)
@@ -125,16 +125,13 @@
         cdict['__name__'] = name
         if template:
             # class and template
-            new_class = makeClassForTemplate(template, bases=(class_, ),
-                                             cdict=cdict, name=name)
+            new_class = SimpleViewClass(template, bases=(class_, ), name=name)
         elif attribute != "__call__":
             # we're supposed to make a page for an attribute (read:
             # method) and it's not __call__.  We thus need to create a
             # new class using our mixin for attributes.
             cdict.update({'__page_attribute__': attribute})
-            new_class = makeClass(class_.__name__,
-                                  (class_, ViewMixinForAttributes),
-                                  cdict)
+            new_class = makeClass(class_.__name__, (class_, simple), cdict)
 
             # in case the attribute does not provide a docstring,
             # ZPublisher refuses to publish it.  So, as a workaround,
@@ -158,7 +155,7 @@
 
     else:
         # template
-        new_class = makeClassForTemplate(template, name=name)
+        new_class = SimpleViewClass(template, name=name)
 
     for n in ('', attribute):
         required[n] = permission
@@ -428,8 +425,7 @@
             )
 
 
-class ViewMixinForAttributes(BrowserView,
-                             zope.browserpage.metaconfigure.simple):
+class simple(BrowserView, zope.browserpage.metaconfigure.simple):
 
     # XXX: this alternative implementation would support permission checks for
     #      the attribute instead of the view
@@ -471,16 +467,20 @@
     def __call__(self, *args, **kw):
         return self.index(*args, **kw)
 
-def makeClassForTemplate(filename, globals=None, used_for=None,
-                         bases=(), cdict=None, name=u''):
-    # XXX needs to deal with security from the bases?
-    if cdict is None:
+
+# Original version: zope.browserpage.simpleviewclass.SimpleViewClass
+def SimpleViewClass(src, offering=None, used_for=None, bases=(), name=u''):
+    if bases:
+        cdict = getSecurityInfo(bases[0])
+    else:
         cdict = {}
-    cdict.update({'index': ViewPageTemplateFile(filename, globals),
+    cdict.update({'index': ViewPageTemplateFile(src, offering),
                   '__name__': name})
+
     bases += (ViewMixinForTemplates,)
-    class_ = makeClass("SimpleViewClass from %s" % filename, bases, cdict)
 
+    class_ = makeClass("SimpleViewClass from %s" % src, bases, cdict)
+
     if used_for is not None:
         class_.__used_for__ = used_for
 

Modified: Zope/trunk/src/Products/Five/viewlet/README.txt
===================================================================
--- Zope/trunk/src/Products/Five/viewlet/README.txt	2012-07-10 12:27:26 UTC (rev 127294)
+++ Zope/trunk/src/Products/Five/viewlet/README.txt	2012-07-10 12:35:00 UTC (rev 127295)
@@ -484,8 +484,8 @@
   ... </html>
   ... ''')
 
-  >>> from Products.Five.browser.metaconfigure import makeClassForTemplate
-  >>> Contents = makeClassForTemplate(contentsTemplate, name='contents.html')
+  >>> from Products.Five.browser.metaconfigure import SimpleViewClass
+  >>> Contents = SimpleViewClass(contentsTemplate, name='contents.html')
 
 
 The Viewlet Manager



More information about the Zope-Checkins mailing list