> Not really.
>
> More like:
>
> Declare the form statically as per now.
>
> class MyFields(widgets.WidgetsList):
>     description = widgets.TextField(label="Description")
>
> class MyForm():
>     fields = MyFields()
>
> in the page handler:
>
>      form = MyForm()
>      if user.is_restricted:
>         form['description'].update_attrs({'readonly':'readonly'})
>         form['description'].label = "A different label"
> .....
>
> I.e. I would like to "create" a form instance, modify a few bits
> (perhaps) then send it to the template for display together with the
> values as per now.

Well, if you'd put the above declarations _into_ the controller method, you 
could do it - as python is scope-aware, and your fields and visibilities and 
whatnot could easily be computed befor class-creation. After all, a class is 
also just an object.

> Most, if not all of this should really be done in the controller
> without putting to much extra logic in the template. This way, you
> still only need ${form.display(value=myvalues)} in the template....

So it's not ok for you to write

${form.display(value=myvalues), **form_params}

where form_params is a controller-method created dictionary? 

I accept that a syntax of

form.widget.property = value

is a bit nicer than 

form_params['options']['widget'].property - but not _to_ much, and if you'd 
really wanted, you could use python's __getitem__/__setitem__ and 
__getattr__/__setattr__ functionalityes to achieve that above syntax close 
enough, maybe with some additional magic for creating the top-level 
options/attrs-keys. Maybe I think of something. Maybe not .. :)

> With the current widgets implementation this is not possible except by
> creating custom widgets/subclassing.
>
> Needs some thinking about......

Certainly :) I'm sorry if this sounds rude or harsh, it's certainly not meant 
that way - but all you need is some mind-wrapping IMHO. I'v been doing a 
mid-sized TG-project the pasts few months, and so far it beated the hell of 
evrything else wrt to productivity. There are some quirks, and I admit that 
programming with widgets is something that requires that you shouldn't be 
afraid of looking into the code of turbogears. But so far, it solved all my 
problems, and most of the time more on the elegant side of life.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to