本文整理匯總了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
示例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))
示例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)
示例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 ""))