Hi all,

I want to propose two little changes to SourceInputWidget (zope.app.form.browser.source).

1. Context in Source

At this moment, it is not possible to use the context in the source,
because they do not get the context from the SourceInputWidget. For a
typical source, I need the context, so I can lookup terms that are
valid only in a specific context. I propose the following change, because the context is in the field which is passed to the constructor:

    def __init__(self, field, source, request):
        super(SourceInputWidget, self).__init__(field, request)
        self.source = source

        # changed in order to let the source know the fieldcontext
        self.source.field = field
        # end of changes


2. use _toFieldValue en _toFormValue in SourceInputWidget.

_toFieldValue and _toFormValue are powerfull functions in widgets to use a) a
standard widget and b) override the widget on specific parts. I need a
SourceInputWidget which uses an instance of a class as value. Because
the SourceInputWidget only works with strings, I had to convert the
string to/from the class instance. The _toFieldValue and _toFormValue
are very usefull for that purpose, so I propose the following change:

    def _value(self):
        if self._renderedValueSet():
            value = self._data
            #changed in order to let the value change
            value = self._toFormValue(value)
            #end changes


    def getInputValue(self):

            value = self.terms.getValue(str(token))
            #changed in order to let the value change
            value = self._toFieldValue(value)
            #end changes


Are there any objections to these proposed changes? I'am not a Zope3
Developer, so is anyone willing to make these changes in Zope3?


Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to