Thanks for pointing that out. The example in the book is wrong and has been wrong for a while. :-( I changed it into this:
def list_records(): REGEX = re.compile('^(\w+)\.(\w+)\.(\w+)\=\=(\d+)$') match = REGEX.match(request.vars.query) if not match: redirect(URL('error')) table, field, id = match.group(2), match.group(3), match.group(4) records = db(db[table][field]==id).select() return dict(records=records) On Friday, 14 September 2012 02:40:18 UTC-5, martzi wrote: > > Hi all : The below code snippet in web2py manual (p. 340), isn't resulting > to the expected output. > def list_records(): > table = request.args(0) #returns db > query = request.vars.query #db.dog.owner == 1 > records = db(query).select(db[table].ALL) # db("...") requires > "owner==1" as parameter > return dict(records=records) > > This seems to work: > > def list_records(): > table = request.args(1) > query = request.vars.query.split('.')[-1] > records = db(query).select(db[table].ALL) > return dict(records=records) > --