[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator - CompositeWidget.py:1.1.4.1.4.1 Field.py:1.1.4.1.4.1 FieldRegistry.py:1.1.4.1.4.1 Form.py:1.1.4.1.4.1 ICompositeWidget.py:1.1.4.1.4.1 IField.py:1.1.4.1.4.1 IInstanceFactory.py:1.1.4.1.4.1 IPropertyFieldAdapter.py:1.1.4.1.4.1 ISimpleRegistry.py:1.1.4.1.4.1 IValidator.py:1.1.4.1.4.1 IWidget.py:1.1.4.1.4.1 PropertyFieldAdapter.py:1.1.4.1.4.1 SimpleRegistry.py:1.1.4.1.4.1 ValidatorRegistry.py:1.1.4.1.4.1 Widget.py:1.1.4.1.4.1 __init__.py:1.1.4.1.4.1
Martijn Faassen
m.faassen@vet.uu.nl
Wed, 10 Apr 2002 12:11:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator
In directory cvs.zope.org:/tmp/cvs-serv6926/Zope/App/Formulator
Modified Files:
Tag: Zope3-property-branch
CompositeWidget.py Field.py FieldRegistry.py Form.py
ICompositeWidget.py IField.py IInstanceFactory.py
IPropertyFieldAdapter.py ISimpleRegistry.py IValidator.py
IWidget.py PropertyFieldAdapter.py SimpleRegistry.py
ValidatorRegistry.py Widget.py __init__.py
Log Message:
Added experimental schema stuff. Incidentally removed windows newlines from
Formulator
=== Zope3/lib/python/Zope/App/Formulator/CompositeWidget.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from ICompositeWidget import ICompositeWidget
-from Widget import Widget
-
-
-class CompositeWidget(Widget):
- """ """
-
- __implements__ = Widget.__implements__, ICompositeWidget
-
- # Page template that is ised to lay out sub-widgets
- template = None
-
- # List of Sub-Widgets
- widgets = None
-
-
- def render(self, REQUEST):
- """ """
- return apply(self.template, (REQUEST,))
-
-
- def render_hidden(self, REQUEST):
- """ """
- return apply(self.template, (REQUEST,), {'hidden': 1})
-
-
- def setWidget(self, name, widget):
- """ """
- if self.widgets is None:
- self.widgets = {}
-
- self.widgets[name] = widget
-
-
- def getWidget(self, name, _default=None):
- """ """
- if name in self.widgets.keys():
- return self.widgets[name]
- else:
- return _default
-
-
- def getWidgets(self):
- """ """
- return self.widgets
+"""
+
+$Id$
+"""
+
+from ICompositeWidget import ICompositeWidget
+from Widget import Widget
+
+
+class CompositeWidget(Widget):
+ """ """
+
+ __implements__ = Widget.__implements__, ICompositeWidget
+
+ # Page template that is ised to lay out sub-widgets
+ template = None
+
+ # List of Sub-Widgets
+ widgets = None
+
+
+ def render(self, REQUEST):
+ """ """
+ return apply(self.template, (REQUEST,))
+
+
+ def render_hidden(self, REQUEST):
+ """ """
+ return apply(self.template, (REQUEST,), {'hidden': 1})
+
+
+ def setWidget(self, name, widget):
+ """ """
+ if self.widgets is None:
+ self.widgets = {}
+
+ self.widgets[name] = widget
+
+
+ def getWidget(self, name, _default=None):
+ """ """
+ if name in self.widgets.keys():
+ return self.widgets[name]
+ else:
+ return _default
+
+
+ def getWidgets(self):
+ """ """
+ return self.widgets
=== Zope3/lib/python/Zope/App/Formulator/Field.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Persistence import Persistent
-from IField import IField
-from Zope.App.Formulator.Errors import ValidationError
-from IInstanceFactory import IInstanceFactory
-
-
-class Field(Persistent):
- """Base class of all fields.
- A field is an object consisting of a widget and a validator.
- """
-
- __implements__ = (
- IField,
- IInstanceFactory
- )
-
- propertyNames = ('id', 'validator', 'default', 'title', 'description',
- 'required')
-
- id = None
- validator = None
- default = None
- title = 'Field Title'
- description = 'Field Description'
- required = 0
-
-
- def __init__(self, context=None, **kw):
- self.realize(context)
-
- for name in self.propertyNames:
- if name in kw.keys():
- setattr(self, name, kw[name])
-
-
- def getErrorMessage(self, name):
- try:
- return self.validator.getMessage(name)
- except KeyError:
- if name in self.validator.messageNames:
- return getattr(self.validator, name)
- else:
- return "Unknown error: %s" % name
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.Formulator.IField.
-
- def getValidator(self):
- '''See interface IField'''
- return self.validator
-
-
- def hasValue(self, id):
- '''See interface IField'''
- if id in self.propertyNames:
- return 1
- else:
- return 0
-
-
- def getValue(self, id, _default=None):
- '''See interface IField'''
- if id in self.propertyNames:
- return getattr(self, id)
- else:
- return _default
-
-
- def isRequired(self):
- '''See interface IField'''
- return hasattr(self, 'required') and getattr(self, 'required')
-
-
- def getErrorNames(self):
- '''See interface IField'''
- return self.validator.messageNames
-
-
- def getTales(self, id):
- '''See interface IField'''
- raise NotImplemented
-
-
- def isTALESAvailable(self):
- '''See interface IField'''
- raise NotImplemented
-
-
- def getOverride(self, id):
- '''See interface IField'''
- raise NotImplemented
-
- #
- ############################################################
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.Formulator.IInstanceFactory.
-
- def __call__(self, context):
- '''See interface IInstanceFactory'''
- self.realize(context)
- return self
-
-
- def getContext(self):
- '''See interface IInstanceFactory'''
- return self.context
-
-
- def realize(self, context):
- '''See interface IInstanceFactory'''
- self.context = context
- #
- ############################################################
+"""
+
+$Id$
+"""
+
+from Persistence import Persistent
+from IField import IField
+from Zope.App.Formulator.Errors import ValidationError
+from IInstanceFactory import IInstanceFactory
+
+
+class Field(Persistent):
+ """Base class of all fields.
+ A field is an object consisting of a widget and a validator.
+ """
+
+ __implements__ = (
+ IField,
+ IInstanceFactory
+ )
+
+ propertyNames = ('id', 'validator', 'default', 'title', 'description',
+ 'required')
+
+ id = None
+ validator = None
+ default = None
+ title = 'Field Title'
+ description = 'Field Description'
+ required = 0
+
+
+ def __init__(self, context=None, **kw):
+ self.realize(context)
+
+ for name in self.propertyNames:
+ if name in kw.keys():
+ setattr(self, name, kw[name])
+
+
+ def getErrorMessage(self, name):
+ try:
+ return self.validator.getMessage(name)
+ except KeyError:
+ if name in self.validator.messageNames:
+ return getattr(self.validator, name)
+ else:
+ return "Unknown error: %s" % name
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.Formulator.IField.
+
+ def getValidator(self):
+ '''See interface IField'''
+ return self.validator
+
+
+ def hasValue(self, id):
+ '''See interface IField'''
+ if id in self.propertyNames:
+ return 1
+ else:
+ return 0
+
+
+ def getValue(self, id, _default=None):
+ '''See interface IField'''
+ if id in self.propertyNames:
+ return getattr(self, id)
+ else:
+ return _default
+
+
+ def isRequired(self):
+ '''See interface IField'''
+ return hasattr(self, 'required') and getattr(self, 'required')
+
+
+ def getErrorNames(self):
+ '''See interface IField'''
+ return self.validator.messageNames
+
+
+ def getTales(self, id):
+ '''See interface IField'''
+ raise NotImplemented
+
+
+ def isTALESAvailable(self):
+ '''See interface IField'''
+ raise NotImplemented
+
+
+ def getOverride(self, id):
+ '''See interface IField'''
+ raise NotImplemented
+
+ #
+ ############################################################
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.Formulator.IInstanceFactory.
+
+ def __call__(self, context):
+ '''See interface IInstanceFactory'''
+ self.realize(context)
+ return self
+
+
+ def getContext(self):
+ '''See interface IInstanceFactory'''
+ return self.context
+
+
+ def realize(self, context):
+ '''See interface IInstanceFactory'''
+ self.context = context
+ #
+ ############################################################
=== Zope3/lib/python/Zope/App/Formulator/FieldRegistry.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-
-from SimpleRegistry import SimpleRegistry
-from ISimpleRegistry import ISimpleRegistry
-from IField import IField
-
-class IFieldRegistry(ISimpleRegistry):
- """
- The Field Registry manages a list of all the fields available in Zope. A
- registry is useful at this point, since fields can be initialized and
- registered by many places.
-
- Note that it does not matter whether we have classes or instances as
- fields. If the fields are instances, they must implement
- IInstanceFactory.
- """
- pass
-
-
-class FieldRegistry(SimpleRegistry):
- """ """
-
- __implements__ = (IFieldRegistry,)
-
-
-
-FieldRegistry = FieldRegistry(IField)
-registerField = FieldRegistry.register
-getField = FieldRegistry.get
+"""
+
+$Id$
+"""
+
+
+from SimpleRegistry import SimpleRegistry
+from ISimpleRegistry import ISimpleRegistry
+from IField import IField
+
+class IFieldRegistry(ISimpleRegistry):
+ """
+ The Field Registry manages a list of all the fields available in Zope. A
+ registry is useful at this point, since fields can be initialized and
+ registered by many places.
+
+ Note that it does not matter whether we have classes or instances as
+ fields. If the fields are instances, they must implement
+ IInstanceFactory.
+ """
+ pass
+
+
+class FieldRegistry(SimpleRegistry):
+ """ """
+
+ __implements__ = (IFieldRegistry,)
+
+
+
+FieldRegistry = FieldRegistry(IField)
+registerField = FieldRegistry.register
+getField = FieldRegistry.get
=== Zope3/lib/python/Zope/App/Formulator/Form.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.Publisher.Browser.AttributePublisher \
- import AttributePublisher
-#from IForm import IForm
-from Zope.ComponentArchitecture import getRequestView
-from Zope.App.Formulator.IPropertyFieldAdapter import IPropertyFieldAdapter
-from Zope.App.Formulator.Errors import ValidationError
-from Zope.ComponentArchitecture import getAdapter
-
-
-class Form(AttributePublisher):
- """Form base class.
- """
-
- __implements__ = AttributePublisher.__implements__#, IForm
-
- name = 'Form Name' # for use by javascript
- title = 'This is a form'
- description = ''
- method = 'post'
- enctype = ''
-
- _fieldViewNames = []
- template = None
-
-
- def __init__(self, context):
- """Initialize form.
- """
- self._context = context
- self._widgets = []
-
-
- def index(self, REQUEST, **kw):
- """ """
- return apply(self.template, (REQUEST,), kw)
-
-
- def action(self, REQUEST):
- """ """
- errors = []
- values = {}
- for widget in self.getFieldViews(REQUEST):
- value = widget.getValueFromRequest(REQUEST)
- field = widget.getContext()
- try:
- values[field.id] = field.getValidator().validate(field, value)
- except ValidationError, err:
- errors.append(err)
-
- if errors == []:
- for widget in self.getFieldViews(REQUEST):
- field = widget.getContext()
- getAdapter(field, IPropertyFieldAdapter).setPropertyInContext(values[field.id])
-
- return self.index(REQUEST, errors=errors)
-
-
- def getFieldViews(self, REQUEST):
- """ """
- views = []
- context = self.getContext()
- for name in self._fieldViewNames:
- views.append(getRequestView(context, name, REQUEST))
- return views
-
-
- def getContext(self):
- """ """
- return self._context
+"""
+
+$Id$
+"""
+
+from Zope.Publisher.Browser.AttributePublisher \
+ import AttributePublisher
+#from IForm import IForm
+from Zope.ComponentArchitecture import getRequestView
+from Zope.App.Formulator.IPropertyFieldAdapter import IPropertyFieldAdapter
+from Zope.App.Formulator.Errors import ValidationError
+from Zope.ComponentArchitecture import getAdapter
+
+
+class Form(AttributePublisher):
+ """Form base class.
+ """
+
+ __implements__ = AttributePublisher.__implements__#, IForm
+
+ name = 'Form Name' # for use by javascript
+ title = 'This is a form'
+ description = ''
+ method = 'post'
+ enctype = ''
+
+ _fieldViewNames = []
+ template = None
+
+
+ def __init__(self, context):
+ """Initialize form.
+ """
+ self._context = context
+ self._widgets = []
+
+
+ def index(self, REQUEST, **kw):
+ """ """
+ return apply(self.template, (REQUEST,), kw)
+
+
+ def action(self, REQUEST):
+ """ """
+ errors = []
+ values = {}
+ for widget in self.getFieldViews(REQUEST):
+ value = widget.getValueFromRequest(REQUEST)
+ field = widget.getContext()
+ try:
+ values[field.id] = field.getValidator().validate(field, value)
+ except ValidationError, err:
+ errors.append(err)
+
+ if errors == []:
+ for widget in self.getFieldViews(REQUEST):
+ field = widget.getContext()
+ getAdapter(field, IPropertyFieldAdapter).setPropertyInContext(values[field.id])
+
+ return self.index(REQUEST, errors=errors)
+
+
+ def getFieldViews(self, REQUEST):
+ """ """
+ views = []
+ context = self.getContext()
+ for name in self._fieldViewNames:
+ views.append(getRequestView(context, name, REQUEST))
+ return views
+
+
+ def getContext(self):
+ """ """
+ return self._context
=== Zope3/lib/python/Zope/App/Formulator/ICompositeWidget.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from IWidget import IWidget
-
-
-class ICompositeWidget(IWidget):
- """ """
+"""
+
+$Id$
+"""
+
+from IWidget import IWidget
+
+
+class ICompositeWidget(IWidget):
+ """ """
=== Zope3/lib/python/Zope/App/Formulator/IField.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-from Interface import Interface
-
-
-class IField(Interface):
- """
- """
-
- def getValidator():
- """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.
- """
-
-
- def getValue(id):
- """Get value for id."""
-
-
- def getOverride(id):
- """Get override method for id (not wrapped)."""
-
-
- def getTales(id):
- """Get tales expression method for id."""
-
-
- def isRequired():
- """Check whether this field is required (utility function)
- """
-
-
- def getErrorNames():
- """Get error messages.
- """
-
-
- def isTALESAvailable():
- """Return true only if TALES is available.
- """
-
+from Interface import Interface
+
+
+class IField(Interface):
+ """
+ """
+
+ def getValidator():
+ """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.
+ """
+
+
+ def getValue(id):
+ """Get value for id."""
+
+
+ def getOverride(id):
+ """Get override method for id (not wrapped)."""
+
+
+ def getTales(id):
+ """Get tales expression method for id."""
+
+
+ def isRequired():
+ """Check whether this field is required (utility function)
+ """
+
+
+ def getErrorNames():
+ """Get error messages.
+ """
+
+
+ def isTALESAvailable():
+ """Return true only if TALES is available.
+ """
+
=== Zope3/lib/python/Zope/App/Formulator/IInstanceFactory.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-
-from Interface import Interface
-
-
-class IInstanceFactory(Interface):
- """
- If the Instance Factory is implemented by an object, then this object
- can be used as factory for other components, such as Views.
- """
-
- def realize(context):
- """
- Relaizes an instance in a particular context/evironment. This
- method basically replaces __init__(context) for class-based
- factories.
- """
-
-
- def __call__(context):
- """
- 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.
- """
+"""
+
+$Id$
+"""
+
+
+from Interface import Interface
+
+
+class IInstanceFactory(Interface):
+ """
+ If the Instance Factory is implemented by an object, then this object
+ can be used as factory for other components, such as Views.
+ """
+
+ def realize(context):
+ """
+ Relaizes an instance in a particular context/evironment. This
+ method basically replaces __init__(context) for class-based
+ factories.
+ """
+
+
+ def __call__(context):
+ """
+ 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/IPropertyFieldAdapter.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-
-from Interface import Interface
-
-
-class IPropertyFieldAdapter(Interface):
- """
- """
-
- def setPropertyInContext(value):
- """ """
-
-
- def getPropertyInContext():
- """ """
+"""
+
+$Id$
+"""
+
+
+from Interface import Interface
+
+
+class IPropertyFieldAdapter(Interface):
+ """
+ """
+
+ def setPropertyInContext(value):
+ """ """
+
+
+ def getPropertyInContext():
+ """ """
=== Zope3/lib/python/Zope/App/Formulator/ISimpleRegistry.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Interface import Interface
-
-
-class ISimpleRegistry(Interface):
- """
- The Simple Registry is minimal collection of registered objects. This can
- be useful, when it is expected that objects of a particular type are added
- from many places in the system (through 3rd party products for example).
-
- A good example for this are the Formulator fields. While the basic types
- are defined inside the Formulator tree, other parties might add many
- more later on in their products, so it is useful to provide a registry via
- ZCML that allows to collect these items.
-
- There is only one constraint on the objects. They all must implement a
- particular interface specified during the initialization of the registry.
-
- Note that it does not matter whether we have classes or instances as
- objects. If the objects are instances, they must implement simply
- IInstanceFactory.
- """
-
- def register(name, object):
- """
- Registers the object under the id name.
- """
-
-
- def getF(name):
- """
- This returns the object with id name.
- """
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+
+class ISimpleRegistry(Interface):
+ """
+ The Simple Registry is minimal collection of registered objects. This can
+ be useful, when it is expected that objects of a particular type are added
+ from many places in the system (through 3rd party products for example).
+
+ A good example for this are the Formulator fields. While the basic types
+ are defined inside the Formulator tree, other parties might add many
+ more later on in their products, so it is useful to provide a registry via
+ ZCML that allows to collect these items.
+
+ There is only one constraint on the objects. They all must implement a
+ particular interface specified during the initialization of the registry.
+
+ Note that it does not matter whether we have classes or instances as
+ objects. If the objects are instances, they must implement simply
+ IInstanceFactory.
+ """
+
+ def register(name, object):
+ """
+ Registers the object under the id name.
+ """
+
+
+ def getF(name):
+ """
+ This returns the object with id name.
+ """
=== Zope3/lib/python/Zope/App/Formulator/IValidator.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Interface import Interface
-
-
-class IValidator(Interface):
- """A field validator provides the functionality to verify the
- input data on the server.
-
- This class will be initialized as a singleton.
- """
-
- def validate(field, value):
- """Validate the value, knowing the field.
- """
-
- def raiseError(errorKey, field):
- """Raises the error, if the validation fails.
- """
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+
+class IValidator(Interface):
+ """A field validator provides the functionality to verify the
+ input data on the server.
+
+ This class will be initialized as a singleton.
+ """
+
+ def validate(field, value):
+ """Validate the value, knowing the field.
+ """
+
+ def raiseError(errorKey, field):
+ """Raises the error, if the validation fails.
+ """
=== Zope3/lib/python/Zope/App/Formulator/IWidget.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Interface import Interface
-
-
-class IWidget(Interface):
- """Generically describes the behavior of a widget.
-
- The widget defines a list of propertyNames, which describes
- what properties of the widget are available to use for
- constructing the widget render output.
-
- Note that this level must be still presentation independent.
- """
-
- 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
- client will understand."""
-
- def render_hidden():
- """Render the widget as a hidden field. This will return the
- representation the client will understand."""
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+
+class IWidget(Interface):
+ """Generically describes the behavior of a widget.
+
+ The widget defines a list of propertyNames, which describes
+ what properties of the widget are available to use for
+ constructing the widget render output.
+
+ Note that this level must be still presentation independent.
+ """
+
+ 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
+ client will understand."""
+
+ def render_hidden():
+ """Render the widget as a hidden field. This will return the
+ representation the client will understand."""
=== Zope3/lib/python/Zope/App/Formulator/PropertyFieldAdapter.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from IPropertyFieldAdapter import IPropertyFieldAdapter
-from Zope.App.Formulator.Errors import ValidationError
-
-
-class PropertyFieldAdapter:
- """ """
-
- __implements__ = IPropertyFieldAdapter
-
-
- def __init__(self, context):
- """ """
- self.context = context
-
-
- def setPropertyInContext(self, value):
- """ """
- field = self.getContext()
- method = getattr(field.getContext(),
- 'set'+field.id[0].capitalize()+field.id[1:], None)
- apply(method, (value,))
-
-
- def getPropertyInContext(self):
- """ """
- field = self.getContext()
- method = getattr(field.getContext(),
- 'get'+field.id[0].capitalize()+field.id[1:], None)
- return apply(method, ())
-
-
- def getContext(self):
- """ """
- return self.context
+"""
+
+$Id$
+"""
+
+from IPropertyFieldAdapter import IPropertyFieldAdapter
+from Zope.App.Formulator.Errors import ValidationError
+
+
+class PropertyFieldAdapter:
+ """ """
+
+ __implements__ = IPropertyFieldAdapter
+
+
+ def __init__(self, context):
+ """ """
+ self.context = context
+
+
+ def setPropertyInContext(self, value):
+ """ """
+ field = self.getContext()
+ method = getattr(field.getContext(),
+ 'set'+field.id[0].capitalize()+field.id[1:], None)
+ apply(method, (value,))
+
+
+ def getPropertyInContext(self):
+ """ """
+ field = self.getContext()
+ method = getattr(field.getContext(),
+ 'get'+field.id[0].capitalize()+field.id[1:], None)
+ return apply(method, ())
+
+
+ def getContext(self):
+ """ """
+ return self.context
=== Zope3/lib/python/Zope/App/Formulator/SimpleRegistry.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.Configuration.name import resolve
-from ISimpleRegistry import ISimpleRegistry
-from types import StringTypes, ListType, TupleType
-ListTypes = (TupleType, ListType)
-
-
-class ZopeDuplicateRegistryEntryError(Exception):
- """
- This Error is raised when the user tries to add an object with
- a name that already exists in the registry. Therefore,
- overwriting is not allowed.
- """
-
- def __init__(self, name):
- """Initializes Error"""
- self.name = name
-
-
- def __str__(self):
- """Returns string representation of Error"""
- return "The name '%s' is already defined in this registry." \
- %self.name
-
-
-
-class ZopeIllegalInterfaceError(Exception):
- """
- This Error is thrown, when the passed object does not implement
- the specified interface.
- """
-
- def __init__(self, name, interface):
- """Initalize Error"""
- self.name = name
- self.interface = interface
-
-
- def __str__(self):
- """Returns string representation of Error"""
- return ( "The object with name " + self.name + " does not implement "
- "the interface " + self.interface.__name__ + "." )
-
-
-
-class SimpleRegistry:
- """ """
-
- __implements__ = (ISimpleRegistry,)
-
-
- def __init__(self, interface):
- """Initialize registry"""
- self.objects = {}
- self.interface = interface
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.Formulator.ISimpleRegistry
-
- def register(self, name, object):
- '''See interface ISimpleRegistry'''
-
- if name in self.objects.keys():
- raise ZopeDuplicateRegistryEntryError(name)
-
- # XXX Find the right Interface tools to do that; unfortunately,
- # I have not found them
- # Check whether the object implements the right interface.
- # Note, that we do *not* know whether the object is an instance
- # or a class (or worse a Persistent class)
- if hasattr(object, '__implements__') and \
- ( self.interface == object.__implements__ or \
- ( type(object.__implements__) in ListTypes and
- self.interface in object.__implements__ ) ):
- self.objects[name] = object
-
- else:
- raise ZopeIllegalInterfaceError(name, self.interface)
-
- return []
-
-
- def get(self, name):
- '''See interface ISimpleRegistry'''
- if name in self.objects.keys():
- return self.objects[name]
- else:
- return None
-
- #
- ############################################################
+"""
+
+$Id$
+"""
+
+from Zope.Configuration.name import resolve
+from ISimpleRegistry import ISimpleRegistry
+from types import StringTypes, ListType, TupleType
+ListTypes = (TupleType, ListType)
+
+
+class ZopeDuplicateRegistryEntryError(Exception):
+ """
+ This Error is raised when the user tries to add an object with
+ a name that already exists in the registry. Therefore,
+ overwriting is not allowed.
+ """
+
+ def __init__(self, name):
+ """Initializes Error"""
+ self.name = name
+
+
+ def __str__(self):
+ """Returns string representation of Error"""
+ return "The name '%s' is already defined in this registry." \
+ %self.name
+
+
+
+class ZopeIllegalInterfaceError(Exception):
+ """
+ This Error is thrown, when the passed object does not implement
+ the specified interface.
+ """
+
+ def __init__(self, name, interface):
+ """Initalize Error"""
+ self.name = name
+ self.interface = interface
+
+
+ def __str__(self):
+ """Returns string representation of Error"""
+ return ( "The object with name " + self.name + " does not implement "
+ "the interface " + self.interface.__name__ + "." )
+
+
+
+class SimpleRegistry:
+ """ """
+
+ __implements__ = (ISimpleRegistry,)
+
+
+ def __init__(self, interface):
+ """Initialize registry"""
+ self.objects = {}
+ self.interface = interface
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.Formulator.ISimpleRegistry
+
+ def register(self, name, object):
+ '''See interface ISimpleRegistry'''
+
+ if name in self.objects.keys():
+ raise ZopeDuplicateRegistryEntryError(name)
+
+ # XXX Find the right Interface tools to do that; unfortunately,
+ # I have not found them
+ # Check whether the object implements the right interface.
+ # Note, that we do *not* know whether the object is an instance
+ # or a class (or worse a Persistent class)
+ if hasattr(object, '__implements__') and \
+ ( self.interface == object.__implements__ or \
+ ( type(object.__implements__) in ListTypes and
+ self.interface in object.__implements__ ) ):
+ self.objects[name] = object
+
+ else:
+ raise ZopeIllegalInterfaceError(name, self.interface)
+
+ return []
+
+
+ def get(self, name):
+ '''See interface ISimpleRegistry'''
+ if name in self.objects.keys():
+ return self.objects[name]
+ else:
+ return None
+
+ #
+ ############################################################
=== Zope3/lib/python/Zope/App/Formulator/ValidatorRegistry.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-
-from SimpleRegistry import SimpleRegistry
-from ISimpleRegistry import ISimpleRegistry
-from IValidator import IValidator
-
-class IValidatorRegistry(ISimpleRegistry):
- """
-
- Note that it does not matter whether we have classes or instances as
- validators. If the validaotrs are instances, they must implement
- IInstanceFactory.
- """
- pass
-
-
-class ValidatorRegistry(SimpleRegistry):
- """ """
-
- __implements__ = (IValidatorRegistry,)
-
-
-
-ValidatorRegistry = ValidatorRegistry(IValidator)
-registerValidator = ValidatorRegistry.register
-getValidator = ValidatorRegistry.get
+"""
+
+$Id$
+"""
+
+
+from SimpleRegistry import SimpleRegistry
+from ISimpleRegistry import ISimpleRegistry
+from IValidator import IValidator
+
+class IValidatorRegistry(ISimpleRegistry):
+ """
+
+ Note that it does not matter whether we have classes or instances as
+ validators. If the validaotrs are instances, they must implement
+ IInstanceFactory.
+ """
+ pass
+
+
+class ValidatorRegistry(SimpleRegistry):
+ """ """
+
+ __implements__ = (IValidatorRegistry,)
+
+
+
+ValidatorRegistry = ValidatorRegistry(IValidator)
+registerValidator = ValidatorRegistry.register
+getValidator = ValidatorRegistry.get
=== Zope3/lib/python/Zope/App/Formulator/Widget.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-from IWidget import IWidget
-
-
-class Widget(object):
- """I do not know what will be in this class, but it provides
- an extra layer.
- """
-
- __implements__ = IWidget
-
- propertyNames = []
-
-
- def __init__(self, field):
- """ """
- self._field = field
-
-
- def getValue(self, name):
- """ """
- if name in self.propertyNames:
- return getattr(self, name, None)
-
-
- def getContext(self):
- """ """
- return self._field
-
-
- def render(self):
- """ """
- raise NotImplemented
-
-
- def render_hidden(self):
- """ """
- raise NotImplemented
+"""
+
+$Id$
+"""
+from IWidget import IWidget
+
+
+class Widget(object):
+ """I do not know what will be in this class, but it provides
+ an extra layer.
+ """
+
+ __implements__ = IWidget
+
+ propertyNames = []
+
+
+ def __init__(self, field):
+ """ """
+ self._field = field
+
+
+ def getValue(self, name):
+ """ """
+ if name in self.propertyNames:
+ return getattr(self, name, None)
+
+
+ def getContext(self):
+ """ """
+ return self._field
+
+
+ def render(self):
+ """ """
+ raise NotImplemented
+
+
+ def render_hidden(self):
+ """ """
+ raise NotImplemented
=== Zope3/lib/python/Zope/App/Formulator/__init__.py 1.1.4.1 => 1.1.4.1.4.1 ===
#
##############################################################################
-"""
-
-$Id$
-"""
-
-from FieldRegistry import registerField, getField
-from ValidatorRegistry import registerValidator, getValidator
+"""
+
+$Id$
+"""
+
+from FieldRegistry import registerField, getField
+from ValidatorRegistry import registerValidator, getValidator