I'm just guessing cause your model isn't entirely clear.... book_set = db(db.book.editor == auth.user_id)
articles = db(db.article.writer == auth.user_id)(~db.article.book.belongs(book_set._select(db.book.id))) books = book_set.select() http://web2py.com/books/default/chapter/29/06?search=belongs#belongs On Monday, March 4, 2013 3:42:38 PM UTC+1, Kenneth wrote: > > Hi, > > I have a feeling this is quite easy to do but can't find an elegant way of > doing it. > > I'm building a book application for an client, the book has chapters and > articels in it. Every book has an editor and every articel has a writer and > cowriter. There will be maybe 20 books. Every editor and writer will be > inserted into auth_user and will have permission to edit their own > articels, so that the editor can edit all articels in his/hers book. > > Now I'd like to find all articels "belonging" to a person either via > direct "ownership" of articels or via bookownership. > > I can find all books belonging to the person and then all articels that > way. But finding all other articels will also contain all articels in > bookownership. > > books = db(t.book.f_editor = auth.user['id']).select() > > articels = db(t.article.f_writer = auth.user['id']) & (t.articel.f_book == > not in books).select() > > How is this written in DAL? > > > Kenneth > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

