GAE DataStore - Web2Py 1.99.7 Stable On Thu, Apr 12, 2012 at 5:53 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote:
> What database, what web2py version? > > > On Thursday, 12 April 2012 01:48:51 UTC-5, Sathvik Ponangi wrote: >> >> From >> http://stackoverflow.com/**q/10117143/937891<http://stackoverflow.com/q/10117143/937891> >> >> I'm trying to exclude posts which have a tag named meta from my >> selection, by: >> >> meta_id = db(db.tags.name == "meta").select().first().id >> not_meta = ~db.posts.tags.contains(meta_**id) >> posts=db(db.posts).select(not_**meta) >> >> But those posts still show up in my selection. >> >> What is the right way to write that expression? >> >> My tables look like: >> >> db.define_table('tags', >> db.Field('name', 'string'), >> db.Field('desc', 'text', default="") >> ) >> >> db.define_table('posts', >> db.Field('title', 'string'), >> db.Field('message', 'text'), >> db.Field('tags', 'list:reference tags'), >> db.Field('time', 'datetime', default=datetime.utcnow()) >> ) >> >> *UPDATE:* >> >> I just tried posts=db(not_meta).**select() as suggested by @Anthony, but >> it gives me a Ticket with the following Traceback: >> >> Traceback (most recent call last): >> File "E:\Programming\Python\web2py\**gluon\restricted.py", line 205, in >> restricted >> exec ccode in environment >> File >> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py", >> line 391, in <module> >> File "E:\Programming\Python\web2py\**gluon\globals.py", line 173, in >> <lambda> >> self._caller = lambda f: f() >> File >> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py", >> line 8, in index >> posts=db(not_meta).select()#**orderby=settings.sel.posts, limitby=(0, >> settings.delta) >> File "E:\Programming\Python\web2py\**gluon\dal.py", line 7578, in select >> return adapter.select(self.query,**fields,attributes) >> File "E:\Programming\Python\web2py\**gluon\dal.py", line 3752, in select >> (items, tablename, fields) = self.select_raw(query,fields,**attributes) >> File "E:\Programming\Python\web2py\**gluon\dal.py", line 3709, in >> select_raw >> filters = self.expand(query) >> File "E:\Programming\Python\web2py\**gluon\dal.py", line 3589, in expand >> return expression.op(expression.**first) >> File "E:\Programming\Python\web2py\**gluon\dal.py", line 3678, in NOT >> raise SyntaxError, "Not suported %s" % first.op.__name__ >> SyntaxError: Not suported CONTAINS >> >> -- Sathvik Ponangi