Skip to content

Commit

Permalink
- more syncing with zope.browserpage
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Jul 11, 2012
1 parent b4d37a3 commit da088f0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/Products/Five/browser/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
"""

import os
import sys
from inspect import ismethod

from zope.component import queryMultiAdapter
from zope.component.interface import provideInterface
from zope.component.zcml import handler
from zope.configuration.exceptions import ConfigurationError
from zope.interface import classImplements
from zope.interface import Interface
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.zcml import Permission
Expand Down Expand Up @@ -122,14 +125,17 @@ def page(_context, name, permission, for_=Interface,
# class and template
new_class = SimpleViewClass(template, bases=(class_, ), name=name)
else:
cdict = getSecurityInfo(class_)
if not hasattr(class_, 'browserDefault'):
cdict.update({
cdict = {
'browserDefault':
lambda self, request: (getattr(self, attribute), ())
})
}
else:
cdict = {}

cdict['__name__'] = name
cdict['__page_attribute__'] = attribute
cdict.update(getSecurityInfo(class_))
new_class = type(class_.__name__, (class_, simple,), cdict)

if attribute != "__call__":
Expand All @@ -146,6 +152,9 @@ def page(_context, name, permission, for_=Interface,
func = func.im_func
func.__doc__ = "Stub docstring to make ZPublisher work"

if hasattr(class_, '__implements__'):
classImplements(new_class, IBrowserPublisher)

else:
# template
new_class = SimpleViewClass(template, name=name)
Expand Down Expand Up @@ -444,16 +453,17 @@ def __getitem__(self, name):

# 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(src, offering),
'__name__': name})
if offering is None:
offering = sys._getframe(1).f_globals

bases += (ViewMixinForTemplates,)

class_ = type("SimpleViewClass from %s" % src, bases, cdict)
cdict = {'index': ViewPageTemplateFile(src, offering),
'__name__': name}
if bases:
cdict.update(getSecurityInfo(bases[0]))
class_ = type("SimpleViewClass from %s" % src, bases,
cdict)

if used_for is not None:
class_.__used_for__ = used_for
Expand Down

0 comments on commit da088f0

Please sign in to comment.