Skip to content

Commit

Permalink
- fixed simple class
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
Unknown committed Jul 10, 2012
1 parent b0c70bd commit 695d8c9
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/Products/Five/browser/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -125,6 +124,11 @@ def page(_context, name, permission, for_=Interface,
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)
Expand Down Expand Up @@ -415,29 +419,22 @@ def resourceDirectory(_context, name, directory, layer=IDefaultBrowserLayer,
)


class simple(BrowserView, 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__), ()
class simple(zope.browserpage.metaconfigure.simple):

# __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__")

return getattr(self, attr)


class ViewMixinForTemplates(BrowserView,
zope.browserpage.simpleviewclass.simple):
class ViewMixinForTemplates(zope.browserpage.simpleviewclass.simple):

def __getitem__(self, name):
if name == 'macros':
Expand Down

0 comments on commit 695d8c9

Please sign in to comment.