Пример #1
0
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))
Пример #2
0
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()
Пример #3
0
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())
Пример #4
0
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)