def load_controllers():
controllers = []
path = os.path.split(__file__)[0]
for fname in os.listdir(path):
mod, ext = os.path.splitext(fname)
fname = os.path.join(path, fname)
if os.path.isfile(fname) and ext == '.py' and not mod.startswith('_'):
try:
exec "import " + mod + " as controller"
except:
import traceback
logger.error(traceback.format_exc())
for c in dir(controller):
cls = getattr(controller, c)
if not c.startswith('_') and isclass(cls) and issubclass(cls, Controller) and Controller != cls:
controllers.append(cls)
return controllers
评论列表
文章目录