[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - viewmeta.py:1.17
Steve Alexander
steve@cat-box.net
Tue, 25 Mar 2003 10:20:02 -0500
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv26509/src/zope/app/publisher/browser
Modified Files:
viewmeta.py
Log Message:
Allow a usage attribute on a view with pages.
=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.16 Tue Mar 25 06:23:09 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py Tue Mar 25 10:19:59 2003
@@ -107,7 +107,7 @@
layer='default', template=None, class_=None,
allowed_interface='', allowed_attributes='',
attribute='__call__', menu=None, title=None,
- usage=u'',
+ usage=u''
):
actions = _handle_menu(_context, menu, title, for_, name, permission)
@@ -135,7 +135,6 @@
required['__getitem__'] = permission
if class_:
-
original_class = _context.resolve(class_)
if attribute != '__call__':
@@ -145,9 +144,9 @@
)
if template:
template = str(_context.path(template))
-
- new_class = SimpleViewClass(template, bases=(original_class, ), usage=usage)
-
+ new_class = SimpleViewClass(
+ template, bases=(original_class, ), usage=usage
+ )
else:
if not hasattr(original_class, 'browserDefault'):
cdict = {
@@ -170,9 +169,6 @@
else:
new_class = SimpleViewClass(template, usage=usage)
-
-
-
for n in (attribute, 'browserDefault', '__call__', 'publishTraverse'):
required[n] = permission
@@ -210,7 +206,7 @@
__implements__ = ISubdirectiveHandler
def __init__(self, _context, for_, permission,
- layer='default', class_ = None,
+ layer='default', class_=None,
allowed_interface='', allowed_attributes='',
):
self.opts = opts(for_=for_, permission=permission,
@@ -247,7 +243,7 @@
def __init__(self, _context, name, for_, permission,
layer='default', class_=None,
allowed_interface='', allowed_attributes='',
- menu=None, title=None,
+ menu=None, title=None, usage=u''
):
actions = _handle_menu(_context, menu, title, for_, name, permission)
@@ -261,8 +257,10 @@
allowed_interface, allowed_attributes, actions)
self.pages = []
+ # default usage is u''
+ self.usage = usage
- def page(self, _context, name, attribute=None, template=None, usage=u''):
+ def page(self, _context, name, attribute=None, template=None, usage=None):
if template:
template = _context.path(template)
if not os.path.isfile(template):
@@ -290,6 +288,10 @@
pages = {}
for pname, attribute, template, usage in self.pages:
+ if usage is None:
+ # If no usage is declared explicitly for this page, use the
+ # usage given for the whole view.
+ usage = self.usage
if template:
cdict[pname] = ViewPageTemplateFile(template, usage=usage)
if attribute and attribute != name:
@@ -342,7 +344,6 @@
cdict['browserDefault'] = (
lambda self, request: (self, ())
)
-
if class_ is not None:
bases = (class_, simple)