Render data for plugin and return text response.
514255
def post(self, request, ext):
        
        try:
            plugin = plugins.get(ext)
            data, meta = self.get_post_data(request)
            data = plugin.load(data)
        except UnknownPlugin:
            raise Http404
        else:
            content = plugin.render(data)
            return self.render_to_response(content)
1027919
def render_json(result, cfg, **kwargs):
    
    result = json.loads(result.decode('utf-8'))
    head = result['head']
    if 'results' not in result:
        if 'boolean' in result:
            r = u'Result: {}'.format(result['boolean'])
        else:
            r = u'Unsupported result: \n' + unicode(result)
        return {'data': {'text/plain': r},
                'metadata': {}}

    vars = head['vars']
    nrow = len(result['results']['bindings'])
    if cfg.dis == 'table':
        j = json_iterator(vars, result['results']['bindings'], set(cfg.lan),
                          add_vtype=cfg.typ)
        n, data = html_table(j, limit=cfg.lmt, withtype=cfg.typ)
        data += div('Total: {}, Shown: {}', nrow, n, css="tinfo")
        data = {'text/html': div(data)}
    else:
        result = json.dumps(result,
                            ensure_ascii=False, indent=2, sort_keys=True)
        data = {'text/plain': unicode(result)}

    return {'data': data,
            'metadata': {}}
414500
def render_to_response(self, obj, **response_kwargs):
        
        return HttpResponse(self.serialize(obj), content_type='application/json', **response_kwargs)
26829
def render(self, form=None, **kwargs):
        
        form = form or self.get_form()
        context = self.get_context_data(form, **kwargs)
        return self.render_to_response(context)
1076509
def render(self, context):
        """"""
        content = self.get_render_content(context)
        request = context.get('request')
        render_edit_tag = False
        if request and request.user.is_staff and request.COOKIES.get('enable_edit_mode'):
            render_edit_tag = True

        if not content:
            if not render_edit_tag:
                return ''
            return self.edit_tag()

        if self.parsed:
            content = self.render_parsed(context, content)

        if self.as_varname is None:
            if not render_edit_tag:
                return content
            return content + self.edit_tag()
        context[self.as_varname] = content
        return ''
381631
def render(self, data, div_id="chart", head=""):
        """"""
        if not self.is_valid_name(div_id):
            raise ValueError(
                "Name {} is invalid. Only letters, numbers, '_', and '-' are permitted ".format(
                    div_id))

        return Template(head + self.template).render(
            div_id=div_id.replace(" ", "_"),
            data=json.dumps(
                data, indent=4).replace("'", "\\'").replace('"', "'"))
943493
def _build_response(data, renderer=None):
    
    if isinstance(data, Response) or isinstance(data, BaseResponse):
        return data
    if not renderer:
        raise AttributeError(" Renderer is required")
    if isinstance(data, dict) or data is None:
        data = {} if data is None else data
        for _ in __view_parsers:
            data = _(data)
        return renderer(data), 200
    elif isinstance(data, tuple):
        data, status, headers = _normalize_response_tuple(data)
        for _ in __view_parsers:
            data = _(data)
        return renderer(data or {}), status, headers
    return data
787433
def render(obj):
    """"""
    def get_v(v):
        return v % env if isinstance(v, basestring) else v

    if isinstance(obj, types.StringType):
        return obj % env
    elif isinstance(obj, types.TupleType) or isinstance(obj, types.ListType):
        rv = []
        for v in obj:
            rv.append(get_v(v))
    elif isinstance(obj, types.DictType):
        rv = {}
        for k, v in obj.items():
            rv[k] = get_v(v)

    return rv
202244
def render(self, data, accepted_media_type=None, renderer_context=None):
        

        wrapper = None
        success = False

        for wrapper_name in self.wrappers:
            wrapper_method = getattr(self, wrapper_name)
            try:
                wrapper = wrapper_method(data, renderer_context)
            except WrapperNotApplicable:
                pass
            else:
                success = True
                break

        if not success:
            raise WrapperNotApplicable(
                'No acceptable wrappers found for response.',
                data=data, renderer_context=renderer_context)

        renderer_context["indent"] = 4

        return super(JsonApiMixin, self).render(
            data=wrapper,
            accepted_media_type=accepted_media_type,
            renderer_context=renderer_context)
622177
def _render(template, callable_, args, data, as_unicode=False):
    """"""

    if as_unicode:
        buf = util.FastEncodingBuffer(as_unicode=True)
    elif template.bytestring_passthrough:
        buf = compat.StringIO()
    else:
        buf = util.FastEncodingBuffer(
                        as_unicode=as_unicode,
                        encoding=template.output_encoding,
                        errors=template.encoding_errors)
    context = Context(buf, **data)
    context._outputting_as_unicode = as_unicode
    context._set_with_template(template)

    _render_context(template, callable_, context, *args,
                            **_kwargs_for_callable(callable_, data))
    return context._pop_buffer().getvalue()
59946
def render(self, context, request=None):
        """"""
        context['component'] = self
        return render_to_string(self.template_name, context, request)
923840
def render(self, context, db=None, safe_mode=False, extra_context=None):
        """"""
        if not db:
            raise MissingParameterError(
                "db",
                context=self.error_context
            )
        rendered_views = dict()
        path_instances = db.query(self.path.query, safe_mode=safe_mode)
        extra_ctx = copy(extra_context) if extra_context else dict()

        for inst in path_instances:
            extra_ctx.update({
                self.path.variable: inst
            })
            ctx = context.build(
                db=db,
                safe_mode=safe_mode,
                for_each_inst=inst,
                extra=extra_ctx
            )
            inst_path = self.path.render(inst=inst, context=ctx)
            rendered_view = self.template.render(ctx)
            rendered_views = deep_merge_dict(
                rendered_views,
                dict_from_path(inst_path, final_value=rendered_view)
            )
        return rendered_views
170777
def html(content, **kwargs):
    """"""
    if hasattr(content, 'read'):
        return content
    elif hasattr(content, 'render'):
        return content.render().encode('utf8')

    return str(content).encode('utf8')
259359
def render(self):
        """"""
        tpl = '<xml>\n{data}\n</xml>'
        nodes = []
        msg_type = '<MsgType><![CDATA[{msg_type}]]></MsgType>'.format(
            msg_type=self.type
        )
        nodes.append(msg_type)
        for name, field in self._fields.items():
            value = getattr(self, name, field.default)
            node_xml = field.to_xml(value)
            nodes.append(node_xml)
        data = '\n'.join(nodes)
        return tpl.format(data=data)
597004
def render(self, request, context, status=codes.ok, content_type=None,
            args=None, kwargs=None):
        ""

        if isinstance(self.template_name, (list, tuple)):
            template = loader.select_template(self.template_name)
        elif self.template_name:
            template = loader.get_template(self.template_name)
        else:
            template = loader.Template(self.template_string)

        context = RequestContext(request, context)
        content = template.render(context)

        return HttpResponse(content, status=status, content_type=content_type)
1177115
def render_to_response(self, context, **response_kwargs):
        
        # is this a select2 format response?
        if self.request.GET.get('_format', 'html') == 'select2':

            results = []
            for obj in context['object_list']:
                result = None
                if hasattr(obj, 'as_select2'):
                    result = obj.as_select2()

                if not result:
                    result = dict(id=obj.pk, text="%s" % obj)

                results.append(result)

            json_data = dict(results=results, err='nil', more=context['page_obj'].has_next())
            return JsonResponse(json_data)
        # otherwise, return normally
        else:
            return super(SmartListView, self).render_to_response(context)
423600
def hook_response(self, response):
        " "
        # Decode content with json.
        response._content = json.loads(response.content)
        return response