Esempio n. 1
0
    def render(self, generate, session, logger, personality, archetype,
               pre_feature, post_feature, param_tmpl, **kwargs):
        dbpersonality = Personality.get_unique(session, archetype=archetype,
                                               name=personality, compel=True)

        if pre_feature:
            plenary = PlenaryPersonalityPreFeature.get_plenary(dbpersonality,
                                                               logger=logger)
        elif post_feature:
            plenary = PlenaryPersonalityPostFeature.get_plenary(dbpersonality,
                                                                logger=logger)
        elif param_tmpl:
            param_templates = get_parameters_by_tmpl(dbpersonality)

            if param_tmpl in param_templates.keys():
                values = param_templates[param_tmpl]
            else:
                values = {}

            ptmpl = ParameterTemplate(dbpersonality, param_tmpl, values)
            plenary = PlenaryPersonalityParameter(ptmpl, logger=logger)
        else:
            plenary = PlenaryPersonalityBase.get_plenary(dbpersonality,
                                                         logger=logger)

        if generate:
            return plenary._generate_content()
        else:
            return plenary.read()
Esempio n. 2
0
    def render(self, generate, session, logger, personality, archetype,
               pre_feature, post_feature, param_tmpl, **kwargs):
        dbpersonality = Personality.get_unique(session,
                                               archetype=archetype,
                                               name=personality,
                                               compel=True)

        plenary = PlenaryPersonalityBase(dbpersonality, logger=logger)
        if pre_feature:
            plenary = PlenaryPersonalityPreFeature(dbpersonality,
                                                   logger=logger)

        if post_feature:
            plenary = PlenaryPersonalityPostFeature(dbpersonality,
                                                    logger=logger)

        if param_tmpl:
            param_templates = get_parameters_by_tmpl(dbpersonality)
            if param_tmpl in param_templates.keys():
                plenary = PlenaryPersonalityParameter(
                    dbpersonality,
                    param_tmpl,
                    param_templates[param_tmpl],
                    logger=logger)
            else:
                raise NotFoundException("No parameter template %s%s found." %
                                        (param_tmpl, TEMPLATE_EXTENSION))

        lines = []
        if generate:
            lines.append(plenary._generate_content())
        else:
            lines.append(plenary.read())

        return lines
Esempio n. 3
0
    def render(self, generate, session, logger, personality, archetype,
               pre_feature, post_feature, param_tmpl, **kwargs):
        dbpersonality = Personality.get_unique(session, archetype=archetype,
                                               name=personality, compel=True)

        plenary = PlenaryPersonalityBase(dbpersonality, logger=logger)
        if pre_feature:
            plenary = PlenaryPersonalityPreFeature(dbpersonality, logger=logger)

        if post_feature:
            plenary = PlenaryPersonalityPostFeature(dbpersonality, logger=logger)

        if param_tmpl:
            param_templates = get_parameters_by_tmpl(dbpersonality)
            if param_tmpl in param_templates.keys():
                plenary = PlenaryPersonalityParameter(dbpersonality, param_tmpl,
                                                      param_templates[param_tmpl],
                                                      logger=logger)
            else:
                raise NotFoundException("No parameter template %s%s found." %
                                        (param_tmpl, TEMPLATE_EXTENSION))

        lines = []
        if generate:
            lines.append(plenary._generate_content())
        else:
            lines.append(plenary.read())

        return lines