문제

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
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top