def all(): """get all model objects from 'core' and 'models' folders""" import os, common common.update_path() dr = common.directory_root() ml = find_models(os.path.join(dr, 'models'), 'models') ml += find_models(os.path.join(dr, 'lib/py/core'), 'core') return filter(lambda x: x, ml)
def main(module='__main__'): """run methods on main class""" cgitb.enable() import common common.update_path() global req req = Request() import database if req.method in ('post', 'delete'): req.db.begin() if isinstance(module, basestring): moduleobj = __import__(module) if hasattr(moduleobj, req.method): try: ret = getattr(moduleobj, req.method)(**req.form) if ret: req.out.update(ret) except Exception, e: req.out['traceback'] = get_traceback() req.out['error'] = str(e.args[0])