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


Python ContentType._id方法代码示例

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


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

示例1: _create_or_update_type

# 需要导入模块: from pulp.server.db.model.content import ContentType [as 别名]
# 或者: from pulp.server.db.model.content.ContentType import _id [as 别名]
def _create_or_update_type(type_def):
    """
    This method creates or updates a type definition in MongoDB.

    :param type_def: the type definition to update or create. If a type definition with the same
                     as an existing type, the type is updated, otherwise it is created.
    :type  type_def: ContentType

    :return: This method will always return None
    :rtype:  None
    """
    # Make sure a collection exists for the type
    database = pulp_db.get_database()
    collection_name = unit_collection_name(type_def.id)

    if collection_name not in database.collection_names():
        pulp_db.get_collection(collection_name, create=True)

    # Add or update an entry in the types list
    content_type_collection = ContentType.get_collection()
    content_type = ContentType(
        type_def.id, type_def.display_name, type_def.description, type_def.unit_key,
        type_def.search_indexes, type_def.referenced_types)
    # no longer rely on _id = id
    existing_type = content_type_collection.find_one({'id': type_def.id}, fields=[])
    if existing_type is not None:
        content_type._id = existing_type['_id']
    # XXX this still causes a potential race condition when 2 users are updating the same type
    content_type_collection.save(content_type, safe=True)
开发者ID:hgschmie,项目名称:pulp,代码行数:31,代码来源:database.py

示例2: _create_or_update_type

# 需要导入模块: from pulp.server.db.model.content import ContentType [as 别名]
# 或者: from pulp.server.db.model.content.ContentType import _id [as 别名]
def _create_or_update_type(type_def):

    # Make sure a collection exists for the type
    database = pulp_db.get_database()
    collection_name = unit_collection_name(type_def.id)

    if collection_name not in database.collection_names():
        pulp_db.get_collection(collection_name, create=True)

    # Add or update an entry in the types list
    content_type_collection = ContentType.get_collection()
    content_type = ContentType(type_def.id, type_def.display_name, type_def.description,
                               type_def.unit_key, type_def.search_indexes, type_def.referenced_types)
    # no longer rely on _id = id
    existing_type = content_type_collection.find_one({'id': type_def.id}, fields=[])
    if existing_type is not None:
        content_type._id = existing_type['_id']
    # XXX this still causes a potential race condition when 2 users are updating the same type
    content_type_collection.save(content_type, safe=True)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:21,代码来源:database.py


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