当前位置: 首页>>代码示例>>Python>>正文


Python Profile.submit方法代码示例

本文整理汇总了Python中models.Profile.submit方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.submit方法的具体用法?Python Profile.submit怎么用?Python Profile.submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Profile的用法示例。


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

示例1: _add_profile

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import submit [as 别名]
def _add_profile(data, user, id=0):
    if id:
        obj = get_profile(id)
        update_ref_count(obj.construct_list, -1)
        obj.name = data[NAME]

        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)
        else:
            obj.construct_list = data[CONSTRUCT_LIST]

        obj.submit = data[SUBMIT]
        obj.updated_by = user
        update_ref_count(data[CONSTRUCT_LIST], +1)
        obj.save()
        return obj
    else:
        fp_object = Profile()
        fp_object.name = data[NAME]

        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)
        else:
            fp_object.construct_list = data[CONSTRUCT_LIST]

        fp_object.submit = data[SUBMIT]
        fp_object.updated_by = user
        update_ref_count(data[CONSTRUCT_LIST], +1)
        fp_object.save()
        return fp_object
开发者ID:datacenter,项目名称:ignite,代码行数:32,代码来源:feature.py

示例2: _add_profile

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import submit [as 别名]
def _add_profile(data, user, id=0):
    logger.debug("profile name = %s", data[NAME])

    if id:
        # get existing profile
        profile = Profile.objects.get(pk=id)

        for cfg in profile.construct_list:
            configlet.update_ref_count(cfg[CONFIGLET_ID], -1)
            for param_detail in cfg[PARAM_LIST]:
                if param_detail[PARAM_TYPE] == POOL:
                    update_pool_ref_count(int(param_detail[PARAM_VALUE]), -1)

    else:
        # create new profile
        profile = Profile()

    profile.name = data[NAME]
    profile.submit = data[SUBMIT]

    if not data[CONSTRUCT_LIST]:
        raise IgniteException(ERR_PROF_IS_EMPTY)
    else:
        profile.construct_list = data[CONSTRUCT_LIST]

    profile.updated_by = user
    profile.save()

    # increment ref count of configlets and pool used in this profile
    for cfg in profile.construct_list:
        configlet.update_ref_count(cfg[CONFIGLET_ID], 1)
        for param_detail in cfg[PARAM_LIST]:
            if param_detail[PARAM_TYPE] == POOL:
                update_pool_ref_count(int(param_detail[PARAM_VALUE]), 1)

    return profile
开发者ID:hasebrand,项目名称:ignite,代码行数:38,代码来源:profile.py

示例3: _add_profile_index

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import submit [as 别名]
def _add_profile_index(data, user, prindex_id=0, pr_id=0):
    logger.debug("profile name = %s", data[NAME])
    import hashlib

    pr_index = None
    profile = None
    temp1 = json.dumps(data[CONSTRUCT_LIST])

    if pr_id and prindex_id:
        # get existing profile
        pr_index = ProfileIndex.objects.get(pk=prindex_id)
        profile = Profile.objects.get(pk=pr_id, profileindex_id=prindex_id)
        current_version = get_profile_current_version(prindex_id)
        new = hashlib.md5(str(json.loads(temp1))).hexdigest()
        old = hashlib.md5(str(profile.construct_list)).hexdigest()

        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)

        if old == new:
            if not profile.submit:
                profile.submit = data[SUBMIT]
                profile.save()
            return profile

        obj = Profile.objects.get(profileindex=prindex_id, version=current_version)
        if obj.id != pr_id:
            err = "Update/Newversion can only be done with latest version of config profile"
            logger.error(err)
            raise IgniteException(err)

        for cfg in profile.construct_list:
            configlet.update_ref_count(cfg[CONFIGLETINDEX_ID], cfg[VERSION], -1)
            for param_detail in cfg[PARAM_LIST]:
                if param_detail[PARAM_TYPE] == POOL:
                    update_pool_ref_count(int(param_detail[PARAM_VALUE]), -1)

        if data[NEW_VERSION]:
            if not profile.submit:
                err = "Please submit current version, then create new version"
                logger.error(err)
                raise IgniteException(err)

            profile = Profile()
            profile.version = current_version + 1
        else:
            profile = Profile.objects.get(pk=pr_id)
    else:
        # create new profile
        if not data[CONSTRUCT_LIST]:
            raise IgniteException(ERR_PROF_IS_EMPTY)
        pr_index = ProfileIndex()
        pr_index.name = data[NAME]
        pr_index.updated_by = user
        pr_index.save()

        profile = Profile()
        profile.version = 1

    profile.name = data[NAME]
    profile.construct_list = data[CONSTRUCT_LIST]
    profile.submit = data[SUBMIT]
    profile.updated_by = user
    profile.profileindex = pr_index
    profile.save()

    # increment ref count of configlets and pool used in this profile
    for cfg in profile.construct_list:
        configlet.update_ref_count(cfg[CONFIGLETINDEX_ID], cfg[VERSION],  1)
        for param_detail in cfg[PARAM_LIST]:
            if param_detail[PARAM_TYPE] == POOL:
                update_pool_ref_count(int(param_detail[PARAM_VALUE]), 1)

    return profile
开发者ID:datacenter,项目名称:ignite,代码行数:76,代码来源:profile.py


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