[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - add.py:1.26 addwizard.py:1.6 editview.py:1.31 editwizard.py:1.9 meta.zcml:1.19 schemadisplay.py:1.7 metadirectives.py:NONE
Anthony Baxter
anthony@interlink.com.au
Sat, 2 Aug 2003 05:11:45 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv24272/zope/app/browser/form
Modified Files:
add.py addwizard.py editview.py editwizard.py meta.zcml
schemadisplay.py
Removed Files:
metadirectives.py
Log Message:
Backing out philiKON's changes - they broke the functional tests, and
from his signoff on IRC, I don't think he's going to be around until
Monday. As I'm working on the Catalog functional tests, this is pretty
annoying. I tried to figure out how to just back out bits til I found the
broken stuff, but it's a pretty serious refactoring. I'll send a message
to zope3-checkins with the CVS commands used for this, so that someone
can undo the backout if they wish.
=== Zope3/src/zope/app/browser/form/add.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/browser/form/add.py:1.25 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/add.py Sat Aug 2 05:11:08 2003
@@ -19,11 +19,11 @@
from zope.schema.interfaces import ValidationError
-from zope.app.interfaces.container import IAdding
from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent
from zope.app.interfaces.form import WidgetsError
from zope.app.form.utility import setUpWidgets, getWidgetsData
+from zope.configuration.action import Action
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.security.checker import defineChecker, NamesChecker
from zope.component import getAdapter
@@ -81,15 +81,13 @@
"""
args = []
- if self._arguments:
- for name in self._arguments:
- args.append(data[name])
+ for name in self._arguments:
+ args.append(data[name])
kw = {}
- if self._keyword_arguments:
- for name in self._keyword_arguments:
- if name in data:
- kw[str(name)] = data[name]
+ for name in self._keyword_arguments:
+ if name in data:
+ kw[str(name)] = data[name]
content = self.create(*args, **kw)
adapted = getAdapter(content, self.schema, context=self.context)
@@ -167,10 +165,12 @@
def add(_context, name, schema, content_factory='', label='',
permission = 'zope.Public', layer = "default",
- class_ = None, for_ = IAdding,
- template = None, fields=None, arguments=None, keyword_arguments=None,
- set_before_add=None, set_after_add=None,
- menu=None, title=None, description=''):
+ class_ = None, for_ = 'zope.app.interfaces.container.IAdding',
+ template = None, omit=None, fields=None,
+ arguments='', keyword_arguments='',
+ set_before_add='', set_after_add='',
+ menu=None, title=None, description='',
+ ):
# Handle menu attrs. We do this now to rather than later becaise
# menuItemDirective expects a dotted name for for_.
@@ -178,16 +178,24 @@
if (not menu) or (not title):
raise ValueError("If either menu or title are specified, "
"they must both be specified")
- menuItemDirective(
+ actions = menuItemDirective(
_context, menu, for_, '@@' + name, title,
permission=permission, description=description)
+ else:
+ actions = []
+
+
+ content_factory = (content_factory and _context.resolve(content_factory)
+ or None)
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'add.pt', fields, AddView)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'add.pt', fields, omit,
+ AddView)
leftover = fields
if arguments:
+ arguments = arguments.split()
missing = [n for n in arguments if n not in fields]
if missing:
raise ValueError("Some arguments are not included in the form",
@@ -200,6 +208,7 @@
leftover = [n for n in leftover if n not in arguments]
if keyword_arguments:
+ keyword_arguments = keyword_arguments.split()
missing = [n for n in keyword_arguments if n not in fields]
if missing:
raise ValueError(
@@ -208,6 +217,7 @@
leftover = [n for n in leftover if n not in keyword_arguments]
if set_before_add:
+ set_before_add = set_before_add.split()
missing = [n for n in set_before_add if n not in fields]
if missing:
raise ValueError(
@@ -216,6 +226,7 @@
leftover = [n for n in leftover if n not in set_before_add]
if set_after_add:
+ set_after_add = set_after_add.split()
missing = [n for n in set_after_add if n not in fields]
if missing:
raise ValueError(
@@ -226,12 +237,19 @@
set_after_add += leftover
else:
+
set_after_add = leftover
- _context.action(
+
+
+ actions += [
+ Action(
discriminator = ('view', for_, name, IBrowserPresentation, layer),
callable = AddViewFactory,
args = (name, schema, label, permission, layer, template, 'add.pt',
bases, for_, fields, content_factory, arguments,
keyword_arguments, set_before_add, set_after_add),
)
+ ]
+
+ return actions
=== Zope3/src/zope/app/browser/form/addwizard.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/form/addwizard.py:1.5 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/addwizard.py Sat Aug 2 05:11:08 2003
@@ -24,6 +24,7 @@
from zope.app.event.objectevent import ObjectCreatedEvent
from zope.app.interfaces.form import WidgetsError
from zope.app.form.utility import setUpWidgets, getWidgetsData
+from zope.configuration.action import Action
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.security.checker import defineChecker, NamesChecker
from zope.component import getAdapter
@@ -175,16 +176,21 @@
if (not menu) or (not title):
raise ValueError("If either menu or title are specified, "
"they must both be specified")
- menuItemDirective(
+ actions = menuItemDirective(
_context, menu, for_, '@@' + name, title,
permission=permission, description=description)
+ else:
+ actions = []
- self.content_factory = content_factory
+ self.content_factory = (
+ content_factory and _context.resolve(content_factory) or None
+ )
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'addwizard.pt', view=AddWizardView)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'addwizard.pt',
+ fields=None, omit=None, view=AddWizardView
+ )
- self._context = _context
self.schema = schema
self.for_ = for_
self.bases = bases
@@ -195,8 +201,10 @@
self.keyword_arguments = keyword_arguments
self.panes = []
+ self.actions = actions
def pane(self, _context, fields, label=''):
+ fields = [str(f) for f in fields.split(' ')]
for f in fields:
if f not in self.all_fields:
raise ValueError(
@@ -204,6 +212,7 @@
name, self.schema
)
self.panes.append(Pane(fields, label))
+ return []
def __call__(self):
@@ -215,6 +224,7 @@
arguments = self.arguments
if arguments:
+ arguments = arguments.split()
missing = [n for n in arguments if n not in fields]
if missing:
raise ValueError("Some arguments are not included in the form",
@@ -228,6 +238,7 @@
keyword_arguments = self.keyword_arguments
if keyword_arguments:
+ keyword_arguments = keyword_arguments.split()
missing = [n for n in keyword_arguments if n not in fields]
if missing:
raise ValueError(
@@ -237,6 +248,7 @@
set_before_add = self.set_before_add
if set_before_add:
+ set_before_add = set_before_add.split()
missing = [n for n in set_before_add if n not in fields]
if missing:
raise ValueError(
@@ -246,6 +258,7 @@
set_after_add = self.set_after_add
if set_after_add:
+ set_after_add = set_after_add.split()
missing = [n for n in set_after_add if n not in fields]
if missing:
raise ValueError(
@@ -259,13 +272,22 @@
set_after_add = leftover
- self._context.action(
- discriminator=('view', self.for_, self.name, IBrowserPresentation,
- self.layer),
- callable=AddWizardViewFactory,
- args=(self.name, self.schema, self.permission, self.layer,
- self.panes, self.all_fields, self.template, 'editwizard.pt',
- self.bases, self.for_, self.content_factory, arguments,
- keyword_arguments, self.set_before_add, self.set_after_add,
- self.use_session)
+ self.actions.append(
+ Action(
+ discriminator=(
+ 'view', self.for_, self.name, IBrowserPresentation,
+ self.layer
+ ),
+ callable=AddWizardViewFactory,
+ args=(
+ self.name, self.schema, self.permission, self.layer,
+ self.panes, self.all_fields, self.template, 'editwizard.pt',
+ self.bases, self.for_, self.content_factory, arguments,
+ keyword_arguments, self.set_before_add, self.set_after_add,
+ self.use_session,
+ )
+ )
)
+ return self.actions
+
+
=== Zope3/src/zope/app/browser/form/editview.py 1.30 => 1.31 ===
--- Zope3/src/zope/app/browser/form/editview.py:1.30 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/editview.py Sat Aug 2 05:11:08 2003
@@ -25,6 +25,7 @@
from zope.interface import classProvides, implements
+from zope.configuration.action import Action
from zope.app.context import ContextWrapper
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.browser import BrowserView
@@ -33,6 +34,7 @@
from zope.component import getAdapter
from zope.app.interfaces.form import WidgetsError
+from zope.app.component.metaconfigure import resolveInterface
from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
from zope.app.browser.form.submit import Update
from zope.app.event import publish
@@ -43,6 +45,7 @@
from zope.app.publisher.browser.globalbrowsermenuservice \
import menuItemDirective, globalBrowserMenuService
+
class EditView(BrowserView):
"""Simple edit-view base class
@@ -59,6 +62,7 @@
def __init__(self, context, request):
super(EditView, self).__init__(context, request)
+
self._setUpWidgets()
def _setUpWidgets(self):
@@ -113,6 +117,7 @@
self.update_status = status
return status
+
def EditViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_, fields,
fulledit_path=None, fulledit_label=None, menu=u'',
@@ -141,68 +146,93 @@
provideView(for_, name, IBrowserPresentation, class_, layer)
-def normalize(for_, schema, class_, template, default_template, fields, view=EditView):
+def normalize(_context, schema_, for_, class_, template, default_template,
+ fields, omit, view=EditView):
+ schema = resolveInterface(_context, schema_)
+
if for_ is None:
for_ = schema
+ else:
+ for_ = resolveInterface(_context, for_)
if class_ is None:
bases = view,
else:
- bases = (class_, view)
+ # XXX What about class_.__implements__ ?
+ bases = _context.resolve(class_), view
if template is not None:
+ template = _context.path(template)
template = os.path.abspath(str(template))
if not os.path.isfile(template):
raise ConfigurationError("No such file", template)
else:
template = default_template
+
+
names = getFieldNamesInOrder(schema)
if fields:
+ fields = fields.split()
for name in fields:
if name not in names:
raise ValueError("Field name is not in schema",
- name, schema)
+ name, schema_)
else:
fields = names
- return (for_, bases, template, fields)
+ if omit:
+ omit = omit.split()
+ for name in omit:
+ if name not in names:
+ raise ValueError("Field name is not in schema",
+ name, schema_)
+ fields = [name for name in fields if name not in omit]
+
+ return schema, for_, bases, template, fields
def edit(_context, name, schema, permission, label='',
- layer = "default", class_ = None, for_ = None,
- template = None, fields=None,
+ layer = "default",
+ class_ = None, for_ = None,
+ template = None, omit=None, fields=None,
menu=None, title='Edit', usage=u''):
if menu:
- menuItemDirective(
+ actions = menuItemDirective(
_context, menu, for_ or schema, '@@' + name, title,
permission=permission)
+ else:
+ actions = []
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'edit.pt', fields)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'edit.pt', fields, omit)
- _context.action(
- #XXX added schema to descriminator to make it unique
- # don't know whether that's a Good Thing(tm) -- philiKON
- discriminator=('view', for_, name, schema,
- IBrowserPresentation, layer),
+ actions.append(
+ Action(
+ discriminator=('view', for_, name, IBrowserPresentation, layer),
callable=EditViewFactory,
args=(name, schema, label, permission, layer, template, 'edit.pt',
bases, for_, fields, menu, usage),
)
+ )
+
+ return actions
def subedit(_context, name, schema, label,
permission='zope.Public', layer="default",
- class_=None, for_=None, template=None, fields=None,
+ class_=None, for_=None,
+ template=None, omit=None, fields=None,
fulledit=None, fulledit_label=None):
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'subedit.pt', fields)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'subedit.pt', fields, omit)
- _context.action(
+ return [
+ Action(
discriminator=('view', for_, name, IBrowserPresentation, layer),
callable=EditViewFactory,
args=(name, schema, label, permission, layer, template, 'subedit.pt',
bases, for_, fields, fulledit, fulledit_label),
)
+ ]
=== Zope3/src/zope/app/browser/form/editwizard.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/editwizard.py:1.8 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/editwizard.py Sat Aug 2 05:11:08 2003
@@ -22,6 +22,7 @@
from zope.component import getAdapter
from zope.app.publisher.browser.globalbrowsermenuservice \
import menuItemDirective, globalBrowserMenuService
+from zope.configuration.action import Action
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from editview import normalize, EditViewFactory, EditView
@@ -248,10 +249,11 @@
else:
actions = []
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'editwizard.pt', view=EditWizardView)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'editwizard.pt',
+ fields=None, omit=None, view=EditWizardView
+ )
- self._context = _context
self.schema = schema
self.for_ = for_
self.bases = bases
@@ -262,6 +264,8 @@
self.actions = actions
def pane(self, _context, fields, label=''):
+ fields = [str(f) for f in fields.split(' ')]
+
for f in fields:
if f not in self.all_fields:
raise ValueError(
@@ -269,16 +273,25 @@
name, self.schema
)
self.panes.append(Pane(fields, label))
+ return []
def __call__(self):
- self._context.action(
- discriminator=(
- 'view', self.for_, self.name, IBrowserPresentation, self.layer),
- callable=EditWizardViewFactory,
- args=(self.name, self.schema, self.permission, self.layer,
- self.panes, self.all_fields, self.template, 'editwizard.pt',
- self.bases, self.for_, self.menu, u'', self.use_session)
+ self.actions.append(
+ Action(
+ discriminator=(
+ 'view', self.for_, self.name, IBrowserPresentation,
+ self.layer
+ ),
+ callable=EditWizardViewFactory,
+ args=(
+ self.name, self.schema, self.permission, self.layer,
+ self.panes, self.all_fields, self.template, 'editwizard.pt',
+ self.bases, self.for_, self.menu, u'', self.use_session
+ )
+ )
)
+ return self.actions
+
def EditWizardViewFactory(name, schema, permission, layer,
panes, fields, template, default_template, bases, for_,
=== Zope3/src/zope/app/browser/form/meta.zcml 1.18 => 1.19 ===
--- Zope3/src/zope/app/browser/form/meta.zcml:1.18 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/meta.zcml Sat Aug 2 05:11:08 2003
@@ -1,60 +1,674 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta"
- >
-
- <meta:directives namespace="http://namespaces.zope.org/browser">
-
- <meta:complexDirective
- name="addwizard"
- schema=".metadirectives.IAddWizardDirective"
- handler="zope.app.browser.form.addwizard.AddWizardDirective"
- >
-
- <meta:subdirective
- name="pane"
- schema=".metadirectives.IPaneSubdirective"
- />
-
- </meta:complexDirective>
-
- <meta:complexDirective
- name="editwizard"
- schema=".metadirectives.IEditWizardDirective"
- handler="zope.app.browser.form.editwizard.EditWizardDirective"
- >
-
- <meta:subdirective
- name="pane"
- schema=".metadirectives.IPaneSubdirective"
- />
-
- </meta:complexDirective>
-
- <meta:directive
- name="editform"
- schema=".metadirectives.IEditFormDirective"
- handler=".editview.edit"
- />
-
- <meta:directive
- name="subeditform"
- schema=".metadirectives.ISubeditFormDirective"
- handler=".editview.subedit"
- />
-
- <meta:directive
- name="addform"
- schema=".metadirectives.IAddFormDirective"
- handler=".add.add"
- />
-
- <meta:directive
- name="schemadisplay"
- schema=".metadirectives.ISchemaDisplayDirective"
- handler=".schemadisplay.display"
- />
+<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
- </meta:directives>
+ <directives namespace="http://namespaces.zope.org/browser">
-</configure>
+ <directive name="addwizard"
+ handler="zope.app.browser.form.addwizard.AddWizardDirective">
+
+ <description>
+ Define an automatically generated add wizard (multi-page form)
+
+ The addwizard directive creates and registers a view for
+ adding an object based on a schema.
+
+ Adding an object is a bit trickier than editing an object,
+ because the object the schema applies to isn't available when
+ forms are being rendered. The addwizard directive provides an
+ customization interface to overcome this difficulty.
+
+ See zope.app.interfaces.browser.form.IAddFormCustomization.
+ </description>
+
+ <attribute name="name" required="yes">
+ <description>
+ The name of the generated add view.
+ </description>
+ </attribute>
+
+ <attribute name="schema" required="yes">
+ <description>
+ The schema from which the add form is generated.
+
+ A schema is an interface that includes fields.
+ </description>
+ </attribute>
+
+ <attribute name="for" required="no">
+ <description>
+ The interface this page (view) applies to.
+
+ The view will be for all objects that implement this interface.
+
+ zope.app.interfaces.container.IAdding is used if this
+ attribute isn't specified. If this attribute is specified,
+ then either the named interface must extend IAdding or a class
+ attribute must be used to supply a class implements certain
+ methods described in
+ zope.app.interfaces.browser.form.IAddFormCustomization.
+
+ The schema is used if the for attribute is not specified.
+
+ If the for attribute is specified, then the objects views must
+ implement or be adaptable to the schema.
+ </description>
+ </attribute>
+
+ <attribute name="layer" required="no">
+ <description>
+ The layer the view is in.
+
+ A skin is composed of layers. It is common to put skin specific
+ views in a layer named after the skin. If the 'layer' attribute
+ is not supplied, it defaults to 'default'.
+ </description>
+ </attribute>
+
+ <attribute name="permission" required="yes">
+ <description>
+ The permission needed to use the view.
+ </description>
+ </attribute>
+
+ <attribute name="template" required="no">
+ <description>
+ An alternate template to use for the add form.
+
+ XXX Need to document how to extend the default.
+ </description>
+ </attribute>
+
+ <attribute name="class" required="no">
+ <description>
+ A class to provide custom widget definitions or methods to be
+ used by a custom template.
+
+ This class can override methods defined in IAddFormCustomization.
+
+ This class is used as a mix-in class. As a result, it needn't
+ subclass any special classes, such as BrowserView.
+ </description>
+ </attribute>
+
+ <attribute name="content_factory" required="no">
+ <description>
+ The dotted name of an object to call to create new content objects.
+
+ This attribute isn't used if a class is specified that
+ implements createAndAdd.
+ </description>
+ </attribute>
+
+ <attribute name="arguments" required="no">
+ <description>
+ A list of field names to supply as positional arguments to
+ the factory.
+ </description>
+ </attribute>
+
+ <attribute name="keyword_arguments" required="no">
+ <description>
+ A list of field names to supply as keyword arguments to
+ the factory.
+ </description>
+ </attribute>
+
+ <attribute name="set_before_add" required="no">
+ <description>
+ A list of fields to be assigned to the newly created object
+ before it is added.
+ </description>
+ </attribute>
+
+ <attribute name="set_after_add" required="no">
+ <description>
+ A list of fields to be assigned to the newly created object
+ after it is added.
+ </description>
+ </attribute>
+
+ <attribute name="menu" required="no">
+ <description>
+ The browser menu to include the add form in.
+
+ Many views are included in menus. It's convenient to name
+ the menu in the page directive, rather than having to give a
+ separate menuItem directive.
+ </description>
+ </attribute>
+
+ <attribute name="description" required="no">
+ <description>
+ A longer description of the add form.
+
+ A UI may display this with the item or display it when the
+ user requests more assistance.
+ </description>
+ </attribute>
+
+
+ <attribute name="use_session" required="no">
+ <description>
+ If 'no', hidden input controls are used to maintain state
+ between panes in the wizard. Only simple data types can
+ be propagated with this method.
+
+ Defaults to 'yes'.
+ </description>
+ </attribute>
+
+ <subdirective name="pane"
+ description="Define a Pane (page) of the wizard">
+ <attribute name="fields" required="yes">
+ <description>
+ The fields and the order in which to display them. If this
+ is not specified, all schema fields will be displayed in the
+ order specified in the schema itself.
+ </description>
+ </attribute>
+ <attribute name="label" required="no">
+ <description>
+ The label used as the heading on this pane
+ </description>
+ </attribute>
+ </subdirective>
+
+ </directive>
+
+ <directive name="editwizard" handler=".editwizard.EditWizardDirective">
+ <description>
+ Define an automatically generated edit wizard (multi-page form).
+
+ The editwizard directive creates and register's a view for
+ editing an object based on a schema.
+ </description>
+
+ <attribute name="name" required="yes">
+ <description>
+ The name of the generated View
+ </description>
+ </attribute>
+
+ <attribute name="schema" required="yes">
+ <description>
+ The schema from which the edit form is generated.
+
+ A schema is an interface that includes fields.
+ </description>
+ </attribute>
+
+ <attribute name="for" required="no">
+ <description>
+ The interface this page (view) applies to.
+
+ The view will be for all objects that implement this interface.
+
+ The schema is used if the for attribute is not specified.
+
+ If the for attribute is specified, then the objects views must
+ implement or be adaptable to the schema.
+ </description>
+ </attribute>
+
+ <attribute name="permission" required="yes">
+ <description>
+ The permission needed to use the view.
+ </description>
+ </attribute>
+
+ <attribute name="template" required="no">
+ <description>
+ An alternate template to use for the edit form.
+
+ XXX Need to document how to extend the default.
+ </description>
+ </attribute>
+
+ <attribute name="layer" required="no">
+ <description>
+ The layer the view is in.
+
+ A skin is composed of layers. It is common to put skin specific
+ views in a layer named after the skin. If the 'layer' attribute
+ is not supplied, it defaults to 'default'.
+ </description>
+ </attribute>
+
+ <attribute name="class" required="no">
+ <description>
+ A class to provide custom widget definitions or methods to be
+ used by a custom template.
+
+ This class is used as a mix-in class. As a result, it needn't
+ subclass any special classes, such as BrowserView.
+ </description>
+ </attribute>
+
+ <attribute name="menu" required="no">
+ <description>
+ The browser menu to include the edit form in.
+
+ Many views are included in menus. It's convenient to name
+ the menu in the page directive, rather than having to give a
+ separate menuItem directive.
+ </description>
+ </attribute>
+
+ <attribute name="title" required="no">
+ <description>
+ The browser menu label for the edit form
+
+ This attribute defaults to "Edit".
+ </description>
+ </attribute>
+
+ <attribute name="use_session" required="no">
+ <description>
+ If 'no', hidden input controls are used to maintain state
+ between panes in the wizard. Only simple data types can
+ be propagated with this method.
+
+ Defaults to 'yes'.
+ </description>
+ </attribute>
+
+ <subdirective name="pane"
+ description="Define a Pane (page) of the wizard">
+ <attribute name="fields" required="yes">
+ <description>
+ The fields and the order in which to display them. If this
+ is not specified, all schema fields will be displayed in the
+ order specified in the schema itself.
+ </description>
+ </attribute>
+ <attribute name="label" required="no">
+ <description>
+ The label used as the heading on this pane
+ </description>
+ </attribute>
+ </subdirective>
+
+ </directive>
+
+ <directive name="editform" handler=".editview.edit">
+
+ <description>
+ Define an automatically generated edit form
+
+ The editform directive creates and register's a view for
+ editing an object based on a schema.
+ </description>
+
+ <attribute name="name" required="yes">
+ <description>
+ The name of the generated edit view.
+ </description>
+ </attribute>
+
+ <attribute name="schema" required="yes">
+ <description>
+ The schema from which the edit form is generated.
+
+ A schema is an interface that includes fields.
+ </description>
+ </attribute>
+
+ <attribute name="label" required="no">
+ <description>
+ A label to be used as the heading for the form.
+ </description>
+ </attribute>
+
+ <attribute name="for" required="no">
+ <description>
+ The interface this page (view) applies to.
+
+ The view will be for all objects that implement this interface.
+
+ The schema is used if the for attribute is not specified.
+
+ If the for attribute is specified, then the objects views must
+ implement or be adaptable to the schema.
+ </description>
+ </attribute>
+
+ <attribute name="fields" required="no">
+ <description>
+ The fields and the order in which to display them. If this
+ is not specified, all schema fields will be displayed in the
+ order specified in the schema itself.
+ </description>
+ </attribute>
+
+ <attribute name="layer" required="no">
+ <description>
+ The layer the view is in.
+
+ A skin is composed of layers. It is common to put skin specific
+ views in a layer named after the skin. If the 'layer' attribute
+ is not supplied, it defaults to 'default'.
+ </description>
+ </attribute>
+
+
+ <attribute name="permission" required="yes">
+ <description>
+ The permission needed to use the view.
+ </description>
+ </attribute>
+
+ <attribute name="template" required="no">
+ <description>
+ An alternate template to use for the edit form.
+
+ XXX Need to document how to extend the default.
+ </description>
+ </attribute>
+
+ <attribute name="class" required="no">
+ <description>
+ A class to provide custom widget definitions or methods to be
+ used by a custom template.
+
+ This class is used as a mix-in class. As a result, it needn't
+ subclass any special classes, such as BrowserView.
+ </description>
+ </attribute>
+
+
+ <attribute name="menu" required="no">
+ <description>
+ The browser menu to include the edit form in.
+
+ Many views are included in menus. It's convenient to name
+ the menu in the page directive, rather than having to give a
+ separate menuItem directive.
+ </description>
+ </attribute>
+
+ <attribute name="title" required="no">
+ <description>
+ The browser menu label for the edit form
+
+ This attribute defaults to "Edit".
+ </description>
+ </attribute>
+
+ </directive>
+
+ <directive
+ name="subeditform"
+ attributes="name schema label for layer permission class template
+ fulledit fulledit_label"
+ handler="zope.app.browser.form.editview.subedit"
+ />
+
+ <directive
+ name="addform"
+ handler="zope.app.browser.form.add.add"
+ attributes="menu title"
+ >
+ <description>
+ Define an automatically generated add form
+
+ The addform directive creates and registers a view for
+ adding an object based on a schema.
+
+ Adding an object is a bit trickier than editing an object,
+ because the object the schema applies to isn't available when
+ forms are being rendered. The addform directive provides an
+ customization interface to overcome this difficulty.
+
+ See zope.app.interfaces.browser.form.IAddFormCustomization.
+ </description>
+
+ <attribute name="name" required="yes">
+ <description>
+ The name of the generated add view.
+ </description>
+ </attribute>
+
+ <attribute name="schema" required="yes">
+ <description>
+ The schema from which the add form is generated.
+
+ A schema is an interface that includes fields.
+ </description>
+ </attribute>
+
+ <attribute name="label" required="no">
+ <description>
+ A label to be used as the heading for the form.
+ </description>
+ </attribute>
+
+ <attribute name="description" required="no">
+ <description>
+ A longer description of the add form.
+
+ A UI may display this with the item or display it when the
+ user requests more assistance.
+ </description>
+ </attribute>
+
+ <attribute name="for" required="no">
+ <description>
+ The interface this page (view) applies to.
+
+ The view will be for all objects that implement this interface.
+
+ zope.app.interfaces.container.IAdding is used if this
+ attribute isn't specified. If this attribute is specified,
+ then either the named interface must extend IAdding or a class
+ attribute must be used to supply a class implements certain
+ methods described in
+ zope.app.interfaces.browser.form.IAddFormCustomization.
+
+ The schema is used if the for attribute is not specified.
+
+ If the for attribute is specified, then the objects views must
+ implement or be adaptable to the schema.
+ </description>
+ </attribute>
+
+ <attribute name="fields" required="no">
+ <description>
+ The fields and the order in which to display them. If this
+ is not specified, all schema fields will be displayed in the
+ order specified in the schema itself.
+ </description>
+ </attribute>
+
+ <attribute name="layer" required="no">
+ <description>
+ The layer the view is in.
+
+ A skin is composed of layers. It is common to put skin specific
+ views in a layer named after the skin. If the 'layer' attribute
+ is not supplied, it defaults to 'default'.
+ </description>
+ </attribute>
+
+
+ <attribute name="permission" required="yes">
+ <description>
+ The permission needed to use the view.
+ </description>
+ </attribute>
+
+ <attribute name="template" required="no">
+ <description>
+ An alternate template to use for the add form.
+
+ XXX Need to document how to extend the default.
+ </description>
+ </attribute>
+
+ <attribute name="class" required="no">
+ <description>
+ A class to provide custom widget definitions or methods to be
+ used by a custom template.
+
+ This class can override methods defined in IAddFormCustomization.
+
+ This class is used as a mix-in class. As a result, it needn't
+ subclass any special classes, such as BrowserView.
+ </description>
+ </attribute>
+
+
+ <attribute name="content_factory" required="no">
+ <description>
+ The dotted name of an object to call to create new content objects.
+
+ This attribute isn't used if a class is specified that
+ implements createAndAdd.
+ </description>
+ </attribute>
+
+ <attribute name="arguments" required="no">
+ <description>
+ A list of field names to supply as positional arguments to
+ the factory.
+ </description>
+ </attribute>
+
+ <attribute name="keyword_arguments" required="no">
+ <description>
+ A list of field names to supply as keyword arguments to
+ the factory.
+ </description>
+ </attribute>
+
+ <attribute name="set_before_add" required="no">
+ <description>
+ A list of fields to be assigned to the newly created object
+ before it is added.
+ </description>
+ </attribute>
+
+ <attribute name="set_after_add" required="no">
+ <description>
+ A list of fields to be assigned to the newly created object
+ after it is added.
+ </description>
+ </attribute>
+
+ <attribute name="menu" required="no">
+ <description>
+ The browser menu to include the add form in.
+
+ Many views are included in menus. It's convenient to name
+ the menu in the page directive, rather than having to give a
+ separate menuItem directive.
+ </description>
+ </attribute>
+
+ </directive>
+
+ <directive name="schemadisplay" handler=".schemadisplay.display">
+
+ <description>
+ Define an automatically generated display form.
+
+ The schemadisplay directive creates and register's a view for
+ displaying an object based on a schema.
+ </description>
+
+ <attribute name="name" required="yes">
+ <description>
+ The name of the generated display view.
+ </description>
+ </attribute>
+
+ <attribute name="schema" required="yes">
+ <description>
+ The schema from which the display form is generated.
+
+ A schema is an interface that includes fields.
+ </description>
+ </attribute>
+
+ <attribute name="label" required="no">
+ <description>
+ A label to be used as the heading for the form.
+ </description>
+ </attribute>
+
+ <attribute name="for" required="no">
+ <description>
+ The interface this page (view) applies to.
+
+ The view will be for all objects that implement this interface.
+
+ The schema is used if the for attribute is not specified.
+
+ If the for attribute is specified, then the objects views must
+ implement or be adaptable to the schema.
+ </description>
+ </attribute>
+
+ <attribute name="fields" required="no">
+ <description>
+ The fields and the order in which to display them. If this
+ is not specified, all schema fields will be displayed in the
+ order specified in the schema itself.
+ </description>
+ </attribute>
+
+ <attribute name="layer" required="no">
+ <description>
+ The layer the view is in.
+
+ A skin is composed of layers. It is common to put skin specific
+ views in a layer named after the skin. If the 'layer' attribute
+ is not supplied, it defaults to 'default'.
+ </description>
+ </attribute>
+
+ <attribute name="permission" required="yes">
+ <description>
+ The permission needed to use the view.
+ </description>
+ </attribute>
+
+ <attribute name="template" required="no">
+ <description>
+ An alternate template to use for the display form.
+
+ XXX Need to document how to extend the default.
+ </description>
+ </attribute>
+
+ <attribute name="class" required="no">
+ <description>
+ A class to provide custom widget definitions or methods to be
+ used by a custom template.
+
+ This class is used as a mix-in class. As a result, it needn't
+ subclass any special classes, such as BrowserView.
+ </description>
+ </attribute>
+
+ <attribute name="menu" required="no">
+ <description>
+ The browser menu to include the display form in.
+
+ Many views are included in menus. It's convenient to name
+ the menu in the page directive, rather than having to give a
+ separate menuItem directive.
+ </description>
+ </attribute>
+
+ <attribute name="title" required="no">
+ <description>
+ The browser menu label for the display form
+
+ This attribute defaults to "Display".
+ </description>
+ </attribute>
+
+ </directive>
+
+ </directives>
+
+</zopeConfigure>
=== Zope3/src/zope/app/browser/form/schemadisplay.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/form/schemadisplay.py:1.6 Sat Aug 2 03:03:55 2003
+++ Zope3/src/zope/app/browser/form/schemadisplay.py Sat Aug 2 05:11:08 2003
@@ -19,6 +19,7 @@
from zope.schema import getFieldNamesInOrder
+from zope.configuration.action import Action
from zope.app.context import ContextWrapper
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.browser import BrowserView
@@ -33,7 +34,9 @@
from zope.app.publisher.browser.globalbrowsermenuservice \
import menuItemDirective, globalBrowserMenuService
-from editview import normalize
+# XXX perhaps a little too intimate?
+from zope.app.browser.form.editview import normalize
+
class DisplayView(BrowserView):
"""Simple display-view base class.
@@ -92,21 +95,25 @@
permission))
provideView(for_, name, IBrowserPresentation, class_, layer)
+
def display(_context, name, schema, permission, label='',
- layer="default", class_=None, for_=None,
- template=None, fields=None,
+ layer="default",
+ class_=None, for_=None,
+ template=None, omit=None, fields=None,
menu=None, title='Display', usage=u''):
+ actions = []
if menu:
actions = menuItemDirective(
_context, menu, for_ or schema, '@@' + name, title,
permission=permission)
- for_, bases, template, fields = normalize(
- for_, schema, class_, template, 'display.pt', fields, DisplayView)
+ schema, for_, bases, template, fields = normalize(
+ _context, schema, for_, class_, template, 'display.pt', fields, omit,
+ DisplayView)
- _context.action(
+ actions.append(Action(
discriminator=('view', for_, name, IBrowserPresentation, layer),
callable=DisplayViewFactory,
args=(name, schema, label, permission, layer, template, 'display.pt',
- bases, for_, fields, menu, usage)
- )
+ bases, for_, fields, menu, usage)))
+ return actions
=== Removed File Zope3/src/zope/app/browser/form/metadirectives.py ===