I finally get it works like I was expecting like this : @auth.requires_login() def select(): if request.args(0) in actualTablesList: if db[request.args(0)].id>0: sampleIdEqId={} listId=[] for r in db(db[request.args(0)].id>0).select(db[request.args(0)].id): listId.append(r.id) i=0 for row in db(db[request.args(0)].id>0).select(db[request.args(0)].sample_id): sampleIdEqId[row.sample_id]=listId[i] i=i+1 db[request.args(0)].sample_id.represent=\ lambda sample_id: A("%(sample)s" %db.v_sample_num_all[sample_id],\
_href=URL(r=request,f='read',args=request.args(0)+'/'+str(sampleIdEqId.get(sample_id)))) # Should be replace by db.TABLE.FIELDNAME.readable=False when it will be available for SQLTABLE and crud.select # Begin fieldsBlackList=[ db[request.args(0)].id.name, 'FIELD1', 'FIELD2' ] field2Show=[ request.args(0)+'.%s'%f for f in db[request.args(0)].fields if f not in fieldsBlackList ] rows=db().select(*field2Show) # End # Should be replace if lable are use in SQLTABLE in the future # Begin headersRepresent={} for f in db[request.args(0)].fields: headersRepresent[str(db[request.args(0)][f])]=db[request.args(0)][f].label # End table=SQLTABLE(rows,headers=headersRepresent,_class='sortable',truncate=None) return dict(table=table) response.flash = T('There is no data') And Massimo fixed a major bug that relates to all these post I made this week ;-) I will look at it later today if I have time. I really appreciate your help! Richard On Thu, Oct 21, 2010 at 4:36 PM, DenesL <denes1...@yahoo.ca> wrote: > 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 <ml.richard.vez...@gmail.com> > 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 <mdipie...@cs.depaul.edu> > 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 <ml.richard.vez...@gmail.com> > > > 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 < > > > > > > ml.richard.vez...@gmail.com> 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 <denes1...@yahoo.ca> > 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 <ml.richard.vez...@gmail.com> > > > > >> 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 <denes1...@yahoo.ca> > > > 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 < > ml.richard.vez...@gmail.com> > > > > >> > > 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 > > > > >