Render a model result into `mimetype` format.
779068
def render(self, result, mimetype, errors=None):
        
        available_mimetypes = [x for x in self.render_map.keys() if '/' in x]
        render_func = None

        if '/' not in mimetype:
            # naked superformat (does not correspond to a mimetype)
            render_func = self.reject_map.get(mimetype, None)
            if not render_func:
                raise NoViewMethod("Unknown Superformat: %s" % mimetype)

        if not render_func and available_mimetypes:
            target_mimetype = mimeparse.best_match(available_mimetypes, mimetype)
            render_func = self.render_map.get(target_mimetype, None)

        if not render_func:
            raise NoViewMethod("%s not supported for this program" % mimetype)

        principle_mimetype = render_func.mimetypes[0]

        if GiottoControl in render_func.__class__.mro():
            # redirection defined as view (not wrapped in lambda)
            return {'body': render_func, 'persist': render_func.persist}

        if callable(self.persist):
            # persist (cookie data) can be either an object, or a callable)
            persist = self.persist(result)
        else:
            persist = self.persist

        # render functins can take either one or two arguments, both are
        # supported by the API
        arg_names = inspect.getargspec(render_func).args
        num_args = len(set(arg_names) - set(['self', 'cls']))
        if num_args == 2:
            data = render_func(result, errors or Mock())
        else:
            # if the renderer only has one argument, don't pass in the 2nd arg.
            data = render_func(result)

        if GiottoControl in data.__class__.mro():
            # render function returned a control object
            return {'body': data, 'persist': persist}

        if not hasattr(data, 'items'):
            # view returned string
            data = {'body': data, 'mimetype': principle_mimetype}
        else:
            # result is a dict in for form {body: XX, mimetype: xx}
            if not 'mimetype' in data and target_mimetype == '*/*':
                data['mimetype'] = ''

            if not 'mimetype' in data:
                data['mimetype'] = target_mimetype

        data['persist'] = persist
        return data
1192268
def RenderPayload(self, result, value):
    """"""
    if "args_rdf_name" in result:
      result["payload_type"] = result["args_rdf_name"]
      del result["args_rdf_name"]

    if "args" in result:
      result["payload"] = self._PassThrough(value.payload)
      del result["args"]

    return result
863297
def render(self):
        """"""
        if not self.validate():
            raise ValidationError

        self.process_request()
        self.clean()

        return self.response
562182
def jinja_template(template_name, name='data', mimetype="text/html"):
    
    def jinja_renderer(result, errors):
        template = get_jinja_template(template_name)
        context = {name: result or Mock(), 'errors': errors, 'enumerate': enumerate}
        rendered = template.render(**context)
        return {'body': rendered, 'mimetype': mimetype}
    return jinja_renderer
59946
def render(self, context, request=None):
        """"""
        context['component'] = self
        return render_to_string(self.template_name, context, request)
1200499
def render(template, extra={}, **kwargs):
    """"""
    context = hookenv.execution_environment()
    context.update(extra)
    context.update(kwargs)
    return template.format(**context)
786472
def generate_py():
    """"""
    model = {}

    vk = init()
    format_vk(vk)
    model_alias(vk, model)
    model_typedefs(vk, model)
    model_enums(vk, model)
    model_macros(vk, model)
    model_funcpointers(vk, model)
    model_exceptions(vk, model)
    model_constructors(vk, model)
    model_functions(vk, model)
    model_ext_functions(vk, model)

    env = jinja2.Environment(
        autoescape=False,
        trim_blocks=True,
        lstrip_blocks=True,
        loader=jinja2.FileSystemLoader(HERE)
    )

    out_file = path.join(HERE, path.pardir, 'vulkan', '_vulkan.py')
    with open(out_file, 'w') as out:
        out.write(env.get_template('vulkan.template.py').render(model=model))
946146
def JsonResponseModel(self):
        """"""
        old_model = self.response_type_model
        self.__response_type_model = 'json'
        yield
        self.__response_type_model = old_model
314630
def render(request, template_name, context=None, content_type=None, status=None, using=None, logs=None):
    
    if logs:
        obj_logger = ObjectLogger()
        if not isinstance(logs, list):
            logs = [logs, ]
        for log in logs:
            log = obj_logger.log_response(
                log,
                context,
                status=str(status),
                headers='',
                content_type=str(content_type))
            log.save()
    return django_render(
        request,
        template_name,
        context=context,
        content_type=content_type,
        status=status,
        using=using)
610087
def render_binary(self, context, result):
		""""""
		context.response.app_iter = iter((result, ))  # This wraps the binary string in a WSGI body iterable.
		return True
50083
def render_html(self):
        """"""
        return self._template.safe_substitute(
            report_type=self._report_type,
            results=self.render_json()
        )
211574
def process_result(result, model=None):
    
    if model is None:
        return result
    if isinstance(result, collections.Sequence):
        return [model(**item) for item in result]
    return model(**result)
892387
def rtype_to_model(rtype):
    

    models = goldman.config.MODELS
    for model in models:
        if rtype.lower() == model.RTYPE.lower():
            return model
    raise ValueError('%s resource type not registered' % rtype)
894950
def render(file):
    """"""
    with file.open() as fp:
        encoding = detect_encoding(fp, default='utf-8')
        result = mistune.markdown(fp.read().decode(encoding))
        return result
584050
def render_template(self):
        """"""
        self.import_mappings()
        self.create_template()
        if self.description:
            self.set_template_description(self.description)
        self.setup_parameters()
        rendered = self.template.to_json(indent=self.context.template_indent)
        version = hashlib.md5(rendered.encode()).hexdigest()[:8]
        return (version, rendered)
1236924
def render(self):
        """"""
        template = self.get_template()
        return template.render(
            messages=self._messages,
            metrics=self.metrics,
            report=self)
327743
def json_to_model(self, model_name, j, validate=False):
        """"""
        if validate:
            self.api_spec.validate(model_name, j)
        return self.api_spec.json_to_model(model_name, j)