On Wed, Feb 17, 2010 at 8:13 PM, mdipierro <[email protected]> wrote:
> noooo...
>
> class IS_LIST():
> def __call__(self,value):
> return ([x.strip() for x in value.split(',')],None)
> def formatter(self,value):
> return ', '.join(value)
>
> Field('mylist',gae.StringListProperty(),requires=IS_LIST())
Above returns a string and I need a list for gae. This seems to work:
class IS_LIST():
def __init__(self, format='', error_message='must be a list!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
return ([] if value=='[]' or value=='' else
value[2:-2].split("','"), None)
except:
return (value, self.error_message)
def formatter(self, value):
return value
If in the form I input [] or ['a','b'], etc.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en.