[web2py] Help me understand how to create a search

2013-12-23 Thread Keith Planer
I'm new to web2py, and Python. I created a database, and I want to create a 
page where I can return records from a table of people, using their first 
and last names as search terms. What I have so far is:

def patient_lookup():

#form = SQLFORM.grid(db.consumer, deletable = True)

   form=SQLFORM.factory(
 Field('Lname', requires=IS_IN_SET(consumer)),
 Field('Fname', requires=IS_IN_SET(consumer)),
 submit_button=Search)
if form.accepts(request.vars, session):
consumer=db.consumer(id).select()
return dict(form=form)


My error:


Traceback (most recent call last):
  File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, in 
restricted
  File C:/web2py_src/web2py/applications/facesheet/controllers/default.py, 
line 64, in module
  File /home/mdipierro/make_web2py/web2py/gluon/globals.py, line 372, in 
lambda
  File C:/web2py_src/web2py/applications/facesheet/controllers/default.py, 
line 38, in patient_lookup
Field('Lname', requires=IS_IN_SET(consumer)),
UnboundLocalError: local variable 'consumer' referenced before assignment



-- 
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/groups/opt_out.


Re: [web2py] Help me understand how to create a search

2013-12-23 Thread Marco Mansilla
El Mon, 23 Dec 2013 13:08:20 -0800 (PST)
Keith Planer kwplan...@gmail.com escribió:

 I'm new to web2py, and Python. I created a database, and I want to
 create a page where I can return records from a table of people,
 using their first and last names as search terms. What I have so far
 is:
 
 def patient_lookup():
 
 #form = SQLFORM.grid(db.consumer, deletable = True)
 
form=SQLFORM.factory(
  Field('Lname', requires=IS_IN_SET(consumer)),
  Field('Fname', requires=IS_IN_SET(consumer)),
  submit_button=Search)
 if form.accepts(request.vars, session):
 consumer=db.consumer(id).select()
 return dict(form=form)
 
 
 My error:
 
 
 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line
 217, in restricted File
 C:/web2py_src/web2py/applications/facesheet/controllers/default.py,
 line 64, in module File
 /home/mdipierro/make_web2py/web2py/gluon/globals.py, line 372, in
 lambda File
 C:/web2py_src/web2py/applications/facesheet/controllers/default.py,
 line 38, in patient_lookup Field('Lname',
 requires=IS_IN_SET(consumer)), UnboundLocalError: local variable
 'consumer' referenced before assignment
 
 
 

Would you please show your model file?... it seems that consumer table
isn't created yet... is this right?

-- 
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/groups/opt_out.