On Thu, Jul 3, 2008 at 11:56, zaf <[EMAIL PROTECTED]> wrote:
>
> thing is I'm not using widgets, will that still work ?
> I'm not too familiar with validators yet (haven't really had a use for
> them so far) but i'll look it up.
> Thanks
Validators work even without widgets... Take a look here: [1]
Anyway, if you don't want to use validators, here's a handy function
for your use case:
----------------------
def ensure_sequence(obj):
"""
Adapted from turbogears.util.ensure_sequence.
"""
if obj is None:
return []
elif isSequenceType(obj) and not isinstance(obj, basestring):
return obj
else:
return [obj]
----------------------
This way you can also do:
for x in ensure_sequence(unkwnow_object_type):
... do something with x
Cheers,
Roger
[1] - http://docs.turbogears.org/1.0/ValidateDecorator
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---