[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widgets.txt:1.3

Philipp von Weitershausen philikon at philikon.de
Fri Jan 16 08:14:47 EST 2004


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

Modified Files:
	widgets.txt 
Log Message:
Update docs (CustomWidgetFactory, new package hierarchy, etc.)


=== Zope3/src/zope/app/browser/form/widgets.txt 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/widgets.txt:1.2	Fri Aug 22 16:02:10 2003
+++ Zope3/src/zope/app/browser/form/widgets.txt	Fri Jan 16 08:14:46 2004
@@ -1,8 +1,8 @@
 Simple example showing ObjectWidget and SequenceWidget usage
 ============================================================
 
-The following implements a Poll product (add it as zopeproducts/poll) which
-has poll options defined as:
+The following implements a Poll product (add it as
+zope/products/demo/poll) which has poll options defined as:
 
 label
   A TextLine holding the label of the option
@@ -49,7 +49,7 @@
     from zope.schema.interfaces import ITextLine
     from zope.i18n import MessageIDFactory
 
-    _ = MessageIDFactory("zopeproducts.poll")
+    _ = MessageIDFactory("poll")
 
     class IPollOption(Interface):
         label = TextLine(title=u'Label', min_length=1)
@@ -81,7 +81,7 @@
 
     from zope.app.browser.form.editview import EditView
     from zope.app.browser.form.add import AddView
-    from zope.app.form.widget import CustomWidget
+    from zope.app.form.widget import CustomWidgetFactory
     from zope.app.browser.form.widget import SequenceWidget, ObjectWidget
 
     from interfaces import IPoll
@@ -94,8 +94,8 @@
             self.context.choose(option)
             self.request.response.redirect('.')
 
-    ow = CustomWidget(ObjectWidget, PollOption)
-    sw = CustomWidget(SequenceWidget, subwidget=ow)
+    ow = CustomWidgetFactory(ObjectWidget, PollOption)
+    sw = CustomWidgetFactory(SequenceWidget, subwidget=ow)
 
     class PollEditView(EditView):
         __used_for__ = IPoll
@@ -107,22 +107,22 @@
 
         options_widget = sw
 
-Note the creation of the widget via a CustomWidget - this *should* be
-called CustomWidgetFactory, since it actually creates a new widget every
-time it's used. So, whenever the options_widget is used, a new
-``SequenceWidget(subwidget=CustomWidget(ObjectWidget, PollOption))`` is
-created. The subwidget argument indicates that each item in the sequence
-should be represented by the indicated widget instead of their default. If
-the contents of the sequence were just Text Fields, then the default would
-be just fine - the only odd cases are Sequence and Object Widgets because
-they need additional arguments when they're created.
+Note the creation of the widget via a CustomWidgetFactory. So,
+whenever the options_widget is used, a new
+``SequenceWidget(subwidget=CustomWidgetFactory(ObjectWidget,
+PollOption))`` is created. The subwidget argument indicates that each
+item in the sequence should be represented by the indicated widget
+instead of their default. If the contents of the sequence were just
+Text Fields, then the default would be just fine - the only odd cases
+are Sequence and Object Widgets because they need additional arguments
+when they're created.
 
 Each item in the sequence will be represented by a
-``CustomWidget(ObjectWidget, PollOption)`` - thus a new
-``ObjectWidget(context, request, PollOption)`` is created for each one. The
-PollOption class ("factory") is used to create new instances when new data
-is created in add forms (or edit forms when we're adding new items to a
-Sequence).
+``CustomWidgetFactory(ObjectWidget, PollOption)`` - thus a new
+``ObjectWidget(context, request, PollOption)`` is created for each
+one. The PollOption class ("factory") is used to create new instances
+when new data is created in add forms (or edit forms when we're adding
+new items to a Sequence).
 
 Tying all this together is the ``configure.zcml``::
 
@@ -130,8 +130,8 @@
         xmlns:browser='http://namespaces.zope.org/browser'>
 
     <content class=".poll.Poll">
-    <factory id="zopeproducts.poll"
-            permission="zope.ManageContent" />
+    <factory id="zope.products.demo.poll"
+             permission="zope.ManageContent" />
 
     <implements 
         interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
@@ -175,7 +175,7 @@
         schema=".interfaces.IPoll"
         label="Add a Poll"
         content_factory=".poll.Poll"
-        name="zopeproducts.poll"
+        name="zope.products.demo.poll"
         class=".browser.PollAddView"
         menu="add_content" title="Poll"
         permission="zope.ManageContent" />




More information about the Zope3-Checkins mailing list