Karl Guertin wrote:
> On 2/10/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> >  comment_form = TableForm(fields=[CommentFields(), special_consideration =
> >  TextArea()])
> >
> > I mean, is it possible to combine the declaration with something else (or 
> > two
> > declarations, or ...)?
>
> That won't work, but...
>
> comment_form = TableForm(fields=[CommentFields(),
> TextArea('special_consideration')])
>
> should if my understanding of the rewrite is correct. The fields
> attribute is just a dumb list, the declarative magic only occurs in
> classes that subclass WidgetsDeclaration. I think you can even adjust
> the fields after you've instantiated the TableForm:
>
> comment_form = TableForm(fields=[CommentFields()])
> comment_form.fields += TextArea('special_consideration')

Exactly as Karl said, a WidgetsDeclaraion instance is just a list and
you can anything you can do with a list with it.

Example:

>>> from turbogears import widgets as w
>>> from turbogears.widgets import WidgetsDeclaration as WD
>>> class CommentFields(WD):
...     name = w.TextField()
...     comment = w.TextArea()
...
>>> class OtherFields(WD):
...     special = w.TextArea()
...
>>> fields = CommentFields() + OtherFields()
>>> for field in fields:
...     print field.name
...
name
comment
special
>>> fields.append(w.CheckBox(name="jorge"))
>>> for field in fields:
...     print field.name
...
name
comment
special
jorge
>>>

Ciao
Michele


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to