On Sat, 2007-08-09 at 12:53 -0700, badfrog wrote:
> I've defined and imported these classes into a tg-admin shell session:
> 
> class CustomerFormFields(widgets.WidgetsList):
> 
>     name = widgets.TextField(
> 
>         validator=validators.NotEmpty(),
> 
>         label="Name (First Last)"
> 
>     )
> 
>     nickName = widgets.TextField(
> 
>         validator=validators.NotEmpty(),
> 
>         label="Tag/Nickname"
> 
>     )
> 
>     dateOfBirth = widgets.CalendarDatePicker(
> 
>         validator=validators.DateTimeConverter(),
> 
>         label="Date of Birth"
> 
>     )
> 
> 
> class PhoneFormFields(widgets.WidgetsList):
> 
>     name = widgets.TextField(
> 
>         label = "Label",
> 
>         attrs = dict(size = 50)
> 
>     )
> 
> 
> 
>     number = widgets.TextField(
> 
>         label = "Number",
> 
>         attrs = dict(size = 12)
> 
>     )
> 
> here's the session text:
> 
> >>> from forms import *
> >>> from turbogears import widgets
> >>> l = []
> >>> l.append(CustomerFormFields())
> >>> l.append(PhoneFormFields())
> >>> f = widgets.TableForm(fields=l)
> Traceback (most recent call last):
> [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 169, in widget_init
>     validator = generate_schema(self.validator, widgets)
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 277, in generate_schema
>     if widget.is_named:
> AttributeError: 'CustomerFormFields' object has no attribute
> 'is_named'
> >>> f2 = widgets.TableForm()
> >>> f2.fields.append(CustomerFormFields())
> >>> f2.fields.append(PhoneFormFields())
> >>> f2.display()
> Traceback (most recent call last):
>  [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/forms.py", line 554, in update_params
>     if field.name not in d["disabled_fields"]:
> AttributeError: 'CustomerFormFields' object has no attribute 'name'
> >>> f3 = widgets.TableForm()
> Traceback (most recent call last):
>   [...]
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 169, in widget_init
>     validator = generate_schema(self.validator, widgets)
>   File "/usr/local/lib/python2.4/site-packages/TurboGears-1.0.3.2-
> py2.4.egg/turbogears/widgets/meta.py", line 277, in generate_schema
>     if widget.is_named:
> AttributeError: 'CustomerFormFields' object has no attribute
> 'is_named'
> 
> Questions:
> Am I missing something from my WidgetsList classes that's causing
> these AttributeErrors?
> Can I not append to the form's fields collection, or use a list to put
> together a bunch of WidgetLists?
> Why does an error on one TableForm cause errors on another unrelated
> instance that doesn't even have any widgets in it?
> I've noticed similar behavior if I call TableForm.display() more than
> once on the same form instance. Is this a no-no?
> I've looked at the Widget Toolbox, and the tutorials, and they are all
> really helpful, but what seems to be really missing is API
> documentation. Some of the __doc__ strings are helpful, but others
> aren't set or don't really illuminate anything. Is there any existing
> documentation?
> 

Hi Badfrog ( real name not visible! ).

I believe the problem may be that you are using a regular list instead
of a WidgetsList, but I'm no widget internals expert. Try your code
again making one class that holds all the fields and inherits from
WidgetsList. If that doesn't help, report back again!

Iain



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