New recent nuance on this. Is there any way to avoid the conditional 
phrasing in function add_new_anything below?  

The problem is there is a user prompt in select_country_manually function 
that is called called from add_new_anything. The _href in 
select_country_manually requires a controller to go to in order to capture 
the correct country and then exit.  Then I have to build conditionals to 
let the script pickup where it left off in add_new_anything.

Is this the only way to write this? It is anticipated that 
select_country_manually will be called from many different functions.

thanks

Alex Glaros

def add_new_anything():
    populating_address_type = str(request.get_vars.populating_address_type)
    session.populating_address_type = populating_address_type
    session.countryID = request.get_vars.countryID
    if not session.countryID:
        redirect(URL('default', 'select_country_manually', vars = 
dict(controller_to_return_to 
= 'add_new_anything')))
    response.title = session.countryID
    return locals()


@auth.requires_login()
def select_country_manually():
    controller_to_return_to = request.get_vars.controller_to_return_to
    session.countryID = None
    session.country_name = None
    db.Country.country_name.represent = lambda v, r: A(v, _href = URL(
'default', controller_to_return_to, vars = dict(countryID = r.id))) 
    grid = SQLFORM.grid(db.Country, editable = False, deletable = False, 
create = False,  details = False, maxtextlength = {'Country.country_name':
'140'}, paginate = 300, fields = [db.Country.id, db.Country.country_name, db
.Country.country_code]) 
    response.title = T('Select country')
    return locals()

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