[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Widgets/Browser - BrowserWidget.py:1.1.2.2.2.1 FileWidget.py:1.1.2.2.2.1
Stephan Richter
srichter@cbu.edu
Fri, 1 Mar 2002 01:56:45 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser
In directory cvs.zope.org:/tmp/cvs-serv13304/Widgets/Browser
Modified Files:
Tag: srichter-OFS_Formulator-branch
BrowserWidget.py FileWidget.py
Log Message:
Checkin for new Formualtor layout. Much has changed since the initial
checkin:
- Both classes and instances of fields can be used as factory when creating
views.
- Field: This object is simply a meta-data container for a piece of
information; for content objects these are usually its properties.
Note: It is planned to have a CompositeField for more complex inputs,
such as dates.
- FieldViews are virtual objects; they are basically realized Widgets (or
Widgets in context)
- Validator: An object that validates data. Note that this object is
totally input/protocol-agnostic. Therefore the old concept of some of the
Zope 2 Formulator validators is not applicable anymore.
- Widget: This is a generic component that is concerned about the
presentation of a field in a particular protocol. A difference to the
Zope 2 Formulator version is that the widget is also responsible of
converting possible input-specific representation to a standard one. This
is not yet fully implemented though.
- Form: A protocol-specific object that is concerned with the overall
representation of a form and its action.
- There is a Validator and Field Registry, since Fields and Validators can
also be used independent of Formulator's goals. Fields should really
become the standard way to provide meta-data for properties.
Todo: (too much)
- I need to write a proper metaConfigure.py.
- Make a CompositeField.
- Create XUL Widgets.
- Clean up files.
- Finishing the conversion to the Zope 3 Formulator model.
=== Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/BrowserWidget.py 1.1.2.2 => 1.1.2.2.2.1 ===
from IBrowserWidget import IBrowserWidget
-from Zope.App.Formulator.Widgets.Widget import Widget
+from Zope.App.Formulator.Widget import Widget
+from Zope.App.Formulator.IPropertyFieldAdapter import IPropertyFieldAdapter
+from Zope.ComponentArchitecture import getAdapter
class BrowserWidget(Widget):
@@ -50,7 +52,7 @@
if REQUEST and REQUEST.has_key('field_'+field.id):
return REQUEST['field_'+field.id]
else:
- return self.getContext().getPropertyInContext()
+ return getAdapter(field, IPropertyFieldAdapter).getPropertyInContext()
def render(self, REQUEST=None):
=== Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/FileWidget.py 1.1.2.2 => 1.1.2.2.2.1 ===
from TextWidget import TextWidget
+from Zope.App.Formulator.Widgets.Browser.BrowserWidget import renderElement
class FileWidget(TextWidget):
@@ -23,3 +24,24 @@
__implements__ = TextWidget.__implements__
type = 'file'
+
+
+ def render(self, REQUEST=None):
+ """Renders this widget as HTML using property values in field.
+ """
+ displayMaxWidth = self.getValue('displayMaxWidth') or 0
+ if displayMaxWidth > 0:
+ return renderElement(self.getValue('tag'),
+ type = self.getValue('type'),
+ name = self.getContext().id,
+ cssClass = self.getValue('cssClass'),
+ size = self.getValue('displayWidth'),
+ maxlength = displayMaxWidth,
+ extra = self.getValue('extra'))
+ else:
+ return renderElement(self.getValue('tag'),
+ type = self.getValue('type'),
+ name = self.getContext().id,
+ cssClass = self.getValue('cssClass'),
+ size = self.getValue('displayWidth'),
+ extra = self.getValue('extra'))