I responded but my answer did not appear. I believe this is a known bug. The common_filters are ignored if there is no query:
try db().select(db.p2.name) vs db(db.p2).select(db.p2.name) This should be fixed. I believe there is already a ticket on the topic. On Sunday, 25 November 2012 15:42:14 UTC-6, Brian Zhou wrote: > > #!/usr/bin/env python > > # export PYTHONPATH=.../web2py > > from gluon import DAL, Field > > def def_tables(db): > > p2 = db.define_table('p2', > Field('name', 'string'), > Field('is_active', 'boolean', default=True), > common_filter = lambda q: db.p2.is_active==True) > > def get_db(): > return DAL('sqlite://storage.sqlite') > > def get_db_with_schema(): > db = get_db() > def_tables(db) > return db > > def db_ops(db): > db.p2.truncate() > > db.p2.insert(name='Alice') > db.p2.insert(name='Bob') > db.commit() > > print 'before deactivating Alice' > print db(db.p2.name=='Alice').update(is_active=False) > print 'after deactivating Alice' > db.commit() > > def test(): > db = get_db_with_schema() > db_ops(db) > print db.p2._common_filter > print 1, [r.name for r in db().select(db.p2.name)] > print 2, [r.name for r in db(ignore_common_filters=False).select( > db.p2.name)] > print 3, [r.name for r in db(ignore_common_filters=True).select( > db.p2.name)] > print 4, [r.name for r in db(db.p2.is_active==True).select(db.p2.name > )] > > if __name__ == "__main__": > test() > > Ran against trunk 1b0e08. > Inspecting DB, Alice has been successfully updated, is_active set to F. > I expect to see ['Bob'] in print out 1, 2, and 4. But I'm seeing > > before deactivating Alice > 1 > after deactivating Alice > <function <lambda> at 0x315a500> > 1 ['Alice', 'Bob'] > 2 ['Alice', 'Bob'] > 3 ['Alice', 'Bob'] > 4 ['Bob'] > > Did I miss anything, or shall I file a bug? > > Thanks, > > -Brian > --