On Monday 15 June 2009 10:15:51 enrico secco wrote:
> Hi people,
> I did alredy post this problem on the ToscaWidgets group but no
> response.
> Could be here ... I'm more lucky.
>
> I'm in truble with validation in TG 1.0.8 ToscaWidgets application.
> I did search the discussion to find a solution but seems that I'm
> alone with this problem...
> So at fisrt my configuration and the code:
>
> the ls of my site-packeges direcory is:
>
> Cheetah-2.0.1-py2.5-linux-i686.egg
> CherryPy-2.3.0-py2.5.egg
> configobj-4.6.0-py2.5.egg
> DBSprockets-0.5dev_r417-py2.5.egg
> DecoratorTools-1.7-py2.5.egg
> easy-install.pth
> Extremes-1.1.1-py2.5.egg
> FormEncode-1.2.2-py2.5.egg
> Genshi-0.5.1-py2.5-linux-i686.egg
> gsquickstart-1.0-py2.5.egg
> kid-0.9.6-py2.5.egg
> Paste-1.7.2-py2.5.egg
> PasteDeploy-1.3.3-py2.5.egg
> PasteScript-1.7.3-py2.5.egg
> PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg
> RuleDispatch-0.5a1.dev_r2506-py2.5-linux-i686.egg
> setuptools-0.6c9-py2.5.egg
> setuptools.pth
> simplejson-2.0.9-py2.5-linux-i686.egg
> SQLAlchemy-0.5.3-py2.5.egg
> ToscaWidgets-0.9.4-py2.5.egg
> TurboCheetah-1.0-py2.5.egg
> TurboGears-1.0.8-py2.5.egg
> TurboJson-1.1.4-py2.5.egg
> TurboKid-1.0.4-py2.5.egg
> tw.dynforms-0.9.1-py2.5.egg
> tw.forms-0.9.3-py2.5.egg
> tw.yui
> tw.yui-0.9.2.7.0dev-py2.5.egg
> WebOb-0.9.6.1-py2.5.egg
> WidgetBrowser
> WidgetBrowser-0.1dev_20090509-py2.5.egg
>
> controllers.py
>
> def get_activity_form2(role=-1):
> activity_form = twf.TableForm('activity_form',
> action='save_activity1', validator=TGSchema, children=[
> twf.HiddenField('id'),
> twf.HiddenField('user'),
> twf.CalendarDatePicker('date', date_format='%d/%m/%Y'),
> twf.SingleSelectField('project', options=get_projects(),
> validator=NotEmpty),
> twd.CascadingSingleSelectField('role', options=get_roles
> (),cascadeurl='get_activitytypes2',label='Ruolo', validator=NotEmpty),
> twf.SingleSelectField('activitytype',
> options=get_activitytypes
> (role=role), validator=NotEmpty),
> twf.TextField('minutes', validator=NotEmpty),
> ])
> return activity_form
It's hard to understand what your actual problem is, but for me it appears to
be the above function.
TW (and TG 1) widgets are designed around the concept of singleton instances
of a given widget. They are *not* re-created on the fly within a request.
A usual setup is this (untested):
form_a = TableForm('activity_form', fields=[...])
form_b = TableForm('activity_form', fields=[...other fields...])
def get_activity_form():
if request.params['that_hidden_field_that_tells_us_the_form']
== "form_a":
return form_a
return form_b
And of course in your controllers, you also always only return the various
form instances.
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
-~----------~----~----~----~------~----~------~--~---