On Aug 3, 2005, at 4:46 PM, Marc Rijken wrote:

Hi all,

Hi Marc.

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

        <snip>

I strongly agree that sources need a connection to the field's context. Vocabularies, the precursor to sources, do this. Because Sources are supposed to be the "cleaned up" vocabularies, eventually deprecating them, we need to spend some thought to get this right and get concensus. Jim Fulton has expressed strong opinions about this in the past, so we probably need to wait on his return from vacation (a few weeks from now) before working through this.

If you need to proceed now with this sort of use case, I suggest using vocabularies.

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.

Sources already can be used with arbitrary objects; the sources need to be able to be converted to string tokens for display. Read through the .txt again; I'll be happy to try and answer specific questions.

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

Reply via email to