[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - editview.py:1.18

Godefroid Chapelle gotcha@swing.be
Fri, 11 Apr 2003 18:16:16 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv9040/app/browser/form

Modified Files:
	editview.py 
Log Message:
- added usage argument to ZCML menu directive
  The menu usage is used by the configuration to initialize 
  the page view usage in case a page is registered as a
  menu item included in a menu declared with a usage argument.

- added corresponding tests

- various ZCML refactorings to improve usage initialization

- added tests for menu and usage on page directive



=== Zope3/src/zope/app/browser/form/editview.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/browser/form/editview.py:1.17	Wed Apr  9 16:51:29 2003
+++ Zope3/src/zope/app/browser/form/editview.py	Fri Apr 11 18:15:45 2003
@@ -38,7 +38,7 @@
 from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
 
 from zope.app.publisher.browser.globalbrowsermenuservice \
-     import menuItemDirective
+     import menuItemDirective, globalBrowserMenuService
 
 
 class EditView(BrowserView):
@@ -161,7 +161,8 @@
 
 def EditViewFactory(name, schema, label, permission, layer,
                     template, default_template, bases, for_, fields,
-                    fulledit_path=None, fulledit_label=None):
+                    fulledit_path=None, fulledit_label=None, menu=u'',
+                    usage=u''):
     # XXX What about the __implements__ of the bases?
     class_  = SimpleViewClass(
         template,
@@ -179,6 +180,10 @@
 
     class_.generated_form = ViewPageTemplateFile(default_template)
 
+    class_.usage = usage or (
+        menu and globalBrowserMenuService.getMenuUsage(menu)
+        )
+
     defineChecker(class_,
                   NamesChecker(
                     ("__call__", "__getitem__", "browserDefault"),
@@ -237,7 +242,7 @@
          layer = "default",
          class_ = None, for_ = None,
          template = None, omit=None, fields=None,
-         menu=None, title='Edit'):
+         menu=None, title='Edit', usage=u''):
 
 
     if menu:
@@ -258,7 +263,7 @@
         callable = EditViewFactory,
         args = (name, schema, label, permission, layer, template, 'edit.pt',
                 bases,
-                for_, fields),
+                for_, fields, menu, usage),
         )
         )