本文整理汇总了Python中c2corg_api.models.DBSession.add_all方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.add_all方法的具体用法?Python DBSession.add_all怎么用?Python DBSession.add_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c2corg_api.models.DBSession
的用法示例。
在下文中一共展示了DBSession.add_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_version
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import add_all [as 别名]
def _update_version(self, document, user_id, comment, update_types,
changed_langs):
assert user_id
assert update_types
meta_data = HistoryMetaData(comment=comment, user_id=user_id)
archive = self._get_document_archive(document, update_types)
geometry_archive = \
self._get_geometry_archive(document, update_types)
cultures = \
self._get_cultures_to_update(document, update_types, changed_langs)
locale_versions = []
for culture in cultures:
locale = document.get_locale(culture)
locale_archive = self._get_locale_archive(locale, changed_langs)
version = DocumentVersion(
document_id=document.document_id,
culture=locale.culture,
document_archive=archive,
document_geometry_archive=geometry_archive,
document_locales_archive=locale_archive,
history_metadata=meta_data
)
locale_versions.append(version)
DBSession.add(archive)
DBSession.add(meta_data)
DBSession.add_all(locale_versions)
DBSession.flush()
示例2: _create_new_version
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import add_all [as 别名]
def _create_new_version(self, document):
archive = document.to_archive()
archive_locales = document.get_archive_locales()
archive_geometry = document.get_archive_geometry()
meta_data = HistoryMetaData(comment='creation')
versions = []
for locale in archive_locales:
version = DocumentVersion(
document_id=document.document_id,
culture=locale.culture,
document_archive=archive,
document_locales_archive=locale,
document_geometry_archive=archive_geometry,
history_metadata=meta_data
)
versions.append(version)
DBSession.add(archive)
DBSession.add_all(archive_locales)
DBSession.add(meta_data)
DBSession.add_all(versions)
DBSession.flush()
示例3: create_new_version
# 需要导入模块: from c2corg_api.models import DBSession [as 别名]
# 或者: from c2corg_api.models.DBSession import add_all [as 别名]
def create_new_version(document, user_id):
assert user_id
archive = document.to_archive()
archive_locales = document.get_archive_locales()
archive_geometry = document.get_archive_geometry()
meta_data = HistoryMetaData(comment='creation', user_id=user_id)
versions = []
for locale in archive_locales:
version = DocumentVersion(
document_id=document.document_id,
lang=locale.lang,
document_archive=archive,
document_locales_archive=locale,
document_geometry_archive=archive_geometry,
history_metadata=meta_data
)
versions.append(version)
DBSession.add(archive)
DBSession.add_all(archive_locales)
DBSession.add(meta_data)
DBSession.add_all(versions)
DBSession.flush()