Using a session on the application in computer the one i haven't uploaded online works very well, it gives me the results i want but when i make similar updates to my online application i get an error message: *<type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'id'* I dont know what the problem is! Am i missing something?? Should i make a session declaration of some sort or is there an import i am not making???!
I have highlited where i used the session in the code below. *CONTROLLERS* def companies(): * session.resultsARE=db.services(request.args(0))* </> rslts=db(db.business.services==session.resultsARE.id).select(db.business .ALL, orderby=db.business.company_name) services=len(rslts) form=SQLFORM.factory(Field('query', requires=IS_NOT_EMPTY(), label=SPAN( '', _style="font-weight: bold;"), widget = lambda field, value: SQLFORM. widgets.string.widget(field, value, _class='my-string', _id='searching', _placeholder='LOCATION'))) #hiding the submit button searchBtn=form.element('input',_type='submit') searchBtn['_style'] = 'display:none;' if form.accepts(request): tokens=form.vars.query.split() query=reduce(lambda a,b:a&b, [db.locations.name.contains(k) for k in tokens]) location=db(query).select(orderby=db.locations.name) else: location=[] return locals() def Results(): results=db.locations(request.args(0)) #GET LOCATION & SERVICES FOR RESULTS * rslts=db((db.business.place==results.id) & (db.business.services==session.resultsARE.id)).select()* #rslts=db(db.business.place==results.id).select(db.business.services==serv) services=len(rslts) form=SQLFORM.factory(Field('query', requires=IS_NOT_EMPTY(), label=SPAN( '', _style="font-weight: bold;"), widget = lambda field, value: SQLFORM. widgets.string.widget(field, value, _class='my-string', _id='searching', _placeholder='LOCATION'))) #hiding the submit button searchBtn=form.element('input',_type='submit') searchBtn['_style'] = 'display:none;' if form.accepts(request): tokens=form.vars.query.split() query=reduce(lambda a,b:a&b, [db.locations.name.contains(k) for k in tokens]) location=db(query).select(orderby=db.locations.name) else: location=[] return locals() Mostwanted On Wednesday, March 27, 2019 at 9:17:34 PM UTC+2, Ben Duncan wrote: > > Could you not use: > > *session.resultsARE= ........* > *to save it an reuse it and pass during the whole session ?* > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > > On Wed, Mar 27, 2019 at 1:42 PM Anthony <abas...@gmail.com <javascript:>> > wrote: > >> It's not quite clear what you mean. Are these two functions two separate >> controller actions? If so, it's not clear how you can share that variable, >> as it is defined based on request.args(0) in the first function, but >> presumably request.args(0) has a different meaning in the context of the >> second function. What are you really trying to do? >> >> On Wednesday, March 27, 2019 at 8:11:15 AM UTC-4, mostwanted wrote: >>> >>> I have 2 functions and i want to use the value of the variable returned >>> by one function in another function, how can i achieve this? >>> I want to use the value of *resultsARE *in *function1 *in the same way >>> in *function2 *as attempted in the highlighted lines below. >>> >>> *FUNCTION1* >>> def companies(): >>> *resultsARE=db.services(request.args(0))* >>> rslts=db(db.business.services==resultsARE.id).select(db.business.ALL >>> , orderby=db.business.company_name) >>> services=len(rslts) >>> return locals() >>> >>> *FUNCTION2* >>> def Results(): >>> results=db.locations(request.args(0)) >>> comps=companies() >>> for services in comps: >>> serv=services >>> rslts=db(db.business.place==results.id).select >>> *(db.business.services==resultsARE.id)* >>> services=len(rslts) >>> return locals() >>> Mostwanted >>> >>> -- >> 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 web...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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.