Pergunta

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
Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top