[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator - Field.py:1.1.4.3 Form.py:1.1.4.3 IField.py:1.1.4.3 IInstanceFactory.py:1.1.4.3 IWidget.py:1.1.4.3 PropertyFieldAdapter.py:1.1.4.3 Validator.py:1.1.4.2 Widget.py:1.1.4.3 formulator-meta.zcml:1.1.4.2 formulator.zcml:1.1.4.4
Jim Fulton
jim@zope.com
Fri, 7 Jun 2002 10:41:59 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/App/Formulator
Modified Files:
Tag: Zope-3x-branch
Field.py Form.py IField.py IInstanceFactory.py IWidget.py
PropertyFieldAdapter.py Validator.py Widget.py
formulator-meta.zcml formulator.zcml
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals):
- RenameAllowToRequire
- GroupClassRelatedDirectivesInClassDirective
- ViewInterfaceAndSimplification
- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes
- TwoArgumentViewConstructors
- ImplementsInZCML
- SimpleViewCreationInZCML
- RemoveGetView
- ReplaceProtectWithAllow
- ViewMethodsAsViews
- MergeProtectionAndComponentDefinitions
There were also various security fixes resulting of better integration
of security with components.
=== Zope3/lib/python/Zope/App/Formulator/Field.py 1.1.4.2 => 1.1.4.3 ===
self.realize(context)
return self
-
-
- def getContext(self):
- '''See interface IInstanceFactory'''
- return self.context
-
def realize(self, context):
'''See interface IInstanceFactory'''
=== Zope3/lib/python/Zope/App/Formulator/Form.py 1.1.4.2 => 1.1.4.3 ===
"""
-from Zope.Publisher.Browser.AttributePublisher \
- import AttributePublisher
+from Zope.Publisher.Browser.BrowserView import BrowserView
#from IForm import IForm
-from Zope.ComponentArchitecture import getRequestView
+from Zope.ComponentArchitecture import getView
from Zope.App.Formulator.IPropertyFieldAdapter import IPropertyFieldAdapter
from Zope.App.Formulator.Errors import ValidationError
from Zope.ComponentArchitecture import getAdapter
-class Form(AttributePublisher):
+class Form(BrowserView):
"""Form base class.
"""
- __implements__ = AttributePublisher.__implements__#, IForm
-
name = 'Form Name' # for use by javascript
title = 'This is a form'
description = ''
@@ -41,10 +38,10 @@
template = None
- def __init__(self, context):
+ def __init__(self, *args):
"""Initialize form.
"""
- self._context = context
+ super(Form, self).__init__(*args)
self._widgets = []
@@ -59,7 +56,7 @@
values = {}
for widget in self.getFieldViews(REQUEST):
value = widget.getValueFromRequest(REQUEST)
- field = widget.getContext()
+ field = widget.context
try:
values[field.id] = field.getValidator().validate(field, value)
except ValidationError, err:
@@ -67,8 +64,9 @@
if errors == []:
for widget in self.getFieldViews(REQUEST):
- field = widget.getContext()
- getAdapter(field, IPropertyFieldAdapter).setPropertyInContext(values[field.id])
+ field = widget.context
+ getAdapter(field, IPropertyFieldAdapter
+ ).setPropertyInContext(values[field.id])
return self.index(REQUEST, errors=errors)
@@ -76,12 +74,7 @@
def getFieldViews(self, REQUEST):
""" """
views = []
- context = self.getContext()
+ context = self.context
for name in self._fieldViewNames:
- views.append(getRequestView(context, name, REQUEST))
+ views.append(getView(context, name, REQUEST))
return views
-
-
- def getContext(self):
- """ """
- return self._context
=== Zope3/lib/python/Zope/App/Formulator/IField.py 1.1.4.2 => 1.1.4.3 ===
#
##############################################################################
-from Interface import Interface
+from Zope.ComponentArchitecture.IContextDependent import IContextDependent
-
-class IField(Interface):
+class IField(IContextDependent):
"""
"""
@@ -22,10 +21,6 @@
"""Return the validator of this field."""
- def getContext():
- """Return the context object of the field."""
-
-
def hasValue(id):
"""Return true if the field defines such a value.
"""
@@ -56,4 +51,3 @@
def isTALESAvailable():
"""Return true only if TALES is available.
"""
-
=== Zope3/lib/python/Zope/App/Formulator/IInstanceFactory.py 1.1.4.2 => 1.1.4.3 ===
"""
+from Zope.ComponentArchitecture.IContextDependent import IContextDependent
-from Interface import Interface
-
-
-class IInstanceFactory(Interface):
+class IInstanceFactory(IContextDependent):
"""
If the Instance Factory is implemented by an object, then this object
can be used as factory for other components, such as Views.
@@ -39,9 +37,4 @@
Basically calls realize(context). However it must be implemented
too, so that the factory is callable This method has to return the
produced object.
- """
-
- def getContext():
- """
- Get the context of the realized instance.
"""
=== Zope3/lib/python/Zope/App/Formulator/IWidget.py 1.1.4.2 => 1.1.4.3 ===
$Id$
"""
+from Zope.ComponentArchitecture.IContextDependent import IContextDependent
-from Interface import Interface
-
-
-class IWidget(Interface):
+class IWidget(IContextDependent):
"""Generically describes the behavior of a widget.
The widget defines a list of propertyNames, which describes
@@ -31,11 +29,6 @@
def getValue(name):
"""Look up a Widget setting (value) by name."""
-
-
- def getContext():
- """Get the context of the widget, namely the Field."""
-
def render():
"""Render the widget. This will return the representation the
=== Zope3/lib/python/Zope/App/Formulator/PropertyFieldAdapter.py 1.1.4.2 => 1.1.4.3 ===
from Zope.App.Formulator.Errors import ValidationError
-
class PropertyFieldAdapter:
""" """
@@ -33,20 +32,15 @@
def setPropertyInContext(self, value):
""" """
- field = self.getContext()
- method = getattr(field.getContext(),
+ field = self.context
+ method = getattr(field.context,
'set'+field.id[0].capitalize()+field.id[1:], None)
apply(method, (value,))
def getPropertyInContext(self):
""" """
- field = self.getContext()
- method = getattr(field.getContext(),
+ field = self.context
+ method = getattr(field.context,
'get'+field.id[0].capitalize()+field.id[1:], None)
return apply(method, ())
-
-
- def getContext(self):
- """ """
- return self.context
=== Zope3/lib/python/Zope/App/Formulator/Validator.py 1.1.4.1 => 1.1.4.2 ===
self.realize(context)
return self
-
-
- def getContext(self):
- '''See interface IInstanceFactory'''
- return self.context
-
def realize(self, context):
'''See interface IInstanceFactory'''
=== Zope3/lib/python/Zope/App/Formulator/Widget.py 1.1.4.2 => 1.1.4.3 ===
def __init__(self, field):
""" """
- self._field = field
-
+ self.context = field
def getValue(self, name):
""" """
if name in self.propertyNames:
return getattr(self, name, None)
-
-
- def getContext(self):
- """ """
- return self._field
def render(self):
=== Zope3/lib/python/Zope/App/Formulator/formulator-meta.zcml 1.1.4.1 => 1.1.4.2 ===
<directives namespace="http://namespaces.zope.org/formulator">
- <directive name="registerField" attributes="name, field"
+ <directive name="registerField" attributes="name field"
handler="Zope.App.Formulator.metaConfigure.field" />
- <directive name="registerValidator" attributes="name, validator"
+ <directive name="registerValidator" attributes="name validator"
handler="Zope.App.Formulator.metaConfigure.validator" />
</directives>
=== Zope3/lib/python/Zope/App/Formulator/formulator.zcml 1.1.4.3 => 1.1.4.4 ===
for="Zope.App.Formulator.IField." />
-
- <security:protectClass
- class=".Field."
- permission_id="Zope.View"
- interface=".IField." />
-
- <security:protectClass
- class=".Form."
- permission_id="Zope.View"
- names="index, action, getFieldViews, getContext" />
-
+ <content class=".Field.">
+ <security:require
+ permission="Zope.View"
+ interface=".IField." />
+ </content>
+
+ <content class=".Form.">
+ <security:require
+ permission="Zope.View"
+ attributes="index action getFieldViews getContext" />
+ </content>
</zopeConfigure>