def render(self, session, archetype, template, path, value_type, required,
               rebuild_required, default, description, **kwargs):
        dbarchetype = Archetype.get_unique(session, archetype, compel=True)
        if not dbarchetype.is_compileable:
            raise ArgumentError("{0} is not compileable.".format(dbarchetype))

        if not dbarchetype.paramdef_holder:
            dbarchetype.paramdef_holder = ArchetypeParamDef()


        ## strip slash from path start and end
        if path.startswith("/"):
            path = path[1:]
        if path.endswith("/"):
            path = path[:-1]

        validate_param_definition(path, value_type, default)

        ParamDefinition.get_unique(session, path=path,
                                   holder=dbarchetype.paramdef_holder, preclude=True)

        db_paramdef = ParamDefinition(path=path,
                                      holder=dbarchetype.paramdef_holder,
                                      value_type=value_type, default=default,
                                      required=required, template=template,
                                      rebuild_required=rebuild_required,
                                      description=description)
        session.add(db_paramdef)

        session.flush()

        return
Beispiel #2
0
    def render(self, session, feature, type, path, value_type, required,
               rebuild_required, default, description, **kwargs):
        dbfeature = Feature.get_unique(session, name=feature, feature_type=type,
                                       compel=True)

        if not dbfeature.paramdef_holder:
            dbfeature.paramdef_holder = FeatureParamDef()

        ## strip slash from path start and end
        if path.startswith("/"):
            path = path[1:]
        if path.endswith("/"):
            path = path[:-1]

        validate_param_definition(path, value_type, default)

        ParamDefinition.get_unique(session, path=path,
                                   holder=dbfeature.paramdef_holder, preclude=True)

        db_paramdef = ParamDefinition(path=path,
                                      holder=dbfeature.paramdef_holder,
                                      value_type=value_type, default=default,
                                      required=required,
                                      rebuild_required=rebuild_required,
                                      description=description)
        session.add(db_paramdef)

        session.flush()

        return
Beispiel #3
0
    def render(self, session, archetype, template, path, value_type, required,
               rebuild_required, default, description, **kwargs):
        dbarchetype = Archetype.get_unique(session, archetype, compel=True)
        if not dbarchetype.is_compileable:
            raise ArgumentError("{0} is not compileable.".format(dbarchetype))

        if not dbarchetype.paramdef_holder:
            dbarchetype.paramdef_holder = ArchetypeParamDef()

        ## strip slash from path start and end
        if path.startswith("/"):
            path = path[1:]
        if path.endswith("/"):
            path = path[:-1]

        validate_param_definition(path, value_type, default)

        ParamDefinition.get_unique(session,
                                   path=path,
                                   holder=dbarchetype.paramdef_holder,
                                   preclude=True)

        db_paramdef = ParamDefinition(path=path,
                                      holder=dbarchetype.paramdef_holder,
                                      value_type=value_type,
                                      default=default,
                                      required=required,
                                      template=template,
                                      rebuild_required=rebuild_required,
                                      description=description)
        session.add(db_paramdef)

        session.flush()

        return
    def render(self, session, feature, type, path, required,
               rebuild_required, default, description, **kwargs):
        dbfeature = Feature.get_unique(session, name=feature, feature_type=type,
                                       compel=True)

        if not dbfeature.paramdef_holder:
            dbfeature.paramdef_holder = FeatureParamDef()

        db_paramdef = ParamDefinition.get_unique(session, path=path,
                                                 holder=dbfeature.paramdef_holder,
                                                 compel=True)

        if default:
            validate_param_definition(db_paramdef.path, db_paramdef.value_type,
                                      default)
            db_paramdef.default = default

        if required is not None:
            db_paramdef.required = required
        if rebuild_required is not None:
            db_paramdef.rebuild_required = rebuild_required
        if description:
            db_paramdef.description = description

        session.flush()

        return
Beispiel #5
0
    def render(self, session, archetype, path, required,
               rebuild_required, default, description, **kwargs):
        dbarchetype = Archetype.get_unique(session, archetype, compel=True)
        if not dbarchetype.is_compileable:
            raise ArgumentError("{0} is not compileable.".format(dbarchetype))

        if not dbarchetype.paramdef_holder:
            dbarchetype.paramdef_holder = ArchetypeParamDef()


        db_paramdef = ParamDefinition.get_unique(session, path=path,
                                                 holder=dbarchetype.paramdef_holder,
                                                 compel=True)
        if default:
            validate_param_definition(db_paramdef.path,
                                      db_paramdef.value_type,
                                      default)
            db_paramdef.default = default

        if required is not None:
            db_paramdef.required = required
        if rebuild_required is not None:
            db_paramdef.rebuild_required = rebuild_required
        if description:
            db_paramdef.description = description

        session.flush()

        return
Beispiel #6
0
    def render(self, session, feature, type, path, required, rebuild_required,
               default, description, **kwargs):
        dbfeature = Feature.get_unique(session,
                                       name=feature,
                                       feature_type=type,
                                       compel=True)

        if not dbfeature.paramdef_holder:
            dbfeature.paramdef_holder = FeatureParamDef()

        db_paramdef = ParamDefinition.get_unique(
            session, path=path, holder=dbfeature.paramdef_holder, compel=True)

        if default:
            validate_param_definition(db_paramdef.path, db_paramdef.value_type,
                                      default)
            db_paramdef.default = default

        if required is not None:
            db_paramdef.required = required
        if rebuild_required is not None:
            db_paramdef.rebuild_required = rebuild_required
        if description:
            db_paramdef.description = description

        session.flush()

        return
    def render(self, session, feature, type, path, **kwargs):
        dbfeature = Feature.get_unique(session,
                                       name=feature,
                                       feature_type=type,
                                       compel=True)
        if not dbfeature.paramdef_holder:
            raise ArgumentError(
                "No parameter definitions found for {0:l}.".format(dbfeature))

        db_paramdef = ParamDefinition.get_unique(
            session, path=path, holder=dbfeature.paramdef_holder, compel=True)

        ## validate if this path is being used
        holder = search_path_in_personas(session, path,
                                         dbfeature.paramdef_holder)
        if holder:
            raise ArgumentError(
                "Parameter with path {0} used by following and cannot be deleted : "
                .format(path) + ", ".join([
                    "{0.holder_object:l}".format(h) for h in holder.iterkeys()
                ]))

        session.delete(db_paramdef)
        session.flush()

        return
Beispiel #8
0
def validate_param_definition(path, value_type, default=None):
    """
        Over here we are a bit restrictive then panc and do not allow
        underscores as path starters. So far we haven't needed those
        but this restriction can be relaxed in the future if needed.
        Suggestions were to validate each path component to validate
        against valid pan id but we are using regexp in certain cases
        as parameter paths i.e actions so this would not work.
    """

    if not path[0].isalpha():
        raise ArgumentError("Invalid path {0} specified, path cannot start with special characters".format(path))

    ParamDefinition.validate_type(value_type)

    if default:
        validate_value("default for path=%s" % path, value_type, default)

    return path
Beispiel #9
0
def validate_param_definition(path, value_type, default=None):
    """
        Over here we are a bit restrictive then panc and do not allow
        underscores as path starters. So far we haven't needed those
        but this restriction can be relaxed in the future if needed.
        Suggestions were to validate each path component to validate
        against valid pan id but we are using regexp in certain cases
        as parameter paths i.e actions so this would not work.
    """

    if not path[0].isalpha():
        raise ArgumentError(
            "Invalid path {0} specified, path cannot start with special characters"
            .format(path))

    ParamDefinition.validate_type(value_type)

    if default:
        validate_value("default for path=%s" % path, value_type, default)

    return path
Beispiel #10
0
    def render(self, session, archetype, path, **arguments):

        db_paramdef = None

        if archetype:
            dbarchetype = Archetype.get_unique(session, archetype, compel=True)
            if not dbarchetype.paramdef_holder:
                return
            db_paramdef = ParamDefinition.get_unique(session, path=path,
                                                     holder=dbarchetype.paramdef_holder,
                                                     compel=True)
        if not db_paramdef:
            return

        holder = search_path_in_personas(session, path, db_paramdef.holder)
        return SimpleParameterList(holder.iteritems())
Beispiel #11
0
    def render(self, session, archetype, path, **arguments):

        db_paramdef = None

        if archetype:
            dbarchetype = Archetype.get_unique(session, archetype, compel=True)
            if not dbarchetype.paramdef_holder:
                return
            db_paramdef = ParamDefinition.get_unique(
                session,
                path=path,
                holder=dbarchetype.paramdef_holder,
                compel=True)
        if not db_paramdef:
            return

        holder = search_path_in_personas(session, path, db_paramdef.holder)
        return SimpleParameterList(holder.iteritems())
    def render(self, session, archetype, path, **kwargs):
        dbarchetype = Archetype.get_unique(session, archetype, compel=True)
        if not dbarchetype.paramdef_holder:
            raise ArgumentError("No parameter definitions found for {0}."
                                .format(dbarchetype))

        db_paramdef = ParamDefinition.get_unique(session, path=path,
                                                 holder=dbarchetype.paramdef_holder,
                                                 compel=True)
        ## validate if this path is being used
        holder = search_path_in_personas(session, path, dbarchetype.paramdef_holder)
        if holder:
            raise ArgumentError("Parameter with path {0} used by following and cannot be deleted : ".format(path) +
                                ", ".join(["{0.holder_object:l}".format(h) for h in holder.iterkeys()]))

        session.delete(db_paramdef)
        session.flush()

        return