Question

I have an application in web2py. I have two controllers in it. Now I want to call a method written in one controller from other controller. How do I do that.

Example - In controller 1:

def controller1method():
    return 'something'

In controller 2:

def controller2method():
    # how do I call controller1method here
Was it helpful?

Solution

Don't do it that way. Instead, abstract whatever is common to controller1method and controller2method into a separate function, and put that function in a model file (which will make it accessible in either controller) or a module (and import where needed).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top