New to web2py. What I am doing should be very simple, but can not get it to work.
I have a simple search form: def search_form(): results=None headers=['Jira Id', 'Customer Name', 'Device Type', 'Serial Number', 'Driver Version', 'Firmware Version', 'Sector Size', 'Free LEBs', 'Bytes Read', 'Bytes Written', 'OS'] form=FORM(TABLE(TR("Search By Jira Id",INPUT(_type="text",_name="jira_id", default=None)), TR("Search By Customer Name",INPUT(_type="text",_name="customer_name", default=None)), TR("Search By Device Type",INPUT(_type="text",_name="device_type", default=None)), TR("",INPUT(_type="submit",_value="SUBMIT")))) if form.accepts(request,session): response.flash="form accepted" if form.vars: jira_id = request.vars.jira_id customer_name = request.vars.customer_name device_type = request.vars.device_type query = ((db.bugreport.id == db.iomemory.bug_report) & (db.iomemory.bug_report == db.system.bug_report) & (db.bugreport.id == db.system.bug_report)) if jira_id: query &= db.bugreport.jira_id == jira_id if customer_name: query &= db.bugreport.customer_name == customer_name if device_type: query &= db.iomemory.device_type == device_type try: results = db(query).select(db.bugreport.jira_id, db.bugreport.customer_name, db.iomemory.device_type, db.iomemory.serial_number, db.iomemory.driver_version, db.iomemory.firmware_version, db.iomemory.sector_size, db.iomemory.free_lebs, db.iomemory.bytes_read, db.iomemory.bytes_written, db.system.os, db.system.kernel_version, db.system.cpu_info, db.system.mem_info, db.system.num_cpus, db.system.raid_type, db.system.filesystem) except Exception, e: redirect(URL('error', vars=dict(e=e))) return dict(form=form, results=results) And this works OK, but I don't want the results to show up on the same form page. I want it to display on a 'results' page. I tried to put the db query in another function and called it like this from the form: def search_form(): #headers=['Jira Id', 'Customer Name', 'Device Type', 'Serial Number', 'Driver Version', 'Firmware Version', 'Sector Size', 'Free LEBs', 'Bytes Read', 'Bytes Written', 'OS'] form=FORM(TABLE(TR("Search By Jira Id",INPUT(_type="text",_name="jira_id", default=None)), TR("Search By Customer Name",INPUT(_type="text",_name="customer_name", default=None)), TR("Search By Device Type",INPUT(_type="text",_name="device_type", default=None)), TR("",INPUT(_type="submit",_value="SUBMIT")))) if form.accepts(request,session): response.flash="form accepted" if form.vars: jira_id = request.vars.jira_id customer_name = request.vars.customer_name device_type = request.vars.device_type search_results(jira_id, customer_name, device_type) *******HERE******** elif form.errors: response.flash="form is invalid" else: response.flash="please fill in the form" return dict(form=form) and def search_results(jira_id, customer_name, device_type): query = ((db.bugreport.id == db.iomemory.bug_report) & (db.iomemory.bug_report == db.system.bug_report) & (db.bugreport.id == db.system.bug_report)) if jira_id: query &= db.bugreport.jira_id == jira_id if customer_name: query &= db.bugreport.customer_name == customer_name if device_type: query &= db.iomemory.device_type == device_type results = None results = db(query).select(db.bugreport.jira_id, db.bugreport.customer_name, db.iomemory.device_type, db.iomemory.serial_number, db.iomemory.driver_version, db.iomemory.firmware_version, db.iomemory.sector_size, db.iomemory.free_lebs, db.iomemory.bytes_read, db.iomemory.bytes_written, db.system.os, db.system.kernel_version, db.system.cpu_info, db.system.mem_info, db.system.num_cpus, db.system.raid_type, db.system.filesystem) redirect(URL('search', var = dict(results=results)) But I can't get the redirect or a return to work. What is the best way to do this? Can I just return the results data and have the 'search.html' display it or is a redirect what I want? I can't seem to find a simple example of displaying the query data on a different page. I know this has to be simple, but since I am new I just don't get it. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.