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


Python DatabaseManager.get_database_version方法代码示例

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


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

示例1: environment_needs_upgrade

# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import get_database_version [as 别名]
 def environment_needs_upgrade(self):
     """
     Called when Trac checks whether the environment needs to be upgraded.
     Returns `True` if upgrade is needed, `False` otherwise.
     """
     dbm = DatabaseManager(self.env)
     return dbm.get_database_version(db_version_key) != db_version
开发者ID:Automattic,项目名称:trac-code-comments-plugin,代码行数:9,代码来源:db.py

示例2: DatabaseManagerTestCase

# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import get_database_version [as 别名]
class DatabaseManagerTestCase(unittest.TestCase):

    def setUp(self):
        self.env = EnvironmentStub(default_data=True)
        self.dbm = DatabaseManager(self.env)

    def tearDown(self):
        self.env.reset_db()

    def test_get_default_database_version(self):
        """Get database version for the default entry named
        `database_version`.
        """
        self.assertEqual(default_db_version, self.dbm.get_database_version())

    def test_get_table_names(self):
        """Get table names for the default database."""
        self.assertEqual(sorted(table.name for table in default_schema),
                         sorted(self.dbm.get_table_names()))

    def test_set_default_database_version(self):
        """Set database version for the default entry named
        `database_version`.
        """
        new_db_version = default_db_version + 1
        self.dbm.set_database_version(new_db_version)
        self.assertEqual(new_db_version, self.dbm.get_database_version())

        # Restore the previous version to avoid destroying the database
        # on teardown
        self.dbm.set_database_version(default_db_version)
        self.assertEqual(default_db_version, self.dbm.get_database_version())

    def test_set_get_plugin_database_version(self):
        """Get and set database version for an entry with an
        arbitrary name.
        """
        name = 'a_trac_plugin_version'
        db_ver = 1

        self.assertFalse(self.dbm.get_database_version(name))
        self.dbm.set_database_version(db_ver, name)
        self.assertEqual(db_ver, self.dbm.get_database_version(name))
开发者ID:pkdevbox,项目名称:trac,代码行数:45,代码来源:api.py

示例3: upgrade_environment

# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import get_database_version [as 别名]
 def upgrade_environment(self):
     """
     Actually perform an environment upgrade, but don't commit as
     that is done by the common upgrade procedure when all plugins are done.
     """
     dbm = DatabaseManager(self.env)
     current_ver = dbm.get_database_version(db_version_key)
     if current_ver == 0:
         dbm.create_tables(schema.values())
     else:
         while current_ver + 1 <= db_version:
             upgrade_map[current_ver + 1](self.env)
             current_ver += 1
     dbm.set_database_version(db_version, db_version_key)
开发者ID:Automattic,项目名称:trac-code-comments-plugin,代码行数:16,代码来源:db.py

示例4: get_version

# 需要导入模块: from trac.db.api import DatabaseManager [as 别名]
# 或者: from trac.db.api.DatabaseManager import get_database_version [as 别名]
    def get_version(self, initial=False):
        """Return the current version of the database.  If the
        optional argument `initial` is set to `True`, the version of
        the database used at the time of creation will be returned.

        In practice, for database created before 0.11, this will
        return `False` which is "older" than any db version number.

        :since: 0.11

        :since 1.0.2: The lazily-evaluated attributes `database_version` and
                      `database_initial_version` should be used instead. This
                      method will be removed in release 1.3.1.
        """
        dbm = DatabaseManager(self)
        return dbm.get_database_version("{0}database_version".format("initial_" if initial else ""))
开发者ID:spsoft-RockWang,项目名称:project-_trac,代码行数:18,代码来源:env.py


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