Frage

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
War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top