I am trying to use web2py to build an app. I have a simple print function 
that a user submits a key word . The string or int key word is directed to 
an sqlite db to retrieve a row and output the data. I need to know 1. how 
to use the print on html. 2. How to split the string...so far i did the 
list:string

Here is my code:

def first():
    form = SQLFORM.factory(Field('visitor_name',
                                 label = 'Please Type Your keyword here!',
                                 requires= [IS_NOT_EMPTY(), 
IS_LOWER(),'list:string']))
    form.element('input[type=submit]')['_onclick'] = "return \
    confirm('Are you sure you want to submit:');"
    if form.process().accepted:
        session.visitor_name = form.vars.visitor_name        
        redirect(URL('main'))
    return dict(form=form)

def main():    
    while True:
        name = request.vars.visitor_name or redirect(URL('first'))          
        name2 = name[:]        
        for item in name2:break
        name3 = ' '.join(name2)
        import sqlite3
        id = 0
        location = ""
        conn = sqlite3.connect("keywords.db")
        c = conn.cursor()
        c.execute('select * from kmedicals')
        records = c.fetchall()
        for record in records:
            id = record[0]
            location = record[15]
            if id == name3:
                print name3.capitalize(),':' '\n',location
                break
                sys.exit()
        return dict(name=name)

my view...default/main.html:

{{extend 'layout.html'}}{{=name}}

-- 
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.

Reply via email to