• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python containers.is_basic_identifier函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyon.util.containers.is_basic_identifier函数的典型用法代码示例。如果您正苦于以下问题:Python is_basic_identifier函数的具体用法?Python is_basic_identifier怎么用?Python is_basic_identifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_basic_identifier函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: assert_configuration

def assert_configuration(config):
    """
    Checks that configuration is OK
    """
    if not is_basic_identifier(config.get_safe("system.name", "")):
        raise ContainerConfigError("Config entry 'system.name' has illegal value")
    if not is_basic_identifier(config.get_safe("system.root_org", "")):
        raise ContainerConfigError("Config entry 'system.root_org' has illegal value")
开发者ID:tgiguere,项目名称:pyon,代码行数:8,代码来源:bootstrap.py


示例2: create_role

    def create_role(self, user_role=None):
        """Persists the provided UserRole object. The name of a role can only contain
        alphanumeric and underscore characters while the description can me human
        readable. The id string returned is the internal id by which a UserRole will
        be indentified in the data store.

        @param user_role    UserRole
        @retval user_role_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """

        if not user_role:
            raise BadRequest("The user_role parameter is missing")

        # If this governance identifier is not set, then set to a safe version of the policy name.
        if not user_role.governance_name:
            user_role.governance_name = create_basic_identifier(user_role.name)

        if not is_basic_identifier(user_role.governance_name):
            raise BadRequest(
                "The governance_name field '%s' can only contain alphanumeric and underscore characters"
                % user_role.governance_name
            )

        user_role_id, version = self.clients.resource_registry.create(user_role)
        return user_role_id
开发者ID:pkediyal,项目名称:coi-services,代码行数:26,代码来源:policy_management_service.py


示例3: update_role

    def update_role(self, user_role=None):
        """Updates the provided UserRole object.  The name of a role can only contain
        alphanumeric and underscore characters while the description can me human
        readable.Throws NotFound exception if an existing version of UserRole is
        not found.  Throws Conflict if the provided UserRole object is not based on
        the latest persisted version of the object.

        @param user_role    UserRole
        @retval success    bool
        @throws BadRequest    if object does not have _id or _rev attribute
        @throws NotFound    object with specified id does not exist
        @throws Conflict    object not based on latest persisted object version
        """

        if not user_role:
            raise BadRequest("The user_role parameter is missing")

        # If this governance identifier is not set, then set to a safe version of the policy name.
        if not user_role.governance_name:
            user_role.governance_name = create_basic_identifier(user_role.name)

        if not is_basic_identifier(user_role.governance_name):
            raise BadRequest(
                "The governance_name field '%s' can only contain alphanumeric and underscore characters"
                % user_role.governance_name
            )

        self.clients.resource_registry.update(user_role)
开发者ID:pkediyal,项目名称:coi-services,代码行数:28,代码来源:policy_management_service.py


示例4: assert_configuration

def assert_configuration(config):
    """
    Checks that configuration is OK.
    This is separate so that it can be called after config changes (from directory, command line etc)
    """
    from pyon.core.exception import ContainerConfigError
    from pyon.util.containers import is_basic_identifier
    if not is_basic_identifier(config.get_safe("system.root_org", "")):
        raise ContainerConfigError("Config entry 'system.root_org' has illegal value")
开发者ID:mkl-,项目名称:scioncc,代码行数:9,代码来源:bootstrap.py


示例5: update_policy

    def update_policy(self, policy=None):
        """Updates the provided Policy object.
        """
        self._validate_resource_obj("policy", policy, RT.Policy, checks="id,name")
        if not is_basic_identifier(policy.name):
            raise BadRequest("The policy name '%s' can only contain alphanumeric and underscore characters" % policy.name)

        self.clients.resource_registry.update(policy)

        self._publish_policy_event(policy)
开发者ID:edwardhunter,项目名称:scioncc,代码行数:10,代码来源:policy_management_service.py


示例6: update_conversation_type

    def update_conversation_type(self, conversation_type=None):
        """Updates an existing Conversation Type resource.

        @param conversation_type    ConversationType
        @throws BadRequest    if object does not have _id or _rev attribute
        @throws NotFound    object with specified id does not exist
        @throws Conflict    object not based on latest persisted object version
        """
        if not is_basic_identifier(conversation_type.name):
            raise BadRequest("The conversation type name '%s' can only contain alphanumeric and underscore characters" % conversation_type.name)

        self.clients.resource_registry.update(conversation_type)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:12,代码来源:conversation_management_service.py


示例7: create_conversation_type

    def create_conversation_type(self, conversation_type=None):
        """Creates a Conversation Type resource from the parameter ConversationType object.

        @param conversation_type    ConversationType
        @retval conversation_type_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """
        if not is_basic_identifier(conversation_type.name):
            raise BadRequest("The conversation type name '%s' can only contain alphanumeric and underscore characters" % conversation_type.name)

        conversation_type_id, version = self.clients.resource_registry.create(conversation_type)
        return conversation_type_id
开发者ID:Bobfrat,项目名称:coi-services,代码行数:12,代码来源:conversation_management_service.py


示例8: update_service_definition

 def update_service_definition(self, service_definition=None):
     """ Should receive a ServiceDefinition object
     """
     # Return Value
     # ------------
     # {success: true}
     #
     if not is_basic_identifier(service_definition.name):
         raise BadRequest("Invalid service_definition name: %s" % service_definition.name)
     if not is_yaml_string_valid(service_definition.definition):
         raise BadRequest("Invalid YAML definition")
     service_id , version = self.clients.resource_registry.update(service_definition)
     return service_id
开发者ID:ednad,项目名称:coi-services,代码行数:13,代码来源:service_management_service.py


示例9: update_object_type

 def update_object_type(self, object_type=None):
     """ Should receive an ObjectType object
     """
     # Return Value
     # ------------
     # {success: true}
     #
     if not is_basic_identifier(object_type.name):
         raise BadRequest("Invalid object_type name: %s" % object_type.name)
     if not is_yaml_string_valid(object_type.definition):
         raise BadRequest("Invalid YAML definition")
     object_id, version =  self.clients.resource_registry.update(object_type)
     return object_id
开发者ID:Bobfrat,项目名称:coi-services,代码行数:13,代码来源:object_management_service.py


示例10: update_workflow_definition

    def update_workflow_definition(self, workflow_definition=None):
        """Updates an existing Workflow Definition resource.

        @param workflow_definition    WorkflowDefinition
        @throws BadRequest    if object does not have _id or _rev attribute
        @throws NotFound    object with specified id does not exist
        @throws Conflict    object not based on latest persisted object version
        """
        if not is_basic_identifier(workflow_definition.name):
            raise BadRequest("The workflow definition name '%s' can only contain alphanumeric and underscore characters" % workflow_definition.name)

        self.clients.resource_registry.update(workflow_definition)

        self._update_workflow_associations(workflow_definition)
开发者ID:ooici-eoi,项目名称:coi-services,代码行数:14,代码来源:workflow_management_service.py


示例11: create_policy

    def create_policy(self, policy=None):
        """Persists the provided Policy object for the specified Org id. The id string returned
        is the internal id by which Policy will be identified in the data store.

        @param policy    Policy
        @retval policy_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """
        if not is_basic_identifier(policy.name):
            raise BadRequest("The policy name '%s' can only contain alphanumeric and underscore characters" % user_role.name)

        policy.rule = policy.rule % (policy.name, policy.description)
        policy_id, version = self.clients.resource_registry.create(policy)
        return policy_id
开发者ID:seman,项目名称:coi-services,代码行数:14,代码来源:policy_management_service.py


示例12: update_policy

    def update_policy(self, policy=None):
        """Updates the provided Policy object.  Throws NotFound exception if
        an existing version of Policy is not found.  Throws Conflict if
        the provided Policy object is not based on the latest persisted
        version of the object.

        @param policy    Policy
        @throws NotFound    object with specified id does not exist
        @throws BadRequest    if object does not have _id or _rev attribute
        @throws Conflict    object not based on latest persisted object version
        """
        if not is_basic_identifier(policy.name):
            raise BadRequest("The policy name '%s' can only contain alphanumeric and underscore characters" % user_role.name)

        self.clients.resource_registry.update(policy)
开发者ID:seman,项目名称:coi-services,代码行数:15,代码来源:policy_management_service.py


示例13: create_role

    def create_role(self, user_role=None):
        """Persists the provided UserRole object. The name of a role can only contain
        alphanumeric and underscore characters while the description can me human
        readable. The id string returned is the internal id by which a UserRole will
        be indentified in the data store.

        @param user_role    UserRole
        @retval user_role_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """

        if not is_basic_identifier(user_role.name):
            raise BadRequest("The role name '%s' can only contain alphanumeric and underscore characters" % user_role.name)

        user_role_id, version = self.clients.resource_registry.create(user_role)
        return user_role_id
开发者ID:seman,项目名称:coi-services,代码行数:16,代码来源:policy_management_service.py


示例14: create_resource_type

    def create_resource_type(self, resource_type=None, object_id=""):
        """ Should receive a ResourceType object
        """
        # Return Value
        # ------------
        # {resource_type_id: ''}
        #
        if not is_basic_identifier(resource_type.name):
            raise BadRequest("Invalid resource name: %s " % resource_type.name)
        if not object_id:
            raise BadRequest("Object_id is missing")

        object_type= self.clients.resource_registry.read(object_id)
        if resource_type.name != object_type.name:
            raise BadRequest("Resource and object name don't match: %s - %s" (resource_type.name,object_type.name))
        resource_id, version = self.clients.resource_registry.create(resource_type)
        self.clients.resource_registry.create_association(resource_id, PRED.hasObjectType, object_id)
        return resource_id
开发者ID:blazetopher,项目名称:coi-services,代码行数:18,代码来源:resource_management_service.py


示例15: create_workflow_definition

    def create_workflow_definition(self, workflow_definition=None):
        """Creates a Workflow Definition resource which specifies the steps involved in a workflow process.

        @param workflow_definition    WorkflowDefinition
        @retval workflow_definition_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """

        if not is_basic_identifier(workflow_definition.name):
            raise BadRequest("The workflow definition name '%s' can only contain alphanumeric and underscore characters" % workflow_definition.name)

        workflow_definition_id, version = self.clients.resource_registry.create(workflow_definition)


        workflow_definition = self.read_workflow_definition(workflow_definition_id)
        self._update_workflow_associations(workflow_definition)


        return workflow_definition_id
开发者ID:ooici-eoi,项目名称:coi-services,代码行数:19,代码来源:workflow_management_service.py


示例16: update_org

    def update_org(self, org=None):
        """Updates the Org based on provided object.

        @param org    Org
        @throws BadRequest    if object does not have _id or _rev attribute
        @throws NotFound    object with specified id does not exist
        @throws Conflict    object not based on latest persisted object version
        """
        if not org:
            raise BadRequest("The org parameter is missing")

        #If this governance identifier is not set, then set to a safe version of the org name.
        if not org.org_governance_name:
            org.org_governance_name = create_basic_identifier(org.name)

        if not is_basic_identifier(org.org_governance_name):
            raise BadRequest("The Org org_governance_name '%s' can only contain alphanumeric and underscore characters" % org.org_governance_name)

        self.clients.resource_registry.update(org)
开发者ID:MauriceManning,项目名称:coi-services,代码行数:19,代码来源:org_management_service.py


示例17: create_policy

    def create_policy(self, policy=None):
        """Persists the provided Policy object The id string returned
        is the internal id by which Policy will be identified in the data store.

        @param policy    Policy
        @retval policy_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """
        if not is_basic_identifier(policy.name):
            raise BadRequest("The policy name '%s' can only contain alphanumeric and underscore characters" % policy.name)

        #If there is a policy_rule field then try to add the policy name and decription to the rule text
        if hasattr(policy.policy_type, 'policy_rule'):
            policy.policy_type.policy_rule = policy.policy_type.policy_rule % (policy.name, policy.description)

        policy_id, version = self.clients.resource_registry.create(policy)

        log.debug('Policy created: ' + policy.name)

        return policy_id
开发者ID:jamie-cyber1,项目名称:coi-services,代码行数:20,代码来源:policy_management_service.py


示例18: create_org

    def create_org(self, org=None):
        """Creates an Org based on the provided object. The id string returned
        is the internal id by which Org will be identified in the data store.

        @param org    Org
        @retval org_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """

        if not org:
            raise BadRequest("The org parameter is missing")

        #Only allow one root ION Org in the system
        if org.name == self._get_root_org_name():
            res_list,_  = self.clients.resource_registry.find_resources(restype=RT.Org, name=self._get_root_org_name())
            if len(res_list) > 0:
                raise BadRequest('There can only be one Org named %s' % self._get_root_org_name())

        #If this governance identifier is not set, then set to a safe version of the org name.
        if not org.org_governance_name:
            org.org_governance_name = create_basic_identifier(org.name)

        if not is_basic_identifier(org.org_governance_name):
            raise BadRequest("The Org org_governance_name '%s' can only contain alphanumeric and underscore characters" % org.org_governance_name)


        org_id, org_rev = self.clients.resource_registry.create(org)
        org._id = org_id
        org._rev = org_rev

        #Instantiate a Directory for this Org
        directory = Directory(orgname=org.name)

        #Instantiate initial set of User Roles for this Org
        manager_role = IonObject(RT.UserRole, name='Facility Administrator', governance_name=ORG_MANAGER_ROLE, description='Change Facility Information, assign Roles, post Facility events')
        self.add_user_role(org_id, manager_role)

        member_role = IonObject(RT.UserRole, name='Facility Member', governance_name=ORG_MEMBER_ROLE, description='Subscribe to events, set personal preferences')
        self.add_user_role(org_id, member_role)

        return org_id
开发者ID:MauriceManning,项目名称:coi-services,代码行数:41,代码来源:org_management_service.py


示例19: add_org_role

    def add_org_role(self, org_id="", user_role=None):
        """Adds a UserRole to an Org, if the role by the specified
       name does not exist.
        """
        org_obj = self._validate_resource_id("org_id", org_id, RT.Org)
        self._validate_resource_obj("user_role", user_role, RT.UserRole, checks="noid,name")
        if not is_basic_identifier(user_role.governance_name):
            raise BadRequest("Invalid role governance_name")

        user_role.org_governance_name = org_obj.org_governance_name

        try:
            self._find_org_role(org_id, user_role.governance_name)
            raise BadRequest("Role '%s' is already associated with this Org" % user_role.governance_name)
        except NotFound:
            pass

        user_role_id, _ = self.rr.create(user_role)

        self.rr.create_association(org_obj, PRED.hasRole, user_role_id)

        return user_role_id
开发者ID:edwardhunter,项目名称:scioncc,代码行数:22,代码来源:org_management_service.py


示例20: create_policy

    def create_policy(self, policy=None):
        """Persists the provided Policy object The id string returned
        is the internal id by which Policy will be identified in the data store.

        @param policy    Policy
        @retval policy_id    str
        @throws BadRequest    if object passed has _id or _rev attribute
        """

        if not policy:
            raise BadRequest("The policy parameter is missing")

        if not is_basic_identifier(policy.name):
            raise BadRequest("The policy name '%s' can only contain alphanumeric and underscore characters" % policy.name)

        try:
            #If there is a policy_rule field then try to add the policy name and decription to the rule text
            if hasattr(policy.policy_type, 'policy_rule'):
                policy.policy_type.policy_rule = policy.policy_type.policy_rule % (policy.name, policy.description)

        except Exception, e:
            raise Inconsistent("Missing the elements in the policy rule to set the description: " + e.message)
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:22,代码来源:policy_management_service.py



注:本文中的pyon.util.containers.is_basic_identifier函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python containers.named_any函数代码示例发布时间:2022-05-27
下一篇:
Python containers.get_safe函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap