解决方法
控制器操作(即URL中显示的操作)必须是控制器文件中定义的功能(即,您无法将它们移动到模块中).但是,如果控制器中的某些功能不是操作,则可以将它们移动到模块中.假设您将从模型或控制器调用这些函数,您只需将db,me和now对象作为参数传递给这些函数.另一种选择是将它们添加到线程本地当前对象,可以从模块访问它.为此:
在模型中:
from globals import current current.app.db = db # etc.@H_404_13@在一个模块中:
from globals import current def func(*args): db=current.app.db # etc.@H_404_13@