本文整理汇总了Python中mkt.extensions.models.Extension.es_data方法的典型用法代码示例。如果您正苦于以下问题:Python Extension.es_data方法的具体用法?Python Extension.es_data怎么用?Python Extension.es_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.extensions.models.Extension
的用法示例。
在下文中一共展示了Extension.es_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fake_object
# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import es_data [as 别名]
def fake_object(self, data):
"""Create a fake instance of Extension from ES data."""
obj = Extension(id=data['id'])
# Create a fake ExtensionVersion for latest_public_version.
if data['latest_public_version']:
obj.latest_public_version = ExtensionVersion(
extension=obj,
id=data['latest_public_version']['id'],
created=data['latest_public_version']['created'],
size=data['latest_public_version'].get('size', 0),
status=STATUS_PUBLIC,
version=data['latest_public_version']['version'],)
# Set basic attributes we'll need on the fake instance using the data
# from ES.
self._attach_fields(
obj, data, ('author', 'created', 'default_language',
'last_updated', 'modified', 'slug', 'status',
'version'))
obj.deleted = data['is_deleted']
obj.disabled = data['is_disabled']
obj.uuid = data['guid']
# Attach translations for all translated attributes.
# obj.default_language should be set first for this to work.
self._attach_translations(
obj, data, ('name', 'description', ))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj
示例2: fake_object
# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import es_data [as 别名]
def fake_object(self, data):
"""Create a fake instance of Extension from ES data."""
obj = Extension(id=data["id"])
# Create a fake ExtensionVersion for latest_public_version.
obj.latest_public_version = ExtensionVersion(
extension=obj,
pk=data["latest_public_version"]["id"],
status=STATUS_PUBLIC,
version=data["latest_public_version"]["version"],
)
# Set basic attributes we'll need on the fake instance using the data
# from ES.
self._attach_fields(obj, data, ("default_language", "slug", "status", "version"))
obj.uuid = data["guid"]
# Attach translations for all translated attributes.
# obj.default_language should be set first for this to work.
self._attach_translations(obj, data, ("name", "description"))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj
示例3: fake_object
# 需要导入模块: from mkt.extensions.models import Extension [as 别名]
# 或者: from mkt.extensions.models.Extension import es_data [as 别名]
def fake_object(self, data):
"""Create a fake instance of Extension from ES data."""
obj = Extension(id=data['id'])
# Set basic attributes we'll need on the fake instance using the data
# from ES.
self._attach_fields(
obj, data, ('default_language', 'slug', 'status', 'version'))
obj.uuid = data['guid']
# Attach translations for all translated attributes.
# obj.default_language should be set first for this to work.
self._attach_translations(
obj, data, ('name', ))
# Some methods might need the raw data from ES, put it on obj.
obj.es_data = data
return obj