hi, anyone having this same issue with list:integer?

matt

On Oct 8, 10:26 am, mattynoce <[email protected]> wrote:
> i'm having a similar type of issue. i have the following field:
>
> Field('friends','list:integer', default=[], readable=False,
> writable=False),
>
> and it generally works fine. however, when i'm in the gae appadmin and
> i try to modify a user's record, if the user has an empty list for
> friends, i get this error:
>
> BadValueError: Property friends isrequired
>
> what i need is for the friends list to be able to be blank. but adding
> an IS_EMPTY_OR(IS_INT_LIST()) doesn't help (IS_INT_LIST is a validator
> i'll attach below). it still errors when friends has no value.
>
> what can i do to have the list accept an empty entry in appadmin?
>
> thanks,
>
> matt
>
> the validator, just for good measure:
> class IS_INT_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 [int(x) for x
> in value[1:-1].replace('L','').replace(' ','').split(',')], None)
>         except:
>             return (value, 'You did not submit an int list.')
>     def formatter(self, value):
>         return value
>
> On Sep 25, 4:38 pm, mdipierro <[email protected]> wrote:
>
> > Should be
>
> > Field('changed_fields', 'list:string', default=[],
> >      requires=IS_IN_SET(['explanation', 'output'],multiple=True)
> > ),
>
> > for multiple=True, IS_NOT_EMPTY is implicit and confuses web2py
>
> > On Sep 25, 1:39 pm, Jurgis Pralgauskis <[email protected]>
> > wrote:
>
> > > hello I get the same problem for list:string orlist:integeron GAE
> > > using  version 1.85.3
>
> > > note: I think now, that the way I defined requires here is not needed,
> > > but anyway the errorreporting should handle it more fluently :)
>
> > > if from appadmin I try to insert recrod with
>
> > > Field('changed_fields', 'list:string', default=[],
> > >      requires=IS_EMPTY_OR(IS_IN_SET(['explanation', 'output'],
> > > multiple=True))
> > > ),
>
> > > and if I dont select anything for this field, I get:
> > > Internal error
> > > Ticket issued: unknown
>
> > > otherwise it inserts ok.
> > > on nonGAE it works without complaints
>
> > > I'd expect Validation error message instead.
>
> > > on terminal I can see:
> > > ERROR    2010-09-25 07:30:12,628 restricted.py:151] Traceback (most
> > > recent call last):
> > >   File "/media/data/veikla/coding/web2py_gae_test/gluon/
> > > restricted.py", line 188, in restricted
> > >     exec ccode in environment
> > >   File "/media/data/veikla/coding/web2py_gae_test/applications/
> > > CodeByExample/controllers/appadmin.py:insert", line 410, in <module>
> > >   File "/media/data/veikla/coding/web2py_gae_test/gluon/globals.py",
> > > line 96, in <lambda>
> > >     self._caller = lambda f: f()
> > >   File "/media/data/veikla/coding/web2py_gae_test/applications/
> > > CodeByExample/controllers/appadmin.py:insert", line 125, in insert
> > >   File "/media/data/veikla/coding/web2py_gae_test/gluon/sqlhtml.py",
> > > line 1103, in accepts
> > >     self.vars.id = self.table.insert(**fields)
> > >   File "/media/data/veikla/coding/web2py_gae_test/gluon/contrib/
> > > gql.py", line 296, in insert
> > >     tmp = self._tableobj(**fields)
> > >   File "/media/data/veikla/coding/google_appengine/google/appengine/
> > > ext/db/__init__.py", line 813, in __init__
> > >     prop.__set__(self, value)
> > >   File "/media/data/veikla/coding/google_appengine/google/appengine/
> > > ext/db/__init__.py", line 542, in __set__
> > >     value = self.validate(value)
> > >   File "/media/data/veikla/coding/google_appengine/google/appengine/
> > > ext/db/__init__.py", line 3013, in validate
> > >     value = super(ListProperty, self).validate(value)
> > >   File "/media/data/veikla/coding/google_appengine/google/appengine/
> > > ext/db/__init__.py", line 569, in validate
> > >     raise BadValueError('Property %s isrequired' % self.name)
> > > BadValueError: Property changed_fields isrequired
>
> > > ---
> > > ps.: later I thought that  IS_EMPTY_OR is no use here -- if list is
> > > empty then it is empty itself :)
> > > but IS_EMPY allows to haveNonevalue as I suppose.
> > > anyway after removing this constraint and changingNoneto [],
> > > everything seems to work fluently on both GAE and nonGAE.
>
> > > by the way, when trying to import from csv with IS_EMPTY_OR, I was
> > > getting flash message
> > > "Property changed_fields isrequired"
> > > where there isNonefor this field
>
>

Reply via email to