コード例 #1
0
ファイル: app.py プロジェクト: hyphyphyph/lascaux
 def __init__(self):
     self.self = self
     self.manager = new_manager()
     self.manager.setup()
     logger.info("Initialized main app instance %s" % id(self))
     self.manager.execute('pre_app_init', app=self)
     self.manager.execute('app_init', app=self)
コード例 #2
0
ファイル: reqres.py プロジェクト: hyphyphyph/lascaux
 def close(self):
     self._close_time = time.time()
     logger.info(u'%s milliseconds' % ((self._close_time -
                                        self._init_time) * 1000))
     self.session.save()
     # self.cookies.bake()
     if config['debug']:
         for header in self.headers:
             self.save(u'%s %s' % (header, self.headers[header]), 'debug')
         self.save(u'Request time: %s milliseconds' % ((self._close_time - self._init_time) * 1000),
                   'debug')
コード例 #3
0
ファイル: plugin.py プロジェクト: hyphyphyph/lascaux
 def load_controller_modules(self, app=None):
     for plugin in self.plugins:
         for route in plugin.config['routes'].values():
             dotpath = self.get_dotpath(os.path.join(plugin.config['package_dir'], 
                                        route['controller'].split(':')[0]))
             module = __import__(dotpath)
             for sym in dotpath.split('.')[1:]:
                 module = getattr(module, sym)
             class_ = getattr(module, route['controller'].split(':')[1])
             class_.plugin = plugin
             plugin.controllers[route['controller']] = class_
             logger.info("Loaded plugin module for `%s` from '%s'" % (route['controller'], os.path.abspath(module.__file__)))
コード例 #4
0
ファイル: server.py プロジェクト: hyphyphyph/lascaux
 def serve_static(self, reqres):
     reqres.force_plain_content = True
     reqres.erase_content()
     if not reqres.static_path:
         reqres.static_path = self.get_static_path(reqres.uri)
     if not reqres.static_path:
         reqres.error = "404"
         self.serve_error(reqres)
     reqres.headers["Content-type"] = mimetypes.guess_type(reqres.static_path)[0]
     file_ = open(reqres.static_path, "r")
     content = file_.read()
     file_.close()
     reqres.save(content)
     logger.info("serving static file %s -> %s" % (reqres.uri, reqres.static_path))
     return reqres
コード例 #5
0
ファイル: plugin.py プロジェクト: hyphyphyph/lascaux
 def find_plugins(self, app=None):
     for app_package in config['app_packages']:
         package_dir = config[app_package]['package_dir']
         for plugin in glob.glob(os.path.join(package_dir, 'plugins', '*')):
             if not os.path.isdir(plugin):
                 continue
             plugin_name = os.path.basename(plugin)
             if not plugin_name in config[app_package]['plugins']:
                 continue
             plugin_config = config[app_package]['plugins'][plugin_name]
             plugin_config['package_dir'] = plugin
             plugin_config['routes'] = parse_config(os.path.join(plugin, plugin_config['routing']))
             if app:
                 self.plugins.append(Plugin(app=app.get_root(), 
                                            name=plugin_name,
                                            app_package=app_package,
                                            config=plugin_config))
             else:
                 self.plugins.append(Plugin(name=plugin_name, 
                                            app_package=app_package,
                                            config=plugin_config))
             logger.info("Found plugin `%s` in '%s'" % (plugin_name, plugin))
     return self.plugins
コード例 #6
0
ファイル: server.py プロジェクト: hyphyphyph/lascaux
 def start(self):
     logger.info(
         "started %s server on %s:%s  servering forever..."
         % (self.__class__, self.config["host"], self.config["port"])
     )