Yes, to me the set is like the where clause in a select sentence in SQL : db(db.table.field == something).select(db.table.field1, db.table.field2, db.table.field_etc)
set select Set : where table.field = something Select : SELECT field1, field2, field_etc FROM table And since a view is just a select that you can call without having to matter to define the fields you want and which rows you don't. SELECT * FROM view_tableX In web2py you will have to precise the columns if you want or you can just put you complete select into a variable : 1) set : var1 = db(db.table.field == something) So you have to write the select part : var1.select(db.table.field1, etc...) 2) select : var1 = db(db.table.field == something).select(db.table.field1, db.table.field2, db.table.field_etc) I use var1, but you can view the result of web2py select as rows : rows = db(db.table.field == something).select(db.table.field1, db.table.field2, db.table.field_etc) But if you want to use a web2py select as a "view", you can create a meaningful name for storing the select and use it where you need it. But notice that if you want to use the "web2py view" in an other query it mays not works as you could expect and about that I refer you to the book for the proper way to make multiple table query with left join or other means. Hope it help. Richard On Tue, Jun 5, 2012 at 9:54 AM, bob <bmacc...@gmail.com> wrote: > Thanks Richard, I am coding up the set example, it should do what I need > without having to build views. > > > > > On Monday, June 4, 2012 1:04:14 PM UTC-7, Richard wrote: > >> Yes it works, but I think lambda: has_membership is much better approach >> as pointed by Anthony as more fast since the lambda is only hit when you >> really want to access the records... >> >> Richard >> >> >> On Mon, Jun 4, 2012 at 4:00 PM, pbreit wrote: >> >>> I might not quite understand the question but wouldn't readable/writable >>> work? >>> >>> >>> On Monday, June 4, 2012 5:56:40 AM UTC-7, bob wrote: >>>> >>>> >>>> In the old days I would just create a database view on a subset of a >>>> table that I wanted to allow other developers to access (assuming read >>>> only), however I'm not sure if that's the best thing to do with web2py. >>>> >>>> I have a table that has: >>>> >>>> last_name >>>> first_name >>>> etc >>>> including some 'internal' columns that I don't want to expose on any >>>> form or service. >>>> >>>> Any thoughts on the best way to implement this? >>>> >>>> I'm thinking: >>>> >>>> a: database view (postgresql in this case), issues being no 'id' in >>>> the view and I'm not sure how best to maintain that. >>>> >>>> b: a new .py that takes the full record and returns the subset. >>>> upside - it would be a single point of maintenance, question is where >>>> would this live (in the models, it's not a controller so it doesn't really >>>> fit there)? >>>> >>>> c: ?? >>>> >>>> thanks for any suggestions, >>>> bobm >>>> >>>> >>