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


Python PackageVersion.get方法代码示例

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


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

示例1: _reload_version

# 需要导入模块: from models.package_version import PackageVersion [as 别名]
# 或者: from models.package_version.PackageVersion import get [as 别名]
    def _reload_version(self, key):
        """Reload a single package version from its tarball."""

        version = PackageVersion.get(key)
        with closing(cloud_storage.read(version.storage_path)) as f:
            new_version = PackageVersion.from_archive(
                f, uploader=version.uploader)

        with models.transaction():
            # Reload the old version in case anything (e.g. sort order) changed.
            version = PackageVersion.get(key)
            package = version.package

            # We don't load new_version.package.latest_version here for two
            # reasons. One is to avoid a needless data store lookup; the other
            # is because it's possible that that version is being reloaded in
            # another transaction and thus in a weird transitional state.
            latest_version_key = Package.latest_version.get_value_for_datastore(
                package)
            if latest_version_key == key:
                package.latest_version = new_version

            new_version.created = version.created
            new_version.downloads = version.downloads
            new_version.sort_order = version.sort_order
            version.delete()
            new_version.put()
            package.put()

        memcache.incr('versions_reloaded')
开发者ID:butlermatt,项目名称:pub-dartlang,代码行数:32,代码来源:package_versions.py

示例2: _count_download

# 需要导入模块: from models.package_version import PackageVersion [as 别名]
# 或者: from models.package_version.PackageVersion import get [as 别名]
 def _count_download(self, key):
     """Increment the download count for a package version."""
     with models.transaction():
         version = PackageVersion.get(key)
         version.downloads += 1
         version.package.downloads += 1
         version.put()
         version.package.put()
开发者ID:butlermatt,项目名称:pub-dartlang,代码行数:10,代码来源:package_versions.py

示例3: _reload_version

# 需要导入模块: from models.package_version import PackageVersion [as 别名]
# 或者: from models.package_version.PackageVersion import get [as 别名]
    def _reload_version(self, key):
        """Reload a single package version from its tarball."""

        version = PackageVersion.get(key)
        logging.info('Reloading %s %s' % (version.package.name, version.version))

        with closing(cloud_storage.read(version.storage_path)) as f:
            new_version = PackageVersion.from_archive(
                f, uploader=version.uploader)

        with models.transaction():
            # Reload the old version in case anything (e.g. sort order) changed.
            version = PackageVersion.get(key)
            package = version.package

            # We don't load new_version.package.latest_version here for two
            # reasons. One is to avoid a needless data store lookup; the other
            # is because it's possible that that version is being reloaded in
            # another transaction and thus in a weird transitional state.
            latest_version_key = Package.latest_version.get_value_for_datastore(
                package)
            if latest_version_key == key:
                package.latest_version = new_version

            new_version.created = version.created
            new_version.downloads = version.downloads
            new_version.sort_order = version.sort_order
            version.delete()
            new_version.put()

            # Only save the package if its latest version has been updated.
            # Otherwise, its latest version may be being updated in parallel,
            # causing icky bugs.
            if latest_version_key == key:
                package.put()
                package.invalidate_cache()


        count = memcache.incr('versions_reloaded')
        logging.info('%s/%s versions reloaded' %
                     (count, memcache.get('versions_to_reload')))
开发者ID:ricowind,项目名称:pub-dartlang,代码行数:43,代码来源:package_versions.py


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