def render_widget(request, opts, css_out=None, js_out=None): plugin = plugin_registry.get(opts['type']) if plugin is None: return render_error(request, opts) ret = plugin['instance'].render(request, opts) if len(ret) == 1: # Simple string return ret else: template_file, data = ret #template = plugin['mod'].get_template(template_file) #print template, render_template(template, **data) template = loader.get_template(plugin['namespace']+'/'+template_file) return template.render(RequestContext(request, data))
def gather_requests(): log = gather_requests.get_logger() now = datetime.datetime.now() for gather in GatherRequest.objects.all().for_update(): log.debug('Running gather request for plugin %s', gather.plugin) plugin = plugin_registry.get(gather.plugin) if plugin is None: log.warning('Plugin %s not found', gather.plugin) continue if gather.args is None: args = [] kwargs = {} elif isinstance(gather.args, list): args = gather.args kwargs = {} else: args = () kwargs = gather.args gather_request.apply_async(args=[gather.plugin, gather.user_id, args, kwargs]) # Reshedule? if now >= gather.until: gather.delete()
def plugin_tick(frequency, plugin_name): plugin = plugin_registry.get(plugin_name) with transaction.commit_on_success(): getattr(plugin['instance'], 'tick_%s'%frequency)(plugin_tick.get_logger())
def gather_request(plugin_name, user, args, kwargs): plugin = plugin_registry.get(plugin_name) if user: kwargs['user'] = User.objects.get(id=user) with transaction.commit_on_success(): plugin['instance'].gather(*args, **kwargs)