I hope you are certain that is what you want. db().select(*[f for f in db['test_activity'] if not f.name in fieldsBlackList])
will get the field names from test_activity and not from table1 as per your initial post, but table1 might have only a subset of the fields, so the resulting list after the blacklist filter is applied can be different. Denes On Oct 21, 11:00 am, Richard Vézina <[email protected]> wrote: > Thank you very much I got it to work. > > But I think it just a kind of hack because db.table.readable=False not seems > to work for crud.select and SQLTABLE. > > I sent an other e-mail about that today. > > Richard > > On Thu, Oct 21, 2010 at 10:38 AM, mdipierro <[email protected]> wrote: > > You are passing to select a list of field names and not a list fo > > fields. Try > > > db().select(*[f for f in db['test_activity'] if not f.name in > > fieldsBlackList]) > > > On Oct 21, 9:32 am, Richard Vézina <[email protected]> > > wrote: > > > In [4]: *[f for f in db['test_activity'].fields if f not in > > > fieldsBlackList]------------------------------------------------------------ > > > File "<ipython console>", line 1 > > > *[f for f in db['test_activity'].fields if f not in fieldsBlackList] > > > ^ > > > SyntaxError: invalid syntax > > > > In [5]: (*[f for f in db['test_activity'].fields if f not in > > > fieldsBlackList]) > > > ------------------------------------------------------------ > > > File "<ipython console>", line 1 > > > (*[f for f in db['test_activity'].fields if f not in > > fieldsBlackList]) > > > ^ > > > SyntaxError: invalid syntax > > > > And it raise : > > > > In [6]: db().select(*[f for f in db['test_activity'].fields if f not in > > > fieldsBlackList]) > > > ------------------------------------------------------------ > > > SyntaxError: Set: no tables selected > > > > In the select expression... > > > > Richard > > > > On Thu, Oct 21, 2010 at 10:27 AM, Richard Vézina < > > > > [email protected]> wrote: > > > > Do I have to import a python module... In Ipython I was having synthax > > > > error with *[list comp exp of yesterday] > > > > > Richard > > > > > On Wed, Oct 20, 2010 at 10:31 PM, DenesL <[email protected]> wrote: > > > > >> It really depends on how you select and which row indexing you want. > > > > >> To use db().select(...) > > > >> you have to specify table.field pairs in the select (without the db > > > >> part) > > > >> and to obtain the value of field1 you use row['table.field1']. > > > > >> If you are selecting fields from only one table the alternative would > > > >> be > > > >> db(db.table.id>0).select(*[list of fields without table prefix]) > > > >> and each value is accessible as row['field']. > > > > >> To use db().select(...) as in your first post > > > >> you would build the comprehension with: > > > >> L=[ 'table2.%s'%f for f in db['table1'].fields if f not in blacklist ] > > > > >> which creates a list L with: > > > >> 'table2.field1', 'table2.field2', ... > > > >> where field1, field2, ... are field names from table1 that are not > > > >> black listed, > > > > >> and that list can be used directly in the select: > > > >> rows=db().select(*L) # note the * before the list > > > > >> Hope this helps, > > > >> Denes > > > > >> On Oct 20, 11:16 am, Richard Vézina <[email protected]> > > > >> wrote: > > > >> > Near of it... Your list comprehension is doing much simpler then I > > were > > > >> > doing what it should do. > > > > >> > But the problem is still there... > > > > >> > First the > > > > >> > [f for f in db['table1'].fields if f not in BlackList] > > > > >> > Return a list (['field1','field2', etc.]) without the rest of the > > > >> > information needed : "db.table" > > > > >> > I was having in a : > > > > >> > 'db.table.field1, db.table.field2, etc.' > > > > >> > Second it is a list. > > > > >> > My fundamental problem is that I try tu use the content of a > > variable as > > > >> > code for my app and that should not be a common thing in > > programmation > > > >> since > > > >> > I am not a experienced programmer. > > > > >> > I don't know if I should do something else to resolve my problem... > > > > >> > Basically I would do exactly the inverse of columns= do in SQLTABLE > > > > >> > Richard > > > > >> > On Tue, Oct 19, 2010 at 10:52 PM, DenesL <[email protected]> > > wrote: > > > >> > > Hello Richard, > > > > >> > > if I understood correctly, you want: > > > > >> > > ... > > > >> > > BlackList = [ 'fieldx', 'fieldy', ...] > > > >> > > rows = db().select(*[f for f in db['table1'].fields if f not in > > > >> > > BlackList]) > > > >> > > ... > > > > >> > > Denes > > > > >> > > On Oct 19, 6:14 pm, Richard Vézina <[email protected]> > > > >> > > wrote: > > > >> > > > Hello, > > > > >> > > > I would do this : > > > > >> > > > def grid(): > > > >> > > > if request.args[0] in tableSubSet: > > > >> > > > allFieldsSet=set(db['table1'].fields) # all the fields > > in > > > >> the > > > >> > > table > > > >> > > > fieldsBlackListSet=set(['f1ToRem','f2ToRem','f1ToRem']) > > # > > > >> fields > > > >> > > to > > > >> > > > be remove from the grid > > > >> > > > allFieldsSet-=fieldsBlackListSet # removing fields to be > > > >> removed > > > >> > > > fieldsRequested=[] > > > >> > > > for field in allFieldsSet: > > > fieldsRequestedList.append('db.test_activity.'+field) # > > > >> > > building > > > >> > > > the select list of elements > > > > >> > > > a=','.join(fieldsRequestedList) # transform the list > > into a > > > >> > > string > > > > >> > > > rows = db().select(a) # BLOCKED BECAUSE OF THE QUOTES > > > >> > > > (*'*db.table1.field1, > > > >> > > > db.table1.field2, etc.*'*)!!! > > > >> > > > table=SQLTABLE(rows) > > > >> > > > return dict(table=table) > > > > >> > > > Thanks for your help. > > > > >> > > > Richard > >

