So I have been working on a validator and trying to simply make a list
from a string.
a="['a','b']"
b=a[1:-1].split(',')
returns
[ " 'a' "," 'b' " ]
Is there a simpler way?
On Wed, Feb 17, 2010 at 1:57 PM, mdipierro <[email protected]> wrote:
> because now
>
> db.table.insert(yourlistfield=.....)
>
> has to be a list. You need to create a validator that takes the input
> and filters it into a list. I cannot write that for you since it
> depends on how you insert the data.
>
> On Feb 17, 12:57 pm, Wes James <[email protected]> wrote:
>> I removed all the data and tweaked the model a bit so all it looks like is:
>>
>> if request.env.web2py_runtime_gae:
>> db = DAL('gae')
>> session.connect(request, response, db=db) # and store sessions and
>> tickets there
>> else:
>> db = DAL('sqlite://storage.sqlite')
>>
>> from gluon.tools import *
>> crud=Crud(globals(),db)
>>
>> from gluon.contrib.gql import gae
>>
>> db.define_table('ideModelAPI',
>> Field('ideModelAPIitem','string'),
>> Field('ideModelAPITip','text'),
>> Field('ideModelAPIkey',type=gae.StringListProperty())
>> )
>>
>> but when I go to /app/
>>
>> /app/default/controller/create/table
>>
>> and submit the data, I still get:
>>
>> BadValueError: Property ideModelAPIkey must be a list
>>
>> This is even with a blank value, or [], or ['a'] for tests.
>>
>> Is there something wrong with gql.py?
>>
>> -wes
>>
>> On Wed, Feb 17, 2010 at 9:56 AM, Wes James <[email protected]> wrote:
>> > After some changes when I try to add an entity on gae through their
>> > interface, the StringListProperty field does not even show for me to
>> > put data in it.
>>
>> > If I edit a record that already has some data, the StringListProperty
>> > field has [] in it, but if I leave it blank or add some data like
>> > ['a','b'] I get the error:
>>
>> > ...'
>>
>> > File
>> > "/base/data/home/apps/web2pyapi/1.339952435474722330/gluon/contrib/gql.py",
>> > line 719, in update
>> > setattr(item, field, value)
>> > File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py",
>> > line 472, in __set__
>> > value = self.validate(value)
>> > File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py",
>> > line 2731, in validate
>> > raise BadValueError('Property %s must be a list' % self.name)
>> > BadValueError: Property ideModelAPIkey must be a list
>>
>> > What is it about blank, or even [] or ['a','b'] that is not a list?
>>
>> > and why is google interface not providing a field for adding a list
>> > value for that field?
>>
>> > -wes
>>
>> > On Wed, Feb 17, 2010 at 9:09 AM, mdipierro <[email protected]> wrote:
>> >> As far as web2py is concerned you just change the type.
>> >> As far as GAE is concerned I do not know.
>> >> Try and see what happens.
>>
>> >> On Feb 17, 9:56 am, Wes James <[email protected]> wrote:
>> >>> OK. That field is a text field on gae now, how do I change it to
>> >>> gae.StringListProperty type?
>>
>> >>> On Tue, Feb 16, 2010 at 9:50 PM, mdipierro <[email protected]>
>> >>> wrote:
>> >>> > You are mixing gae syntax and dal syntax.
>>
>> >>> > This is only allowed in
>>
>> >>> > from gluon.contrib.gql import gae
>> >>> > db.define_table('mytable',Field('this_is_a_list',type=gae.StringListProperty()))
>>
>> >>> > queries must use dal syntax.
>>
>> >>> > On Feb 16, 5:46 pm, Wes James <[email protected]> wrote:
>> >>> >> There does not seem to be an .all(). How should the line be written?
>>
>> >>> >> thx,
>>
>> >>> >> -wes
>>
>> >>> >> On Tue, Feb 16, 2010 at 4:25 PM, Wes James <[email protected]>
>> >>> >> wrote:
>> >>> >> > so if I created a field
>>
>> >>> >> > Field('fieldKey', 'text')
>>
>> >>> >> > and put ['web2py', 'web2p', 'web2', 'web', 'we', 'w'], in for the
>> >>> >> > value and then did
>>
>> >>> >> > query=request.vars._query
>>
>> >>> >> > rows=db(db.table.all().filter('fieldKey >=', query).filter('fieldKey
>> >>> >> > <', query + u'\ufffd')).select(db.table.ALL,
>> >>> >> > orderby=db.table.tableitem)
>>
>> >>> >> > this would work?
>>
>> >>> >> > On Sun, Feb 14, 2010 at 3:57 AM, Richard <[email protected]>
>> >>> >> > wrote:
>> >>> >> >> sounds like this will be useful.
>>
>> >>> >> >> StringListProperty is a native gae type now supported by web2py:
>> >>> >> >>http://code.google.com/appengine/docs/python/datastore/typesandproper...
>> >>> >> >>http://groups.google.com/group/web2py/browse_thread/thread/7d284c9fa4...
>>
>> >>> >> >> To get around the like problem you can do something like this:
>> >>> >> >> Model.all().filter('ngrams >=', word).filter('ngrams <', word +
>> >>> >> >> u'\ufffd')
>>
>> >>> >> >> Check out Thadeus's code for a full example.
>>
>> >>> >> >> There's also info how to do this in the docs:
>> >>> >> >>http://code.google.com/appengine/docs/python/datastore/queriesandinde...
>>
>> >>> >> >> Richard
>>
>> >>> >> >> On Feb 14, 1:52 pm, Wes James <[email protected]> wrote:
>> >>> >> >>> Richard,
>>
>> >>> >> >>> Do you have a python example of this? I'll check on
>> >>> >> >>> StringListProperty also and see how it works. (would this work on
>> >>> >> >>> gae?) I was trying somthing else since like is not supported, but
>> >>> >> >>> this
>> >>> >> >>> might work. I would like this site to provide quick search on
>> >>> >> >>> anything that would be helpful in building a web2py app. There
>> >>> >> >>> are a
>> >>> >> >>> lot of things in tools.py that could go here for instance, and
>> >>> >> >>> maybe
>> >>> >> >>> another page with docstrings? Whatever anyone thinks would be
>> >>> >> >>> helpful.
>>
>> >>> >> >>> -wes
>>
>> >>> >> >>> On Sat, Feb 13, 2010 at 4:26 PM, Richard <[email protected]>
>> >>> >> >>> wrote:
>> >>> >> >>> > hi wes,
>>
>> >>> >> >>> > something like this could be really nice for browsing the
>> >>> >> >>> > function
>> >>> >> >>> > docstrings. Do you intend to take it further?
>>
>> >>> >> >>> > If you use a StringListProperty to store all the ngrams (eg:
>> >>> >> >>> > web2py,
>> >>> >> >>> > web2p, web2, web, we, w) then it could match partial words.
>>
>> >>> >> >>> > Richard
>>
>> >>> >> >> --
>> >>> >> >> 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
>> >>> >> >> athttp://groups.google.com/group/web2py?hl=en.
>>
>> >>> > --
>> >>> > 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
>> >>> > athttp://groups.google.com/group/web2py?hl=en.
>>
>> >> --
>> >> 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
>> >> athttp://groups.google.com/group/web2py?hl=en.
>
> --
> 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.
>
>
--
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.