def load_second_plugins(*args): log.msg("Loading plugins with priority > 10") load_plugin_file(get_plugin_file(), min_priority=9) load_plugin_file(get_builtin_plugin_file(), get_builtin_failover_file(), min_priority=9) run_hook("on_plugins_loaded")
def on_error_rendering(self, request, f): frames = f.stack[-5:] + f.frames traceback = [] for fn, filename, line_no, loc, glob in frames: traceback.append({ "fn" : fn, "filename" : filename, "line_no" : line_no, "preview" : get_code_preview(filename, line_no) }) ctx = { "failure" : f, "traceback" : traceback, "error" : "%s.%s : %s" % (f.type.__module__, f.type.__name__, f.value) } t = yield plugin.run_hook("on_render_jinja2_template", request, "gyro.development/500.html", ctx) if not t: #Our 500 page didn't get rendered log.msg("Error rendering 500 template") t = "<html><body><pre>%s</pre></body></html>" % (f.getTraceback(), ) request.set_response_code(500) request.set_header("content-type", "text/html") request.write(t.encode("utf-8")) request.finish() defer.returnValue(request)
def run_hook(cls, name, *args, **kwargs): """ Run hook in all plugins containing the specified 'hook' """ log.msg("Run hook '%s'" % (name, )) try: hooks = cls._hooks[name] except KeyError, e: d = core.Deferred() d.callback(None) return d
def load_start_plugins(): log.msg("Loading plugins with priority < 10") load_plugin_file(get_plugin_file(), min_priority=-1, max_priority=10) load_plugin_file(get_builtin_plugin_file(), get_builtin_failover_file(), min_priority=-1, max_priority=10)