Hi Massimo, I was on this problem MadWalker this morning, perhaps I can offer some insights into the problem.
This is essentially an electronic record-book project. 1. The "notebook" table contains the set of notebooks created. db.define_table('notebook', SQLField('name')) 2. Each entry has to be in a notebook - rather like pages of a notebook. db.define_table('entry', SQLField('title'), SQLField('notebook',db.notebook)) 3. Currently, what we have is "entries" function which is used to produce a table of contents (TOC) listing for a notebook. The TOC is actually in inverse chronology. def entries(): #return the notebook itself records=db(db.entry.notebook==request.vars.notebook)\ .select(orderby=~cdb.entry.id) form=SQLFORM(cynotedb.entry,fields=['notebook']) return dict(form=form, records=records) 4. It works well so far. Our issue now is this... as we create more notebooks for projects etc. and when the project ends, we want to archive the notebook. We thought that the easiest way is to put an "archive" flag in "notebook" table and modify "entries" to only show those active notebooks (archive = F). 5. We face with an issue. The line "form=SQLFORM(cynotedb.entry,fields= ['notebook'])" gathers the set of notebooks from the entry table and not the notebook table. My initial thought was that to do a inner join of entry and notebook table, then a select for "archive = F". Will you suggest this route of action? We will appreciate any better/maintainable suggestions. Thanks Maurice On Jan 29, 11:47 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > I do not understand. Can you do an example of what you want? > > Without understanding I can see something is missing: > > > db.define_table('notebook', > > SQLField('name')) > > > db.define_table('entry', > > SQLField('title'), > > SQLField('notebook',db.notebook)) > > db.entry.notebook.requires=IS_IN_DB(db,'notebook.id','%(name)s') > > > def entries(): > > #return the notebook itself > > records=db(db.entry.notebook==request.vars.notebook)\ > > .select(orderby=~cdb.entry.id) > > # you do not need the select for the rest to work > > > form=SQLFORM(cynotedb.entry,fields=['notebook']) > > if form.accepts(request.vars,session): > session.flash='record inserted' > redirect(URL(r=request)) # or somewhere else > > > return dict(form=form, records=records) > > On Jan 28, 9:34 pm, MadWalker <maddalwal...@gmail.com> wrote: > > > is it able to do a joint table entries selection? > > by only selecting only those that i need but still having those > > database stored > > and not delete it away? > > > the table database and code are listed as > > > db.define_table('notebook', > > SQLField('name')) > > > db.define_table('entry', > > SQLField('title'), > > SQLField('notebook',db.notebook)) > > > def entries(): > > #return the notebook itself > > records=db(db.entry.notebook==request.vars.notebook)\ > > .select(orderby=~cdb.entry.id) > > form=SQLFORM(cynotedb.entry,fields=['notebook']) > > return dict(form=form, records=records) > > > if there are 3 notebook, instead of letting it list out the one that i > > dun want in the notebook itself, > > is it able to do a selection? > > but still letting the database itself be delete? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---