示例#1
0
    def add_template(ctx, tmpl):
        """
            Add template and a type and typeattrs.
        """
        tmpl_i = template.add_template(tmpl, **ctx.in_header.__dict__)

        return Template(tmpl_i)
示例#2
0
 def update_template(ctx, tmpl):
     """
         Update template and a type and typeattrs.
     """
     tmpl_i = template.update_template(tmpl,
                                        **ctx.in_header.__dict__)
     return Template(tmpl_i)
示例#3
0
    def get_template(ctx, template_id):
        """
            Get a specific resource template template, either by ID or name.
        """
        tmpl_i = template.get_template(template_id, **ctx.in_header.__dict__)
        tmpl = Template(tmpl_i)

        return tmpl
示例#4
0
    def get_templates(ctx):
        """
            Get all resource template templates.
        """
        tmpls = template.get_templates(**ctx.in_header.__dict__)
        ret_templates = [Template(t) for t in tmpls]

        return ret_templates
示例#5
0
    def upload_template_xml(ctx, template_xml):
        """
            Add the template, type and typeattrs described
            in an XML file.

            Delete type, typeattr entries in the DB that are not in the XML file
            The assumption is that they have been deleted and are no longer required.
        """
        tmpl_i = template.upload_template_xml(template_xml,
                                              **ctx.in_header.__dict__)

        return Template(tmpl_i)
示例#6
0
    def get_template_by_name(ctx, template_name):
        """
            Get a specific resource template, either by ID or name.
        """
        tmpl_i = template.get_template_by_name(template_name,
                                               **ctx.in_header.__dict__)
        if tmpl_i is not None:
            tmpl = Template(tmpl_i)

            return tmpl
        else:
            return None