當前位置: 首頁>>代碼示例>>Python>>正文


Python blok.BlokManager類代碼示例

本文整理匯總了Python中anyblok.blok.BlokManager的典型用法代碼示例。如果您正苦於以下問題:Python BlokManager類的具體用法?Python BlokManager怎麽用?Python BlokManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BlokManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: createdb

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()
開發者ID:jssuzanne,項目名稱:AnyBlok,代碼行數:32,代碼來源:scripts.py

示例2: anyblok_createdb

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()
開發者ID:jssuzanne,項目名稱:AnyBlok,代碼行數:25,代碼來源:scripts.py

示例3: test_get_invalid_blok

 def test_get_invalid_blok(self):
     try:
         BlokManager.load()
         BlokManager.get('invalid blok')
         self.fail('No exception when get invalid blok')
     except BlokManagerException:
         pass
開發者ID:petrus-v,項目名稱:AnyBlok,代碼行數:7,代碼來源:test_blok.py

示例4: load

 def load(self):
     BlokManager.load()
     preload_databases()
     config = Configurator()
     config.include_from_entry_point()
     config.load_config_bloks()
     return config.make_wsgi_app()
開發者ID:AnyBlok,項目名稱:Anyblok_Pyramid,代碼行數:7,代碼來源:gunicorn.py

示例5: anyblok_wsgi

def anyblok_wsgi(application, configuration_groups, **kwargs):
    """
    :param application: name of the application
    :param configuration_groups: list configuration groupe to load
    :param \**kwargs: ArgumentParser named arguments
    """
    format_configuration(configuration_groups, 'preload', 'pyramid-debug',
                         'wsgi')
    load_init_function_from_entry_points()
    Configuration.load(application,
                       configuration_groups=configuration_groups, **kwargs)
    BlokManager.load()
    config = Configurator()
    config.include_from_entry_point()
    config.load_config_bloks()

    wsgi_host = Configuration.get('wsgi_host')
    wsgi_port = int(Configuration.get('wsgi_port'))

    app = config.make_wsgi_app()
    server = make_server(wsgi_host, wsgi_port, app)
    preload_databases()

    logger.info("Serve forever on %r:%r" % (wsgi_host, wsgi_port))
    server.serve_forever()
開發者ID:jssuzanne,項目名稱:Anyblok_Pyramid,代碼行數:25,代碼來源:scripts.py

示例6: load_registry

    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
開發者ID:jssuzanne,項目名稱:AnyBlok,代碼行數:34,代碼來源:plugins.py

示例7: setUp

 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()
開發者ID:AnyBlok,項目名稱:AnyBlok_Multi_Engines,代碼行數:8,代碼來源:test_blok.py

示例8: test_set_two_time

 def test_set_two_time(self):
     blok_name = 'ABlok'
     BlokManager.set(blok_name, Blok)
     try:
         BlokManager.set(blok_name, Blok)
         self.fail("No watch dog for set two time the same blok")
     except BlokManagerException:
         pass
開發者ID:petrus-v,項目名稱:AnyBlok,代碼行數:8,代碼來源:test_blok.py

示例9: tearDown

    def tearDown(self):
        """ Clear the registry, unload the blok manager and  drop the database
        """
        if self.registry:
            self.registry.close()

        RegistryManager.clear()
        BlokManager.unload()
        super(DBTestCase, self).tearDown()
開發者ID:petrus-v,項目名稱:AnyBlok,代碼行數:9,代碼來源:testcase.py

示例10: tearDown

 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()
開發者ID:AnyBlok,項目名稱:AnyBlok_Multi_Engines,代碼行數:10,代碼來源:test_blok.py

示例11: test_reload

 def test_reload(self):
     BlokManager.load()
     BlokManager.set('invalid blok', None)
     BlokManager.get('invalid blok')
     BlokManager.reload()
     try:
         BlokManager.get('invalid blok')
         self.fail("Reload classmethod doesn't reload the bloks")
     except BlokManagerException:
         pass
開發者ID:petrus-v,項目名稱:AnyBlok,代碼行數:10,代碼來源:test_blok.py

示例12: setUpClass

    def setUpClass(cls):
        """ Intialialise the configuration manager """

        super(DBTestCase, cls).setUpClass()
        cls.init_configuration_manager()
        if cls.createdb(keep_existing=True):
            BlokManager.load(entry_points=('bloks', 'test_bloks'))
            registry = cls.getRegistry()
            registry.commit()
            registry.close()
            BlokManager.unload()
開發者ID:jssuzanne,項目名稱:AnyBlok,代碼行數:11,代碼來源:testcase.py

示例13: test_start_function

    def test_start_function(self):
        BlokManager.unload()
        db_name = Configuration.get('db_name') or 'test_anyblok'
        db_driver_name = Configuration.get('db_driver_name') or 'postgresql'

        testargs = ['default', '--db-name', db_name, '--db-driver-name',
                    db_driver_name]
        with patch.object(sys, 'argv', testargs):
            registry = start('default')

        self.assertIsNotNone(registry)
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:11,代碼來源:test_registry.py

示例14: get_logo

    def get_logo(self):
        """fget of ``logo`` return the path in the blok of the logo

        :rtype: absolute path or None if unexiste logo
        """
        blok = BlokManager.get(self.name)
        blok_path = BlokManager.getPath(blok.name)
        file_path = join(blok_path, blok.logo)
        if isfile(file_path):
            return file_path

        return None
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:12,代碼來源:blok.py

示例15: get_templates_from

def get_templates_from(attr):
    tmpl = Template(forclient=True)
    for blok_name in BlokManager.ordered_bloks:
        blok = BlokManager.get(blok_name)
        if hasattr(blok, attr):
            bpath = BlokManager.getPath(blok_name)
            for template in getattr(blok, attr):
                with open(join(bpath, template), 'r') as fp:
                    tmpl.load_file(fp)

    tmpl.compile()
    return tmpl.get_all_template()
開發者ID:jssuzanne,項目名稱:ERPBlok,代碼行數:12,代碼來源:common.py


注:本文中的anyblok.blok.BlokManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。