On Wednesday, June 1, 2016 at 11:33:47 AM UTC-7, Maurice Waka wrote:
>
> Thanks Anthony. 
> Am trying to import modules to the controller then run the functions 
> imported from a list (r_lst). From here the several functions will print 
> out different messages to view depending on user input.
>

I'm not sure that I understand.  Do you mean the user input results in a 
request to 
//mydomain.com/myapplication/mycontroller/myfunction?arg1&arg2    
and that you're supposed to do different things according to the values of 
arg1 and arg2?  If that's the case, myfunction() should probably just use 
regular if-statements.  The branches of the if-statement can invoke 
imported functions in the normal python way

import datetime
def myfunction():
   if "snooze" in request.args[0]:
      result = "Please rest until %s" % (request.now.timedelta(minutes=10).
isoformat())
   return dict(result = result)


If you want the print actions to happen without sending an [additional] 
request to the server, that's a different story.  Note that you normally 
can't run Python code in the browser, so returning Python to the browser 
doesn't have much value.  You need to have Javascript functions in place of 
the Python functions.  Python *does* run in the view, but that happens on 
the server, and can't respond to user input until that input is turned into 
a request.

If you mean something else, then you'll have to try again to explain what 
you want to do.

Dave
/dps



-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to