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


Python RegistryManager.init_blok方法代碼示例

本文整理匯總了Python中anyblok.registry.RegistryManager.init_blok方法的典型用法代碼示例。如果您正苦於以下問題:Python RegistryManager.init_blok方法的具體用法?Python RegistryManager.init_blok怎麽用?Python RegistryManager.init_blok使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在anyblok.registry.RegistryManager的用法示例。


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

示例1: imports

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
    def imports(self):
        """ Imports modules and / or packages listed in the blok path"""
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager

        RegistryManager.init_blok(self.blok)
        b = BlokManager.get(self.blok)
        b.import_declaration_module()
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:10,代碼來源:imp.py

示例2: test_init_blok

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
    def test_init_blok(self):
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for core in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                     'InstrumentedList'):
            self.assertIn(
                core, RegistryManager.loaded_bloks['newblok']['Core'].keys())
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][core], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:17,代碼來源:test_registry_manager.py

示例3: test_add_entry

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
    def test_add_entry(self):
        RegistryManager.declare_entry('Other')
        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        for entry in ('Base', 'SqlBase', 'SqlViewBase', 'Session', 'Query',
                      'InstrumentedList'):
            self.assertEqual(
                RegistryManager.loaded_bloks['newblok']['Core'][entry], [])

        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Model'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Mixin'],
                         {'registry_names': []})
        self.assertEqual(RegistryManager.loaded_bloks['newblok']['Other'],
                         {'registry_names': []})
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:18,代碼來源:test_registry_manager.py

示例4: reload

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
    def reload(self):
        """ Reload all the imports for this module

        :exception: ImportManagerException
        """
        from anyblok.blok import BlokManager
        from anyblok.registry import RegistryManager
        from anyblok.environment import EnvironmentManager

        b = BlokManager.get(self.blok)
        if not hasattr(b, 'reload_declaration_module'):
            return

        try:
            EnvironmentManager.set('reload', True)
            RegistryManager.init_blok(self.blok)
            b.reload_declaration_module(reload_module)
        finally:
            EnvironmentManager.set('reload', False)
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:21,代碼來源:imp.py

示例5: test_add_callback

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
    def test_add_callback(self):

        def callback():
            pass

        RegistryManager.declare_entry('Other', assemble_callback=callback,
                                      initialize_callback=callback)
        hasModel = 'Model' in RegistryManager.declared_entries
        hasMixin = 'Mixin' in RegistryManager.declared_entries
        hasOther = 'Other' in RegistryManager.declared_entries
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)

        cb = Model.assemble_callback
        hasModelCb = cb == RegistryManager.callback_assemble_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_assemble_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        cb = Model.initialize_callback
        hasModelCb = cb == RegistryManager.callback_initialize_entries['Model']
        cb = callback
        hasOtherCb = cb == RegistryManager.callback_initialize_entries['Other']
        self.assertEqual(hasModelCb, True)
        self.assertEqual(hasOtherCb, True)

        RegistryManager.init_blok('newblok')
        is_exist = 'newblok' in RegistryManager.loaded_bloks
        self.assertEqual(is_exist, True)
        hasCore = 'Core' in RegistryManager.loaded_bloks['newblok']
        hasModel = 'Model' in RegistryManager.loaded_bloks['newblok']
        hasMixin = 'Mixin' in RegistryManager.loaded_bloks['newblok']
        hasOther = 'Other' in RegistryManager.loaded_bloks['newblok']
        self.assertEqual(hasCore, True)
        self.assertEqual(hasModel, True)
        self.assertEqual(hasMixin, True)
        self.assertEqual(hasOther, True)
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:41,代碼來源:test_registry_manager.py

示例6: test_global_property

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def test_global_property(self):
     RegistryManager.declare_entry('Other')
     blok = 'newblok'
     RegistryManager.init_blok(blok)
     try:
         oldblok = EnvironmentManager.get('current_blok')
         EnvironmentManager.set('current_blok', blok)
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
         RegistryManager.add_or_replace_blok_property('myproperty', 2)
         self.assertEqual(
             RegistryManager.has_blok_property('myproperty'), True)
         self.assertEqual(
             RegistryManager.get_blok_property('myproperty'), 2)
         RegistryManager.add_or_replace_blok_property('myproperty', 3)
         self.assertEqual(
             RegistryManager.get_blok_property('myproperty'), 3)
         RegistryManager.remove_blok_property('myproperty')
         self.assertEqual(RegistryManager.has_blok_property('myproperty'),
                          False)
     finally:
         EnvironmentManager.set('current_blok', oldblok)
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:24,代碼來源:test_registry_manager.py

示例7: setUpClass

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def setUpClass(cls):
     super(TestRegistryEntry, cls).setUpClass()
     RegistryManager.declare_entry('Other')
     RegistryManager.init_blok('testEntry')
     EnvironmentManager.set('current_blok', 'testEntry')
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:7,代碼來源:test_registry_entry.py

示例8: setUpClass

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def setUpClass(cls):
     super(TestCoreInterfaceMixin, cls).setUpClass()
     RegistryManager.init_blok('testMixin')
     EnvironmentManager.set('current_blok', 'testMixin')
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:6,代碼來源:test_mixin.py

示例9: setUpClass

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def setUpClass(cls):
     super(TestRegistryCore, cls).setUpClass()
     RegistryManager.declare_core('test')
     RegistryManager.init_blok('testCore')
     EnvironmentManager.set('current_blok', 'testCore')
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:7,代碼來源:test_registry_core.py

示例10: setUpClass

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def setUpClass(cls):
     super(TestCoreInterfaceCoreBase, cls).setUpClass()
     RegistryManager.init_blok('testCore' + cls._corename)
     EnvironmentManager.set('current_blok', 'testCore' + cls._corename)
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:6,代碼來源:test_core.py

示例11: setUpClass

# 需要導入模塊: from anyblok.registry import RegistryManager [as 別名]
# 或者: from anyblok.registry.RegistryManager import init_blok [as 別名]
 def setUpClass(cls):
     super(TestModel, cls).setUpClass()
     RegistryManager.init_blok('testModel')
     EnvironmentManager.set('current_blok', 'testModel')
開發者ID:jssuzanne,項目名稱:AnyBlok,代碼行數:6,代碼來源:test_model.py


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