I can confirm, this is very desirable feature for form library to
have. Currently we generate schema on the fly because:

1) We allow some components to modify schema before rendering it.
2) We want to provide validating "in context" — allow values that are
in database and etc.

I don't think we can't do 1) the other way, but 2) makes me wonder
about something  like ``form.validate(data, context)``, there
``context`` is arbitrary context, in which you want to validate form.

On Tue, Sep 7, 2010 at 4:37 PM, Tim Hoffman <zutes...@gmail.com> wrote:
> Bummer ;-)
> I don't think I have a developed an application in the last 10 years
> that hasn't has to do this.
> I was quite surprised when I discovered this feature was missing in
> formish, but it seems to be missing in quite a
> few other form libs like wtforms as well.
> I suppose at least they all have declarative method of defining the
> schema, but it does mean the actual schema definition is a bit more
> obscured.
> Cheers
> T
> On Tue, Sep 7, 2010 at 8:20 PM, Chris McDonough <chr...@plope.com> wrote:
>> Hi Tim,
>> Sorry, there is no built-in solution that will allow you to use
>> declarative-module-scope code only.  You'll need to generate schemas and
>> widgets at render time.
>> - C
>> On Tue, 2010-09-07 at 12:56 +0800, Tim Hoffman wrote:
>>> Hi Chris.
>>> Am just starting too look at deform in some detail and I have question.
>>> One of the things I have struggled with formish has been the fact I
>>> can't easily
>>> define a source of values for widgets like checkbox or validators such
>>> as OneOf to
>>> only be resolved late at render time. And I can't see how I would go
>>> about it with deform.
>>> In your example http://docs.repoze.org/deform/app.html you have
>>>  colors = (('red', 'Red'), ('green', 'Green'), ('blue', 'Blue')) used
>>> as values for
>>> widget.RadioChoiceWidget values and for the validator OneOf
>>> So in my contrived example I would like the set of possible values
>>> for color is dependent on the
>>> user and some other factor.  Looking at the code for SelectWidget and
>>> RadioChoice widget
>>> it appears they won't take a callable and lazily render those values
>>> at render time.
>>> With formish I basically constructed the form structure (schema)
>>> but only applied widget definitions  and validators just before render
>>> time. So that I could use things
>>> like the current context to determine values for validation or
>>> choices.  This was a bit of a hack.
>>> So do you have a strategy or suggestion on how to approach this use case ?
>>> I suppose I could work with imperative schema definition performed
>>> late, but I much prefer to work with classes.
>>> (I currently generate Formish (structures) directly from UML).
>>> Cheers
>>> Tim
>>> _______________________________________________
>>> Repoze-dev mailing list
>>> Repoze-dev@lists.repoze.org
>>> http://lists.repoze.org/listinfo/repoze-dev
> _______________________________________________
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev

Andrey Popp

phone: +7 911 740 24 91
e-mail: 8may...@gmail.com
Repoze-dev mailing list

Reply via email to