[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form -
vocabularywidget.zcml:1.2 add.py:1.39 addwizard.py:1.13
configure.zcml:1.27 editview.py:1.51 editwizard.py:1.24
schemadisplay.py:1.18 vocabularywidget.py:1.65 widget.py:1.66
Garrett Smith
garrett at mojave-corp.com
Fri Mar 5 23:17:48 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv15646/src/zope/app/browser/form
Modified Files:
add.py addwizard.py configure.zcml editview.py editwizard.py
schemadisplay.py vocabularywidget.py widget.py
Added Files:
vocabularywidget.zcml
Log Message:
Merged changes from garrett-widgets2-branch:
- Changed the way widgets are looked up to use interfaces instead of
names.
- Refactor of zope/app/form/utility.py -- see
http://dev.zope.org/Zope3/WidgetsAndMultiwayAdapters
for details.
- Moved configuration of vocab widgets to its own zcml file
(zope/app/browser/form/vocabularywidget.zcml).
- Removed 'propertyNames' and 'getValue' from widgets. This is replaced
by accessing the widget attributes directly.
- Deleted depreated methods from widget interface: haveData and getData.
=== Zope3/src/zope/app/browser/form/vocabularywidget.zcml 1.1 => 1.2 ===
--- /dev/null Fri Mar 5 23:17:48 2004
+++ Zope3/src/zope/app/browser/form/vocabularywidget.zcml Fri Mar 5 23:17:17 2004
@@ -0,0 +1,81 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <!-- Query view helpers -->
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ allowed_interface="zope.app.browser.interfaces.form.IVocabularyQueryView"
+ for="zope.schema.interfaces.IIterableVocabularyQuery"
+ name="widget-query-helper"
+ factory=".vocabularywidget.IterableVocabularyQueryView"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ allowed_interface="zope.app.browser.interfaces.form.IVocabularyQueryView"
+ for="zope.schema.interfaces.IIterableVocabularyQuery"
+ name="widget-query-list-helper"
+ factory=".vocabularywidget.IterableVocabularyQueryMultiView"
+ permission="zope.Public"
+ />
+
+ <!-- Vocabulary field display widgets -->
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyDisplayWidget"
+ name="field-display-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyBagDisplayWidget"
+ name="field-display-bag-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyListDisplayWidget"
+ name="field-display-list-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyBagDisplayWidget"
+ name="field-display-set-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyListDisplayWidget"
+ name="field-display-unique-list-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <!-- Vocabulary edit widgets -->
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyEditWidget"
+ name="field-edit-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ factory=".vocabularywidget.VocabularyMultiEditWidget"
+ name="field-edit-list-widget"
+ for="zope.schema.interfaces.IVocabulary"
+ permission="zope.Public"
+ />
+
+
+</configure>
=== Zope3/src/zope/app/browser/form/add.py 1.38 => 1.39 ===
--- Zope3/src/zope/app/browser/form/add.py:1.38 Wed Feb 25 18:02:17 2004
+++ Zope3/src/zope/app/browser/form/add.py Fri Mar 5 23:17:17 2004
@@ -24,6 +24,7 @@
from zope.app.event.objectevent import ObjectCreatedEvent
from zope.app.form.utility import setUpWidgets, getWidgetsData
from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.interfaces.form import IInputWidget
from zope.app.interfaces.form import WidgetsError
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -42,7 +43,7 @@
"""
def _setUpWidgets(self):
- setUpWidgets(self, self.schema, names=self.fieldNames)
+ setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
def update(self):
@@ -54,10 +55,7 @@
self.update_status = ''
try:
- data = getWidgetsData(self, self.schema,
- strict=True,
- names=self.fieldNames,
- set_missing=False)
+ data = getWidgetsData(self, self.schema, names=self.fieldNames)
self.createAndAdd(data)
except WidgetsError, errors:
self.errors = errors
=== Zope3/src/zope/app/browser/form/addwizard.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/browser/form/addwizard.py:1.12 Fri Nov 21 12:10:10 2003
+++ Zope3/src/zope/app/browser/form/addwizard.py Fri Mar 5 23:17:17 2004
@@ -22,6 +22,7 @@
from zope.app.event.objectevent import ObjectCreatedEvent
from zope.app.form.utility import setUpWidgets
from zope.app.interfaces.form import WidgetsError
+from zope.app.interfaces.form import IInputWidget
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.component import getAdapter
@@ -44,7 +45,7 @@
else:
self.storage = WizardStorage(self.fieldNames, None)
- setUpWidgets(self, self.schema, names=self.fieldNames)
+ setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
def create(self, *args, **kw):
"""Do the actual instantiation."""
=== Zope3/src/zope/app/browser/form/configure.zcml 1.26 => 1.27 ===
--- Zope3/src/zope/app/browser/form/configure.zcml:1.26 Tue Mar 2 13:27:36 2004
+++ Zope3/src/zope/app/browser/form/configure.zcml Fri Mar 5 23:17:17 2004
@@ -1,366 +1,266 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser">
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <!-- Core display widgets -->
- <!-- Form Widget View Directives -->
- <browser:defaultView for="zope.schema.interfaces.IField" name="edit" />
-
- <!-- XXX The next directive should be replaced by one that
- uses a 'smart' widget that knows how to deal with type-agnostic
- values, which is the porpose of zope.schema.Field -->
-
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IField"
- name="edit"
- class="zope.app.browser.form.widget.BrowserWidget"
- />
-
- <browser:page
+ provides="zope.app.interfaces.form.IDisplayWidget"
+ factory="zope.app.browser.form.widget.DisplayWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITextLine"
- name="edit"
- class="zope.app.browser.form.widget.TextWidget"
/>
-
- <browser:page
+
+ <!-- Core edit widgets -->
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITextLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IText"
- name="edit"
- class="zope.app.browser.form.widget.TextAreaWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IText"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextAreaWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ISourceText"
- name="edit"
- class="zope.app.browser.form.widget.TextAreaWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ISourceText"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TextAreaWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IBytesLine"
- name="edit"
- class="zope.app.browser.form.widget.BytesWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IBytesLine"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.BytesWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IBytes"
- name="edit"
- class="zope.app.browser.form.widget.FileWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IBytes"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.FileWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IASCII"
- name="edit"
- class="zope.app.browser.form.widget.BytesAreaWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IASCII"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.BytesAreaWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IInt"
- name="edit"
- class="zope.app.browser.form.widget.IntWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IInt"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.IntWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IFloat"
- name="edit"
- class="zope.app.browser.form.widget.FloatWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IFloat"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.FloatWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IDatetime"
- name="edit"
- class="zope.app.browser.form.widget.DatetimeWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IDatetime"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.DatetimeWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IDate"
- name="edit"
- class="zope.app.browser.form.widget.DateWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IDate"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.DateWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IBool"
- name="edit"
- class="zope.app.browser.form.widget.CheckBoxWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IBool"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.CheckBoxWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.ITuple"
- name="edit"
- class="zope.app.browser.form.widget.TupleSequenceWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.ITuple"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.TupleSequenceWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IList"
- name="edit"
- class="zope.app.browser.form.widget.ListSequenceWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IList"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.ListSequenceWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IObject"
- name="edit"
- class="zope.app.browser.form.widget.ObjectWidget"
/>
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IPassword"
- name="edit"
- class="zope.app.browser.form.widget.PasswordWidget"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory="zope.app.browser.form.widget.PasswordWidget"
+ permission="zope.Public"
/>
<!-- Widgets for enumerated field flavours -->
- <browser:page
- permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IEnumeratedTextLine"
- name="edit"
- class=".enumerated.EnumeratedTextWidget"
- />
-
- <browser:page
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".enumerated.EnumeratedTextWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IEnumeratedInt"
- name="edit"
- class=".enumerated.EnumeratedIntWidget"
- />
+ />
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IEnumeratedInt"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".enumerated.EnumeratedIntWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IEnumeratedFloat"
- name="edit"
- class=".enumerated.EnumeratedFloatWidget"
/>
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IEnumeratedFloat"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".enumerated.EnumeratedFloatWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IEnumeratedDatetime"
- name="edit"
- class=".enumerated.EnumeratedDatetimeWidget"
- />
+ />
- <browser:page
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IEnumeratedDatetime"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".enumerated.EnumeratedDatetimeWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IEnumeratedDate"
- name="edit"
- class=".enumerated.EnumeratedDateWidget"
- />
+ />
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IEnumeratedDate"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".enumerated.EnumeratedDateWidget"
+ permission="zope.Public"
+ />
+
<!-- Vocabulary fields share special widget factories that redirect
to the vocabularies they reference. -->
<!-- Single selection -->
+
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyField"
- name="display"
+ for="zope.schema.interfaces.IVocabularyField"
+ provides="zope.app.interfaces.form.IDisplayWidget"
factory=".vocabularywidget.VocabularyFieldDisplayWidget"
+ permission="zope.Public"
/>
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyField"
- name="edit"
+ for="zope.schema.interfaces.IVocabularyField"
+ provides="zope.app.interfaces.form.IInputWidget"
factory=".vocabularywidget.VocabularyFieldEditWidget"
+ permission="zope.Public"
/>
<!-- Bags -->
+
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyBagField"
- name="display"
+ for="zope.schema.interfaces.IVocabularyBagField"
+ provides="zope.app.interfaces.form.IDisplayWidget"
factory=".vocabularywidget.VocabularyBagFieldDisplayWidget"
+ permission="zope.Public"
/>
-
+
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyBagField"
- name="edit"
+ for="zope.schema.interfaces.IVocabularyBagField"
+ provides="zope.app.interfaces.form.IInputWidget"
factory=".vocabularywidget.VocabularyBagFieldEditWidget"
- />
-
- <!-- Lists -->
- <view
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyListField"
- name="display"
- factory=".vocabularywidget.VocabularyListFieldDisplayWidget"
/>
- <view
- permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyListField"
- name="edit"
- factory=".vocabularywidget.VocabularyListFieldEditWidget"
- />
+ <!-- Lists -->
- <!-- Sets -->
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularySetField"
- name="display"
- factory=".vocabularywidget.VocabularySetFieldDisplayWidget"
- />
-
- <view
+ for="zope.schema.interfaces.IVocabularyListField"
+ provides="zope.app.interfaces.form.IDisplayWidget"
+ factory=".vocabularywidget.VocabularyListFieldDisplayWidget"
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularySetField"
- name="edit"
- factory=".vocabularywidget.VocabularySetFieldEditWidget"
/>
- <!-- Unique lists -->
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyUniqueListField"
- name="display"
- factory=".vocabularywidget.VocabularyUniqueListFieldDisplayWidget"
- />
-
- <view
+ for="zope.schema.interfaces.IVocabularyListField"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".vocabularywidget.VocabularyListFieldEditWidget"
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.vocabulary.IVocabularyUniqueListField"
- name="edit"
- factory=".vocabularywidget.VocabularyUniqueListFieldEditWidget"
/>
- <!-- Query view helpers -->
- <view
- permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IVocabularyQueryView"
- for="zope.schema.interfaces.IIterableVocabularyQuery"
- name="widget-query-helper"
- factory=".vocabularywidget.IterableVocabularyQueryView"
- />
+ <!-- Sets -->
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- allowed_interface="zope.app.browser.interfaces.form.IVocabularyQueryView"
- for="zope.schema.interfaces.IIterableVocabularyQuery"
- name="widget-query-list-helper"
- factory=".vocabularywidget.IterableVocabularyQueryMultiView"
- />
-
- <!-- Vocabulary field display widgets -->
- <view
+ for="zope.schema.interfaces.IVocabularySetField"
+ provides="zope.app.interfaces.form.IDisplayWidget"
+ factory=".vocabularywidget.VocabularySetFieldDisplayWidget"
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyDisplayWidget"
- name="field-display-widget"
- for="zope.schema.interfaces.IVocabulary"
/>
-
+
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyBagDisplayWidget"
- name="field-display-bag-widget"
- for="zope.schema.interfaces.IVocabulary"
- />
-
- <view
+ for="zope.schema.interfaces.IVocabularySetField"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".vocabularywidget.VocabularySetFieldEditWidget"
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyListDisplayWidget"
- name="field-display-list-widget"
- for="zope.schema.interfaces.IVocabulary"
/>
- <view
- permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyBagDisplayWidget"
- name="field-display-set-widget"
- for="zope.schema.interfaces.IVocabulary"
- />
+ <!-- Unique lists -->
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyListDisplayWidget"
- name="field-display-unique-list-widget"
- for="zope.schema.interfaces.IVocabulary"
- />
-
- <!-- Vocabulary edit widgets -->
- <view
+ for="zope.schema.interfaces.IVocabularyUniqueListField"
+ provides="zope.app.interfaces.form.IDisplayWidget"
+ factory=".vocabularywidget.VocabularyUniqueListFieldDisplayWidget"
permission="zope.Public"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyEditWidget"
- name="field-edit-widget"
- for="zope.schema.interfaces.IVocabulary"
/>
-
+
<view
- permission="zope.Public"
type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".vocabularywidget.VocabularyMultiEditWidget"
- name="field-edit-list-widget"
- for="zope.schema.interfaces.IVocabulary"
- />
-
- <!-- Default simple display view -->
- <browser:page
+ for="zope.schema.interfaces.IVocabularyUniqueListField"
+ provides="zope.app.interfaces.form.IInputWidget"
+ factory=".vocabularywidget.VocabularyUniqueListFieldEditWidget"
permission="zope.Public"
- allowed_interface="zope.app.browser.interfaces.form.IBrowserWidget"
- for="zope.schema.interfaces.IField"
- name="display"
- class="zope.app.browser.form.widget.DisplayWidget"
/>
+
+ <!-- implementation support for vocabulary field widgets -->
+
+ <include file="vocabularywidget.zcml" />
</configure>
=== Zope3/src/zope/app/browser/form/editview.py 1.50 => 1.51 ===
--- Zope3/src/zope/app/browser/form/editview.py:1.50 Fri Mar 5 17:08:55 2004
+++ Zope3/src/zope/app/browser/form/editview.py Fri Mar 5 23:17:17 2004
@@ -66,8 +66,8 @@
adapted = LocationProxy(adapted)
adapted.__parent__ = self.context
self.adapted = adapted
- setUpEditWidgets(self, self.schema, names=self.fieldNames,
- content=self.adapted)
+ setUpEditWidgets(self, self.schema, source=self.adapted,
+ names=self.fieldNames)
def setPrefix(self, prefix):
for widget in self.widgets():
@@ -95,8 +95,8 @@
if Update in self.request:
changed = False
try:
- changed = applyWidgetsChanges(self, content, self.schema,
- names=self.fieldNames, exclude_readonly=True)
+ changed = applyWidgetsChanges(self, self.schema,
+ target=content, names=self.fieldNames)
# We should not generate events when an adapter is used.
# That's the adapter's job.
if changed and self.context is self.adapted:
@@ -105,8 +105,9 @@
self.errors = errors
status = _("An error occured.")
else:
- setUpEditWidgets(self, self.schema, force=1,
- names=self.fieldNames, content=self.adapted)
+ setUpEditWidgets(self, self.schema, source=self.adapted,
+ ignoreStickyValues=True,
+ names=self.fieldNames)
if changed:
self.changed()
formatter = self.request.locale.dates.getFormatter(
=== Zope3/src/zope/app/browser/form/editwizard.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/browser/form/editwizard.py:1.23 Fri Mar 5 17:08:55 2004
+++ Zope3/src/zope/app/browser/form/editwizard.py Fri Mar 5 23:17:17 2004
@@ -79,9 +79,8 @@
self.storage = WizardStorage(self.fieldNames, adapted)
# Add all our widgets as attributes on this view
- setUpEditWidgets(
- self, self.schema, names=self.fieldNames, content=self.storage
- )
+ setUpEditWidgets(self, self.schema, source=self.storage,
+ names=self.fieldNames)
def widgets(self):
return [getattr(self, name+'_widget')
@@ -124,10 +123,7 @@
# Validate the current pane, and set self.errors
try:
names = self.currentPane().names
- data = getWidgetsData(
- self, self.schema, strict=True, set_missing=True,
- names=names, exclude_readonly=True
- )
+ data = getWidgetsData(self, self.schema, names=names)
self.errors = {}
except WidgetsError, errors:
x = {}
@@ -149,10 +145,7 @@
# Data from panes other than the current one is still
# stuck in request
self.storage.update(getWidgetsData(
- self, self.schema, strict=True, set_missing=True,
- names=self.fieldNames, exclude_readonly=True
- ))
-
+ self, self.schema, names=self.fieldNames))
if self.apply_update(self.storage):
self.feedback = _(u'No changes to save')
else:
@@ -186,10 +179,8 @@
for k,v in storage.items():
getattr(self,k).setRenderedValue(v)
content = self.adapted
- changed = applyWidgetsChanges(
- self, content, self.schema,
- names=self.fieldNames, exclude_readonly=True
- )
+ changed = applyWidgetsChanges(self, self.schema, target=content,
+ names=self.fieldNames)
# We should not generate events when an adapter is used.
# That's the adapter's job
if changed and self.context is self.adapted:
=== Zope3/src/zope/app/browser/form/schemadisplay.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/browser/form/schemadisplay.py:1.17 Fri Mar 5 17:08:55 2004
+++ Zope3/src/zope/app/browser/form/schemadisplay.py Fri Mar 5 23:17:17 2004
@@ -55,8 +55,8 @@
adapted = LocationProxy(adapted)
adapted.__parent__ = self.context
self.adapted = adapted
- setUpDisplayWidgets(self, self.schema, names=self.fieldNames,
- content=adapted)
+ setUpDisplayWidgets(self, self.schema, source=adapted,
+ names=self.fieldNames)
def setPrefix(self, prefix):
for widget in self.widgets():
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.64 => 1.65 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.64 Tue Mar 2 13:27:36 2004
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Fri Mar 5 23:17:17 2004
@@ -165,8 +165,6 @@
class VocabularyWidgetBase(ViewSupport, widget.BrowserWidget):
"""Convenience base class for vocabulary-based widgets."""
- propertyNames = widget.BrowserWidget.propertyNames + ["extra"]
-
extra = ""
type = "vocabulary"
context = None
@@ -324,32 +322,29 @@
class VocabularyMultiDisplayWidget(MultiDataHelper, VocabularyWidgetBase):
- propertyNames = (VocabularyWidgetBase.propertyNames
- + ['itemTag', 'tag'])
-
itemTag = 'li'
tag = 'ol'
def render(self, value):
if value:
rendered_items = self.renderItems(value)
- return widget.renderElement(self.getValue('tag'),
- type=self.getValue('type'),
+ return widget.renderElement(self.tag,
+ type=self.type,
name=self.name,
id=self.name,
- cssClass=self.getValue('cssClass'),
+ cssClass=self.cssClass,
contents="\n".join(rendered_items),
- extra=self.getValue('extra'))
+ extra=self.extra)
else:
return self.translate(_msg_missing_multiple_value_display)
def renderItems(self, value):
L = []
vocabulary = self.context.vocabulary
- cssClass = self.getValue('cssClass') or ''
+ cssClass = self.cssClass or ''
if cssClass:
cssClass += "-item"
- tag = self.getValue('itemTag')
+ tag = self.itemTag
for v in value:
term = vocabulary.getTerm(v)
L.append(widget.renderElement(tag,
@@ -403,8 +398,7 @@
class VocabularyEditWidgetBase(VocabularyWidgetBase):
- propertyNames = (VocabularyWidgetBase.propertyNames
- + ['size', 'tag'])
+
size = 5
tag = 'select'
@@ -446,7 +440,7 @@
s = self.queryview.renderInput()
if s:
contents.append(self._div('queryinput', s))
- return self._div(self.getValue('cssClass'), "\n".join(contents),
+ return self._div(self.cssClass, "\n".join(contents),
id=self.name)
def _div(self, cssClass, contents, **kw):
@@ -461,7 +455,7 @@
"""Render the list of possible values, with those found in
'values' being marked as selected."""
- cssClass = self.getValue('cssClass')
+ cssClass = self.cssClass
# multiple items with the same value are not allowed from a
# vocabulary, so that need not be considered here
@@ -508,7 +502,6 @@
to be small.
"""
implements(implementedBy(widget.SingleItemsWidget))
- propertyNames = VocabularyEditWidgetBase.propertyNames + ['firstItem']
firstItem = False
_msg_no_value = _msg_missing_single_value_edit
@@ -559,7 +552,7 @@
values = ()
L = self.renderItemsWithValues(values)
if not self.context.required:
- cssClass = self.getValue('cssClass')
+ cssClass = self.cssClass
kwargs = {
'value':'',
'name':self.name,
@@ -580,7 +573,6 @@
to be very large.
"""
implements(implementedBy(widget.SingleItemsWidget))
- propertyNames = VocabularyEditWidgetBase.propertyNames + ['firstItem']
firstItem = False
_msg_no_value = _msg_missing_single_value_edit
@@ -591,8 +583,8 @@
return widget.renderElement('select',
name=self.name,
contents=contents,
- size=self.getValue('size'),
- extra=self.getValue('extra'))
+ size=self.size,
+ extra=self.extra)
def renderItems(self, value):
vocabulary = self.context.vocabulary
@@ -637,12 +629,12 @@
# All we really add here is the ':list' in the name argument
# to widget.renderElement().
rendered_items = self.renderItems(value)
- return widget.renderElement(self.getValue('tag'),
+ return widget.renderElement(self.tag,
name=self.name + ':list',
multiple=None,
- size=self.getValue('size'),
+ size=self.size,
contents="\n".join(rendered_items),
- extra=self.getValue('extra'))
+ extra=self.extra)
class VocabularyQueryViewBase(ActionHelper, ViewSupport, BrowserView):
=== Zope3/src/zope/app/browser/form/widget.py 1.65 => 1.66 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.65 Tue Mar 2 13:27:36 2004
+++ Zope3/src/zope/app/browser/form/widget.py Fri Mar 5 23:17:17 2004
@@ -31,6 +31,7 @@
from zope.app import zapi
from zope.app.tests import ztapi
+from zope.app.interfaces.form import IInputWidget
from zope.app.browser.interfaces.form import IBrowserWidget
from zope.app.form.widget import Widget
from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
@@ -50,7 +51,7 @@
labels, titles, and descriptions are translated and the
errors are rendered with the view machinery, so we need to set up
a lot of machinery to support translation and views:
-
+
>>> setUp() # now we have to set up an error view...
>>> from zope.app.interfaces.form import IWidgetInputError
>>> from zope.app.publisher.browser import BrowserView
@@ -138,30 +139,18 @@
Now we clean up.
>>> tearDown()
-
"""
implements(IBrowserWidget)
- propertyNames = (Widget.propertyNames +
- ['tag', 'type', 'cssClass', 'extra'])
-
tag = 'input'
type = 'text'
cssClass = ''
extra = ''
_missing = ''
_error = None
-
- def haveData(self):
- if traceback.extract_stack()[-2][2] != 'hasInput':
- warn("haveData is deprecated - use hasInput",
- DeprecationWarning, 2)
-
- # XXX - move this implementation to hasInput when deprecation is
- # removed
-
- return self.name in self.request.form
+
+ required = property(lambda self: self.context.required)
def hasInput(self):
"""See IWidget.hasInput.
@@ -174,7 +163,7 @@
forms when their value is 'off' -- in this case the widget will
need to add a hidden element to signal its presence in the form.
"""
- return self.haveData()
+ return self.name in self.request.form
def hasValidInput(self):
try:
@@ -183,14 +172,7 @@
except WidgetInputError:
return False
- def getData(self):
- if traceback.extract_stack()[-2][2] != 'getInputValue':
- warn("getData is deprecated - use getInputValue",
- DeprecationWarning, 2)
-
- # XXX - move this implementation to getInputValue when deprecation
- # is removed
-
+ def getInputValue(self):
self._error = None
field = self.context
@@ -215,9 +197,6 @@
raise self._error
return value
- def getInputValue(self):
- return self.getData()
-
def validate(self):
self.getInputValue()
@@ -263,7 +242,7 @@
def _showData(self):
"""Returns a value suitable for use as an HTML form value."""
- if self._data is self._data_marker:
+ if not self._renderedValueSet():
if self.hasInput():
try:
value = self.getInputValue()
@@ -282,22 +261,22 @@
return self.context.default
def __call__(self):
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- value = self._showData(),
- cssClass = self.getValue('cssClass'),
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ value=self._showData(),
+ cssClass=self.cssClass,
+ extra=self.extra)
def hidden(self):
- return renderElement(self.getValue('tag'),
- type = 'hidden',
- name = self.name,
- id = self.name,
- value = self._showData(),
- cssClass = self.getValue('cssClass'),
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type='hidden',
+ name=self.name,
+ id=self.name,
+ value=self._showData(),
+ cssClass=self.cssClass,
+ extra=self.extra)
def render(self, value):
warn("The widget render method is deprecated",
@@ -335,91 +314,24 @@
self.error())
else:
return '<div class="%s">%s</div><div class="field">%s</div>' % (
- self.labelClass(), self.label(), self()
- )
+ self.labelClass(), self.label(), self())
+
class DisplayWidget(BrowserWidget):
def __call__(self):
return self._showData()
+
class CheckBoxWidget(BrowserWidget):
- """Checkbox widget
-
- >>> from zope.publisher.browser import TestRequest
- >>> from zope.schema import Bool
- >>> field = Bool(__name__='foo', title=u'on')
- >>> request = TestRequest(form={'field.foo.used': u'on',
- ... 'field.foo': u'on'})
- >>> widget = CheckBoxWidget(field, request)
- >>> widget.hasInput()
- True
- >>> widget.getInputValue()
- True
-
- >>> def normalize(s):
- ... return '\\n '.join(s.split())
-
- >>> print normalize( widget() )
- <input
- class="hiddenType"
- id="field.foo.used"
- name="field.foo.used"
- type="hidden"
- value=""
- />
- <input
- class="checkboxType"
- checked="checked"
- id="field.foo"
- name="field.foo"
- type="checkbox"
- />
-
- >>> print normalize( widget.hidden() )
- <input
- class="hiddenType"
- id="field.foo"
- name="field.foo"
- type="hidden"
- value="on"
- />
-
- Calling setRenderedValue will change what gets output:
-
- >>> widget.setRenderedValue(False)
- >>> print normalize( widget() )
- <input
- class="hiddenType"
- id="field.foo.used"
- name="field.foo.used"
- type="hidden"
- value=""
- />
- <input
- class="checkboxType"
- id="field.foo"
- name="field.foo"
- type="checkbox"
- />
-
- When a checkbox is not 'checked', it's value is not
- sent in the request, so we consider it 'False', which
- means that 'required' for a boolean field doesn't make
- much sense in the end.
-
- >>> field = Bool(__name__='foo', title=u'on', required=True)
- >>> request = TestRequest(form={'field.foo.used': u''})
- >>> widget = CheckBoxWidget(field, request)
- >>> widget.hasInput()
- True
- >>> widget.validate()
- >>> widget.getInputValue()
- False
+ """A checkbox widget used to display Bool fields.
+
+ For more detailed documentation, including sample code, see
+ tests/test_checkboxwidget.py.
"""
- propertyNames = BrowserWidget.propertyNames + \
- ['extra', 'default']
-
+
+ implements(IInputWidget)
+
type = 'checkbox'
default = 0
extra = ''
@@ -431,18 +343,18 @@
else:
kw = {}
return "%s %s" % (
- renderElement(self.getValue('tag'),
- type = 'hidden',
- name = self.name+".used",
- id = self.name+".used",
+ renderElement(self.tag,
+ type='hidden',
+ name=self.name+".used",
+ id=self.name+".used",
value=""
),
- renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- cssClass = self.getValue('cssClass'),
- extra = self.getValue('extra'),
+ renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ cssClass=self.cssClass,
+ extra=self.extra,
**kw),
)
@@ -515,9 +427,9 @@
/>
"""
- propertyNames = (BrowserWidget.propertyNames +
- ['displayWidth', 'displayMaxWidth', 'extra', 'default']
- )
+
+ implements(IInputWidget)
+
default = ''
displayWidth = 20
displayMaxWidth = ""
@@ -531,28 +443,28 @@
super(TextWidget, self).__init__(*args)
def __call__(self):
- displayMaxWidth = self.getValue('displayMaxWidth') or 0
+ displayMaxWidth = self.displayMaxWidth or 0
if displayMaxWidth > 0:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- value = self._showData(),
- cssClass = self.getValue('cssClass'),
- style = self.style,
- size = self.getValue('displayWidth'),
- maxlength = displayMaxWidth,
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ value=self._showData(),
+ cssClass=self.cssClass,
+ style=self.style,
+ size=self.displayWidth,
+ maxlength=displayMaxWidth,
+ extra=self.extra)
else:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- value = self._showData(),
- cssClass = self.getValue('cssClass'),
- style = self.style,
- size = self.getValue('displayWidth'),
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ value=self._showData(),
+ cssClass=self.cssClass,
+ style=self.style,
+ size=self.displayWidth,
+ extra=self.extra)
class Bytes(BrowserWidget):
@@ -565,6 +477,7 @@
raise ConversionError("Invalid textual data", v)
return value
+
class BytesWidget(Bytes, TextWidget):
"""Bytes widget.
@@ -580,11 +493,11 @@
True
>>> widget.getInputValue()
'Bob'
- """
+ """
class ASCII(Bytes):
- """ ASCII
- """
+ """ASCII"""
+
class ASCIIWidget(BytesWidget):
"""ASCII widget.
@@ -593,6 +506,7 @@
"""
class IntWidget(TextWidget):
+
displayWidth = 10
def _convert(self, value):
@@ -603,8 +517,11 @@
return int(value)
except ValueError, v:
raise ConversionError("Invalid integer data", v)
+
class FloatWidget(TextWidget):
+
+ implements(IInputWidget)
displayWidth = 10
def _convert(self, value):
@@ -615,9 +532,11 @@
return float(value)
except ValueError, v:
raise ConversionError("Invalid floating point data", v)
+
class DatetimeWidget(TextWidget):
"""Datetime entry widget."""
+
displayWidth = 20
def _convert(self, value):
@@ -628,10 +547,12 @@
return parseDatetimetz(value)
except (DateTimeError, ValueError, IndexError), v:
raise ConversionError("Invalid datetime data", v)
+
class DateWidget(TextWidget):
"""Date entry widget.
"""
+
displayWidth = 20
def _convert(self, value):
@@ -642,6 +563,7 @@
return parseDatetimetz(value).date()
except (DateTimeError, ValueError, IndexError), v:
raise ConversionError("Invalid datetime data", v)
+
class TextAreaWidget(BrowserWidget):
"""TextArea widget.
@@ -693,7 +615,8 @@
dude!</textarea>
"""
- propertyNames = BrowserWidget.propertyNames + ['width', 'height', 'extra']
+
+ implements(IInputWidget)
default = ""
width = 60
@@ -715,14 +638,14 @@
def __call__(self):
return renderElement("textarea",
- name = self.name,
- id = self.name,
- cssClass = self.getValue('cssClass'),
- rows = self.getValue('height'),
- cols = self.getValue('width'),
- style = self.style,
- contents = self._showData(),
- extra = self.getValue('extra'))
+ name=self.name,
+ id=self.name,
+ cssClass=self.cssClass,
+ rows=self.height,
+ cols=self.width,
+ style=self.style,
+ contents=self._showData(),
+ extra=self.extra)
class BytesAreaWidget(Bytes, TextAreaWidget):
"""BytesArea widget.
@@ -738,64 +661,66 @@
True
>>> widget.getInputValue()
'Hello\\nworld!'
-
- """
+ """
class PasswordWidget(TextWidget):
"""Password Widget"""
- type='password'
+
+ type = 'password'
def __call__(self):
- displayMaxWidth = self.getValue('displayMaxWidth') or 0
+ displayMaxWidth = self.displayMaxWidth or 0
if displayMaxWidth > 0:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- value = '',
- cssClass = self.getValue('cssClass'),
- style = self.style,
- size = self.getValue('displayWidth'),
- maxlength = displayMaxWidth,
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ value='',
+ cssClass=self.cssClass,
+ style=self.style,
+ size=self.displayWidth,
+ maxlength=displayMaxWidth,
+ extra=self.extra)
else:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- value = '',
- cssClass = self.getValue('cssClass'),
- style = self.style,
- size = self.getValue('displayWidth'),
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ value='',
+ cssClass=self.cssClass,
+ style=self.style,
+ size=self.displayWidth,
+ extra=self.extra)
def hidden(self):
raise NotImplementedError(
'Cannot get a hidden tag for a password field')
+
class FileWidget(TextWidget):
"""File Widget"""
+
type = 'file'
def __call__(self):
- displayMaxWidth = self.getValue('displayMaxWidth') or 0
+ displayMaxWidth = self.displayMaxWidth or 0
if displayMaxWidth > 0:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- cssClass = self.getValue('cssClass'),
- size = self.getValue('displayWidth'),
- maxlength = displayMaxWidth,
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ cssClass=self.cssClass,
+ size=self.displayWidth,
+ maxlength=displayMaxWidth,
+ extra=self.extra)
else:
- return renderElement(self.getValue('tag'),
- type = self.getValue('type'),
- name = self.name,
- id = self.name,
- cssClass = self.getValue('cssClass'),
- size = self.getValue('displayWidth'),
- extra = self.getValue('extra'))
+ return renderElement(self.tag,
+ type=self.type,
+ name=self.name,
+ id=self.name,
+ cssClass=self.cssClass,
+ size=self.displayWidth,
+ extra=self.extra)
def hasInput(self):
file = self.request.form.get(self.name)
@@ -834,13 +759,15 @@
class ItemsWidget(BrowserWidget):
"""A widget that has a number of items in it."""
-
# What the heck is this for?
-
+
+ implements(IInputWidget)
+
class SingleItemsWidget(ItemsWidget):
"""A widget with a number of items that has only a single
selectable item."""
+
default = ""
firstItem = False
@@ -866,7 +793,7 @@
and len(items) > 0):
value = items[0]
- cssClass = self.getValue('cssClass')
+ cssClass = self.cssClass
# FIXME: what if we run into multiple items with same value?
rendered_items = []
@@ -895,20 +822,18 @@
class ListWidget(SingleItemsWidget):
"""List widget."""
- propertyNames = (SingleItemsWidget.propertyNames +
- ['firstItem', 'items', 'size', 'extra']
- )
+
size = 5
def __call__(self):
renderedItems = self.renderItems(self._showData())
return renderElement('select',
- name = self.name,
- id = self.name,
- cssClass = self.getValue('cssClass'),
- size = self.getValue('size'),
- contents = "\n".join(renderedItems),
- extra = self.getValue('extra'))
+ name=self.name,
+ id=self.name,
+ cssClass=self.cssClass,
+ size=self.size,
+ contents="\n".join(renderedItems),
+ extra=self.extra)
def renderItem(self, index, text, value, name, cssClass):
return renderElement('option', contents=text, value=value,
@@ -921,13 +846,12 @@
class RadioWidget(SingleItemsWidget):
"""Radio buttons widget."""
- propertyNames = SingleItemsWidget.propertyNames +\
- ['firstItem', 'orientation']
+
orientation = "vertical"
def __call__(self):
rendered_items = self.renderItems(self._showData())
- orientation = self.getValue('orientation')
+ orientation = self.orientation
if orientation == 'horizontal':
return " ".join(rendered_items)
else:
@@ -970,11 +894,12 @@
def row(self):
return ('<div class="%s"><label for="%s">%s</label></div>'
'<div class="field" id="%s">%s</div>' % (
- self.labelClass(), self.name, self.label(), self.name, self())
- )
+ self.labelClass(), self.name, self.label(), self.name, self()))
+
class MultiItemsWidget(ItemsWidget):
"""A widget with a number of items that has multiple selectable items."""
+
default = []
def _convert(self, value):
@@ -992,7 +917,7 @@
value = [value]
name = self.name
items = self.context.allowed_values
- cssClass = self.getValue('cssClass')
+ cssClass = self.cssClass
rendered_items = []
count = 0
for item in items:
@@ -1023,7 +948,7 @@
class MultiListWidget(MultiItemsWidget):
"""List widget with multiple select."""
- propertyNames = MultiItemsWidget.propertyNames + ['size', 'extra']
+
size = 5
def __call__(self):
@@ -1032,10 +957,10 @@
name=self.name,
id=self.name,
multiple=None,
- cssClass=self.getValue('cssClass'),
- size=self.getValue('size'),
+ cssClass=self.cssClass,
+ size=self.size,
contents="\n".join(rendered_items),
- extra=self.getValue('extra'))
+ extra=self.extra)
def renderItem(self, index, text, value, name, cssClass):
return renderElement('option', contents=text, value=value)
@@ -1047,12 +972,12 @@
class MultiCheckBoxWidget(MultiItemsWidget):
"""Multiple checkbox widget."""
- propertyNames = MultiItemsWidget.propertyNames + ['orientation']
+
orientation = "vertical"
def __call__(self):
rendered_items = self.renderItems(self._showData())
- orientation = self.getValue('orientation')
+ orientation = self.orientation
if orientation == 'horizontal':
return " ".join(rendered_items)
else:
@@ -1074,14 +999,18 @@
id=name,
value=value,
checked=None) + text
+
class SequenceWidget(BrowserWidget):
- """A sequence of fields.
+ """A widget baseclass for a sequence of fields.
subwidget - Optional CustomWidget used to generate widgets for the
items in the sequence
"""
- _type = tuple
+
+ implements(IInputWidget)
+
+ _type = tuple
_data = () # pre-existing sequence items (from setRenderedValue)
def __init__(self, context, request, subwidget=None):
@@ -1151,7 +1080,8 @@
if self.subwidget:
widget = self.subwidget(field, self.request)
else:
- widget = zapi.getView(field, 'edit', self.request, self.context)
+ widget = zapi.getViewProviding(field, IInputWidget, self.request,
+ context=self.context)
widget.setPrefix('%s.%d.'%(self.name, i))
return widget
@@ -1275,12 +1205,15 @@
return sequence
+
class TupleSequenceWidget(SequenceWidget):
pass
class ListSequenceWidget(SequenceWidget):
+
_type = list
+
class ObjectWidget(BrowserWidget):
"""A widget over an Interface that contains Fields.
@@ -1289,6 +1222,9 @@
*_widget - Optional CustomWidgets used to generate widgets for the
fields in this widget
"""
+
+ implements(IInputWidget)
+
_object = None # the object value (from setRenderedValue & request)
_request_parsed = False
@@ -1314,8 +1250,9 @@
def _setUpEditWidgets(self):
# subwidgets need a new name
- setUpEditWidgets(self, self.context.schema, content=None,
- prefix=self.name, names=self.names, context=self.context)
+ setUpEditWidgets(self, self.context.schema, source=self.context,
+ prefix=self.name, names=self.names,
+ context=self.context)
def __call__(self):
"""Render the widget
@@ -1371,8 +1308,8 @@
# apply sub changes, see if there *are* any changes
# XXX ObjectModifiedEvent here would be nice
- changes = applyWidgetsChanges(self, value, field.schema,
- names=self.names, exclude_readonly=True)
+ changes = applyWidgetsChanges(self, field.schema, target=value,
+ names=self.names)
# if there's changes, then store the new value on the content
if changes:
@@ -1400,6 +1337,7 @@
self._setUpEditWidgets()
for name, widget in self.getSubWidgets():
widget.setRenderedValue(getattr(value, name, None))
+
# XXX Note, some HTML quoting is needed in renderTag and renderElement.
@@ -1463,12 +1401,14 @@
return "%s>%s</%s>" % (renderTag(tag, **kw), contents, tag)
else:
return renderTag(tag, **kw) + " />"
+
def setUp():
import zope.app.tests.placelesssetup
global setUp
setUp = zope.app.tests.placelesssetup.setUp
setUp()
+
def tearDown():
import zope.app.tests.placelesssetup
More information about the Zope3-Checkins
mailing list