本文整理汇总了Python中anyblok.registry.RegistryManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python RegistryManager.get方法的具体用法?Python RegistryManager.get怎么用?Python RegistryManager.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anyblok.registry.RegistryManager
的用法示例。
在下文中一共展示了RegistryManager.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_query
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def test_update_query(self):
registry = RegistryManager.get(Configuration.get('db_name'))
registry.upgrade(install=('test-me-blok2',))
registry.commit()
self.assertTrue(registry.System.Blok.query().all_name())
self.assertTrue(registry.System.Blok.query().all())
registry.close()
registry = RegistryManager.get(Configuration.get('db_name'))
self.assertTrue(registry.System.Blok.query().all_name())
self.assertTrue(registry.System.Blok.query().all())
示例2: load_registry
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def load_registry(self):
if self.enabled and self.registryLoaded is False:
# Load the registry here not in configuration,
# because the configuration are not load in order of score
self.registryLoaded = True
BlokManager.load()
load_init_function_from_entry_points(unittest=True)
Configuration.load_config_for_test()
Configuration.parse_options(self.AnyBlokOptions, ('bloks',))
db_name = Configuration.get('db_name')
if not db_name:
raise Exception("No database defined to run Test")
registry = RegistryManager.get(db_name)
if registry:
installed_bloks = registry.System.Blok.list_by_state(
"installed")
selected_bloks = Configuration.get('selected_bloks')
if not selected_bloks:
selected_bloks = installed_bloks
unwanted_bloks = Configuration.get('unwanted_bloks')
if unwanted_bloks is None:
unwanted_bloks = []
self.bloks_path = [BlokManager.getPath(x)
for x in BlokManager.ordered_bloks]
self.authoried_bloks_test_files = [
path for blok in installed_bloks
if blok in selected_bloks and blok not in unwanted_bloks
for path in [join(BlokManager.getPath(blok), 'tests')]
if exists(path)]
registry.close() # free the registry to force create it again
示例3: load_client
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def load_client(request):
""" Return the client main page """
database = request.session.get('database')
login = request.session.get('login')
password = request.session.get('password')
state = request.session.get('state')
if not(database and login and password and state == "connected"):
logout(request)
return HTTPFound(location=request.route_url('homepage'))
try:
registry = RegistryManager.get(database)
assert registry.Web.Login.check_authentification(login, password)
except:
logout(request)
return HTTPFound(location=request.route_url('homepage'))
css = registry.Web.get_css()
js = registry.Web.get_js()
js_babel = registry.Web.get_js_babel()
# TODO see in system.parmeter if they are no data for title
title = Configuration.get('app_name', 'ERPBlok')
templates = registry.Web.get_templates()
return render_to_response('erpblok:client.mak',
{'title': title,
'css': css,
'js': js,
'js_babel': js_babel,
'templates': templates,
}, request=request)
示例4: anyblok_createdb
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def anyblok_createdb():
"""Create a database and install blok from config"""
load_init_function_from_entry_points()
Configuration.load('createdb')
configuration_post_load()
BlokManager.load()
db_name = get_db_name()
db_template_name = Configuration.get('db_template_name', None)
url = Configuration.get('get_url')(db_name=db_name)
create_database(url, template=db_template_name)
registry = RegistryManager.get(db_name)
if registry is None:
return
if Configuration.get('install_all_bloks'):
bloks = registry.System.Blok.list_by_state('uninstalled')
else:
install_bloks = Configuration.get('install_bloks') or []
iou_bloks = Configuration.get('install_or_update_bloks') or []
bloks = list(set(install_bloks + iou_bloks))
registry.upgrade(install=bloks)
registry.commit()
registry.close()
示例5: get_registry_for
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def get_registry_for(dbname, loadwithoutmigration=True, log_repeat=False):
settings = {
'anyblok.session.event': [register],
}
return RegistryManager.get(
dbname, loadwithoutmigration=loadwithoutmigration,
log_repeat=log_repeat, **settings)
示例6: createdb
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def createdb(application, configuration_groups, **kwargs):
""" Create a database and install blok from config
:param application: name of the application
:param configuration_groups: list configuration groupe to load
:param \**kwargs: ArgumentParser named arguments
"""
format_configuration(configuration_groups,
'create_db', 'install-bloks',
'install-or-update-bloks')
load_init_function_from_entry_points()
Configuration.load(application, configuration_groups=configuration_groups,
**kwargs)
BlokManager.load()
db_name = Configuration.get('db_name')
db_template_name = Configuration.get('db_template_name', None)
url = Configuration.get('get_url')(db_name=db_name)
create_database(url, template=db_template_name)
registry = RegistryManager.get(db_name)
if registry is None:
return
if Configuration.get('install_all_bloks'):
bloks = registry.System.Blok.list_by_state('uninstalled')
else:
install_bloks = Configuration.get('install_bloks') or []
iou_bloks = Configuration.get('install_or_update_bloks') or []
bloks = list(set(install_bloks + iou_bloks))
registry.upgrade(install=bloks)
registry.commit()
registry.close()
示例7: setUp
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def setUp(self):
super(TestBlok, self).setUp()
self.__class__.init_configuration_manager()
self.__class__.createdb(keep_existing=False)
BlokManager.load(entry_points=('bloks', 'test_bloks'))
registry = RegistryManager.get(Configuration.get('db_name'))
registry.commit()
registry.close()
示例8: setUpClass
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def setUpClass(cls):
""" Initialize the registry.
"""
super(BlokTestCase, cls).setUpClass()
additional_setting = cls.additional_setting()
if cls.registry is None:
cls.registry = RegistryManager.get(Configuration.get('db_name'),
**additional_setting)
cls.registry.commit()
示例9: tearDown
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def tearDown(self):
""" Clear the registry, unload the blok manager and drop the database
"""
registry = RegistryManager.get(Configuration.get('db_name'))
registry.close()
RegistryManager.clear()
BlokManager.unload()
clear_mappers()
self.__class__.dropdb()
super(TestBlok, self).tearDown()
示例10: drop_database
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def drop_database(database):
""" Close the registry instance of the database and drop the database
:param: database's name
"""
url = Configuration.get('get_url')(db_name=database)
if not database_exists(url):
raise Exception("Database %r does not already exist")
registry = RegistryManager.get(database)
registry.close()
SU_drop_database(url)
示例11: getRegistry
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def getRegistry(cls):
"""Return the registry for the test database.
This assumes the database is created, and the registry has already
been initialized::
registry = self.getRegistry()
:rtype: registry instance
"""
additional_setting = cls.additional_setting()
return RegistryManager.get(Configuration.get('db_name'),
**additional_setting)
示例12: create_database
# 需要导入模块: from anyblok.registry import RegistryManager [as 别名]
# 或者: from anyblok.registry.RegistryManager import get [as 别名]
def create_database(database):
""" Create a new database, initialize it and return an AnyBlok registry
:param: database's name
:rtype: AnyBlok registry instance
"""
url = Configuration.get('get_url')(db_name=database)
if database_exists(url):
raise Exception("Database %r already exist")
db_template_name = Configuration.get('db_template_name', None)
SU_create_database(url, template=db_template_name)
registry = RegistryManager.get(database)
return registry