-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 22/04/2012 00:52, Alessandro Molina a écrit :
> Can you provide more informations or a test case?
There's not much more to say. _method is an hidden field added to the
form as recommended in the documentation for RestController.
Here is an example from my application running fine with tg2.1:
class Edit_group_form(TableForm):
''' Edit group form
'''
fields = [
TextField('display_name', validator=NotEmpty,
label_text='Descriptif',
help_text=u'Entrez un descriptif du groupe'),
HiddenField('_method', validator=None), # Needed by RestController
hiddenField('group_id', validator=Int),
]
submit_text = u'Valider...'
action = '/groups'
method = 'POST'
hover_help = True
edit_group_form = Edit_group_form('edit_group_form')
....
@expose(template="astportal2.templates.form_new")
def edit(self, id=None, **kw):
''' Display edit group form
'''
if not id: id = kw['group_id']
g = DBSession.query(Group).get(id)
v = {'group_id': g.group_id, 'display_name': g.display_name,
'_method': 'PUT'}
tmpl_context.form = edit_group_form
return dict(title = u'Modification groupe ' + g.group_name,
debug='', values=v)
@validate(edit_group_form, error_handler=edit)
@expose()
def put(self, display_name, group_id):
''' Update group in DB
'''
log.info('update %d' % group_id)
g = DBSession.query(Group).get(group_id)
g.display_name = display_name
flash(u'Groupe modifié')
redirect('/groups/%d/edit' % group_id)
I have tried to create a simple tg2.2 quickstarted application with a
RestController, but I'm getting another error :
TypeError: No object (name: ToscaWidgets per-request storage) has been
registered for this thread
Thanks,
- --
Jean-Denis Girard
SysNux Systèmes Linux en Polynésie française
http://www.sysnux.pf/ Tél: +689 50 10 40 / GSM: +689 79 75 27
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAk+UnIcACgkQuu7Rv+oOo/h+EQCgk2RBfFODIhjK4v9mTESaKzKG
4uUAni0gLtWB0/c2LmcMq+SA46S7CQO1
=6BSJ
-----END PGP SIGNATURE-----
--
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.