It seems I was wrong. This is not possible but not diffciult to implement. Give me a couple of days.
On Nov 10, 10:15 am, Frederik Wagner <fner...@googlemail.com> wrote: > thanks for the fast reply, but it does not work for me > > > > On Tue, Nov 10, 2009 at 3:45 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Yes you can do it with a bit of extra work: > > > db.define_table('person',Field('name')) > > db.define_table('dog',Field('name'),Field('owner',db.person)) > > db.define_table('walk',Field('dog',db.dog),Field('when','datetime')) > > > db.dog.owner.requires = IS_IN_DB(db,'person.id','%(name)s') > > class ComputedDogAttributes: > > def owner_name(dog): return dog.owner.name > > db.dog.virtualfields.append(ComputedDogAttributes()) > > db.walk.dog.requires = IS_IN_DB(db,'dog.id','%(name)s by %(owner_name) > > s') > > > Actually I have not tried it. If you do please let us know. > > trying to insert a walk (after inserting a person and a walk), gives > > Traceback (most recent call last): > File "/root/web2py/gluon/restricted.py", line 184, in restricted > exec ccode in environment > File "/root/web2py/applications/test/controllers/appadmin.py", line > 304, in <module> > File "/root/web2py/gluon/globals.py", line 103, in <lambda> > self._caller = lambda f: f() > File "/root/web2py/applications/test/controllers/appadmin.py", line > 123, in insert > form = SQLFORM(db[table], ignore_rw=ignore_rw) > File "/root/web2py/gluon/sqlhtml.py", line 613, in __init__ > inp = self.widgets.options.widget(field, default) > File "/root/web2py/gluon/sqlhtml.py", line 199, in widget > options = requires0.options() > File "/root/web2py/gluon/validators.py", line 346, in options > self.build_set() > File "/root/web2py/gluon/validators.py", line 333, in build_set > records = self.dbset.select(*self.fields, **dd) > File "/root/web2py/gluon/sql.py", line 2901, in select > rows = response(query) > File "/root/web2py/gluon/sql.py", line 2896, in response > db._execute(query) > File "/root/web2py/gluon/sql.py", line 846, in <lambda> > self._execute = lambda *a, **b: self._cursor.execute(*a, **b) > OperationalError: no such column: dog.owner_name > > Actually, why is it not possible to do a > db.walk.dog.requires = IS_IN_DB(db,'dog.id','%(name)s by %(owner.name)s') > directly? > > probably I'm missing some python knowledge. > > Thanks > Frederik > > > > > On Nov 10, 4:35 am, Frederik Wagner <fner...@googlemail.com> wrote: > >> Hi .*, > > >> is there a possibility in the Validator IS_IN_DB to have the display > >> string show attributes from multiple (joined) tables? > >> E.g.: If I say somthing like > > >> IS_IN_DB( db( (table1.id == table2.id_table1) , 'table1.id', > >> '%(table1.attribute)s %(table2.attribute)s') > > >> It tried somthing like this, but the problem is, that the placeholder > >> are always assumed to be attributes of the table used in the second > >> parameterfield, here 'table1'. Such that the used attributes are > >> 'table1.table1.attribute' and 'table1.table2.attribute', which is > >> clearly an error. > > >> I hope I could make the problem clear? > > >> Thanks a lot for help. > >> Bye! > >> Frederik --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" 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 -~----------~----~----~----~------~----~------~--~---