You probably want StringBool for one thing(it gets me all the time).
StringBool: 'True'==True, 'False' == False, '' == None
Bool: 'any string' == 'True' == 'False' == True, '' == false
Also you can use the following to handle cases when they are not sent
at all or are invalid:
if_empty=False, if_invalid=False
So in the end you probably just want this for both the keep and active fields:
validator=validator.StringBool(if_empty=False)
Your error is most likely being caused by the missing of if_empty=False.
Not using StringBool will cause problems later(or maybe as soon as you
add if_empty and try it again).
You can test them on the console using:
import turbogears.validators as validators
validators.StringBool.to_python(value)
validators.Bool.to_python(value)
-Ian
On 6/19/07, aspineux <[EMAIL PROTECTED]> wrote:
>
> Here is y code
>
> class FormForwarding(widgets.TableForm):
> fields = [
> MultipleHiddenFields('context'),
> widgets.CheckBox('active', label="Activate forwarding",
> validator=validators.Bool()),
> widgets.TextField('forward_addr', label="Address to forward
> to", attrs=dict(size=40, maxlength=255), validator=EmailValidator()),
> widgets.CheckBox('keep', label="Keep a copy on server",
> validator=validators.Bool()),
> ]
> submit_text = "Update forwarding"
>
> here is my "action" method :
>
> @turbogears.expose()
> @validate(form=forwarding_form)
> @error_handler(index)
> def update_forwarding(self, email_addr, forward_addr, active,
> keep, **kwargs):
> ...
>
> If one of both checkbox is unchecked, I get error:
>
> exceptions.TypeError: ('update_forwarding() takes at least 5 non-
> keyword arguments (3 given)', <function _wrapper at 0xa5e5224>)
>
> more debug info
> args ()
> errors []
> fn <bound method Mailbox.update_forwarding of
> <emailgency.addr_ctrl.Mailbox object at 0xa39cb6c&g...t;>
> kw {'email_addr': u'[EMAIL PROTECTED]', 'forward_addr':
> u'[EMAIL PROTECTED]', 'keep': u'on...'}
> predicate <turbogears.identity.conditions.in_any_group object at
> 0xa2e8a0c>
>
> << errors= []
> if predicate.eval_with_object( current, errors ):
> return fn( *args, **kw )
> else:
> raise IdentityFailure( errors )>> return fn( *args,
> **kw )
> exceptions.TypeError: ('update_forwarding() takes at least 5 non-
> keyword arguments (3 given)', <function _wrapper at 0xa5e5224>)
>
> TG 1.0.2.2
>
>
> Regards
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---