in your particular example, i often define a field like: Field('client_code', 'string', required=True, requires=IS_IN_DB(db, 'client.code', '%(code)s'))
that does the lookup for the dropdown, but stores the string in the new table. if you will be doing this lots of times then you should cache the lookup in memcache. your technique is ready for memcache, but i think has a typo (that i don't fully understand why it works on sqllite): payment_methods=[p.name for p in db(id>0).select(db.payment_method.name)] db.receipt.paid_by.requires = IS_IN_SET(payment_methods) should be: payment_methods=[p.name for p in db(db.payment_method.id>0).select( db.payment_method.name)] db.receipt.paid_by.requires = IS_IN_SET(payment_methods) cfh On Wednesday, November 28, 2012 11:01:12 PM UTC-8, Andy W wrote: > > Can anybody expand on 13.5 of the Web2py Manual on how best to adapt an > app to run on GAE? In particular, how to do away with linked tables. > > For example, I have a simple app that generates a cash receipt. The input > form displays a dropdown list for the user to select a payment method > (cash, credit card etc). The allowed payment methods are held in a second > table, so that users can adapt & extend them. > > Using sqlite this is simple to achieve with a linked table. For GAE, I am > assuming it is better to store the text value ("cash" or "credit card" etc) > as part of the receipt record, rather than storing the link, but how to > achieve this? > > I have tried reading the payment options in to a list and using this list > to define allowable entry values: > > payment_methods=[p.name for p in db(id>0).select(db.payment_method.name)] >> db.receipt.paid_by.requires = IS_IN_SET(payment_methods) > > > This works on sqlite, but on GAE gives the error: > > File "/Users/andy/www/web2py/gluon/dal.py", line 1414, in get_table >> raise RuntimeError, "No table selected" >> RuntimeError: No table selected > > > Any suggestions?? > --