[Zope-Checkins] SVN: Zope/trunk/src/Products/Five/browser/metaconfigure.py - fixed simple class
Yvo Schubbe
cvs-admin at zope.org
Tue Jul 10 13:57:09 UTC 2012
Log message for revision 127300:
- fixed simple class
- removed Five BrowserView as base class
(trying to move one more step forward instead of reverting revision 127298 and 127299 which did break CMF tests)
Changed:
U Zope/trunk/src/Products/Five/browser/metaconfigure.py
-=-
Modified: Zope/trunk/src/Products/Five/browser/metaconfigure.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/metaconfigure.py 2012-07-10 13:12:59 UTC (rev 127299)
+++ Zope/trunk/src/Products/Five/browser/metaconfigure.py 2012-07-10 13:57:06 UTC (rev 127300)
@@ -46,7 +46,6 @@
from AccessControl.security import protectName
from AccessControl.security import CheckerPrivateId
-from Products.Five.browser import BrowserView
from Products.Five.browser.resource import FileResourceFactory
from Products.Five.browser.resource import ImageResourceFactory
from Products.Five.browser.resource import PageTemplateResourceFactory
@@ -125,6 +124,11 @@
new_class = SimpleViewClass(template, bases=(class_, ), name=name)
else:
cdict = getSecurityInfo(class_)
+ if not hasattr(class_, 'browserDefault'):
+ cdict.update({
+ 'browserDefault':
+ lambda self, request: (getattr(self, attribute), ())
+ })
cdict['__name__'] = name
cdict['__page_attribute__'] = attribute
new_class = makeClass(class_.__name__, (class_, simple), cdict)
@@ -415,30 +419,23 @@
)
-class simple(BrowserView, zope.browserpage.metaconfigure.simple):
+class simple(zope.browserpage.metaconfigure.simple):
- # XXX: this alternative implementation would support permission checks for
- # the attribute instead of the view
- # def browserDefault(self, request):
- # return self, (self.__page_attribute__,)
- #
- # def publishTraverse(self, request, name):
- # return getattr(self, name)
-
- # For some reason, the 'simple' baseclass doesn't implement this
- # mandatory method (see https://bugs.launchpad.net/zope3/+bug/129296)
- def browserDefault(self, request):
- return getattr(self, self.__page_attribute__), ()
-
# __call__ should have the same signature as the original method
@property
def __call__(self):
- return getattr(self, self.__page_attribute__)
+ # If a class doesn't provide it's own call, then get the attribute
+ # given by the browser default.
+ attr = self.__page_attribute__
+ if attr == '__call__':
+ raise AttributeError("__call__")
-class ViewMixinForTemplates(BrowserView,
- zope.browserpage.simpleviewclass.simple):
+ return getattr(self, attr)
+
+class ViewMixinForTemplates(zope.browserpage.simpleviewclass.simple):
+
def __getitem__(self, name):
if name == 'macros':
return self.index.macros
More information about the Zope-Checkins
mailing list