当前位置: 首页 > news >正文

征婚网站建设昆明做网站建设方案

征婚网站建设,昆明做网站建设方案,wordpress开发教程 pdf,网站蜘蛛爬行统计系统odoo启动-加载模块#xff08;load_modules#xff09; odoo每次启动的时候都会加载模块#xff0c;加载模块的过程就是调用load_modules 函数 在函数位于 odoo\modules\loading.py 代码中注释也写的很清楚#xff0c;共分了9个步骤#xff0c;其实是8个步骤。 这个函…odoo启动-加载模块load_modules odoo每次启动的时候都会加载模块加载模块的过程就是调用load_modules 函数 在函数位于 odoo\modules\loading.py 代码中注释也写的很清楚共分了9个步骤其实是8个步骤。 这个函数的作用是为一个新创建的注册表对象加载模块这是Registry.new()的一部分不应该用在其他地方。 def load_modules(registry, force_demoFalse, statusNone, update_moduleFalse): Load the modules for a registry object that has just been created. Thisfunction is part of Registry.new() and should not be used anywhere else.initialize_sys_path()force []if force_demo:force.append(demo)models_to_check set()with registry.cursor() as cr:# prevent endless wait for locks on schema changes (during online# installs) if a concurrent transaction has accessed the table;# connection settings are automatically reset when the connection is# borrowed from the poolcr.execute(SET SESSION lock_timeout 15s)if not odoo.modules.db.is_initialized(cr):if not update_module:_logger.error(Database %s not initialized, you can force it with -i base, cr.dbname)return_logger.info(init db)odoo.modules.db.initialize(cr)update_module True # process auto-installed modulestools.config[init][all] 1if not tools.config[without_demo]:tools.config[demo][all] 1if base in tools.config[update] or all in tools.config[update]:cr.execute(update ir_module_module set state%s where name%s and state%s, (to upgrade, base, installed))# STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps)graph odoo.modules.graph.Graph()graph.add_module(cr, base, force)if not graph:_logger.critical(module base cannot be loaded! (hint: verify addons-path))raise ImportError(Module base cannot be loaded! (hint: verify addons-path))if update_module and odoo.tools.table_exists(cr, ir_model_fields):# determine the fields which are currently translated in the databasecr.execute(SELECT model || . || name FROM ir_model_fields WHERE translate IS TRUE)registry._database_translated_fields {row[0] for row in cr.fetchall()}# processed_modules: for cleanup step after install# loaded_modules: to avoid double loadingreport registry._assertion_reportloaded_modules, processed_modules load_module_graph(cr, graph, status, perform_checksupdate_module,reportreport, models_to_checkmodels_to_check)load_lang tools.config.pop(load_language)if load_lang or update_module:# some base models are used below, so make sure they are set upregistry.setup_models(cr)if load_lang:for lang in load_lang.split(,):tools.load_language(cr, lang)# STEP 2: Mark other modules to be loaded/updatedif update_module:env api.Environment(cr, SUPERUSER_ID, {})Module env[ir.module.module]_logger.info(updating modules list)Module.update_list()_check_module_names(cr, itertools.chain(tools.config[init], tools.config[update]))module_names [k for k, v in tools.config[init].items() if v]if module_names:modules Module.search([(state, , uninstalled), (name, in, module_names)])if modules:modules.button_install()module_names [k for k, v in tools.config[update].items() if v]if module_names:modules Module.search([(state, in, (installed, to upgrade)), (name, in, module_names)])if modules:modules.button_upgrade()env.flush_all()cr.execute(update ir_module_module set state%s where name%s, (installed, base))Module.invalidate_model([state])# STEP 3: Load marked modules (skipping base which was done in STEP 1)# IMPORTANT: this is done in two parts, first loading all installed or# partially installed modules (i.e. installed/to upgrade), to# offer a consistent system to the second part: installing# newly selected modules.# We include the modules to remove in the first step, because# they are part of the currently installed modules. They will# be dropped in STEP 6 later, before restarting the loading# process.# IMPORTANT 2: We have to loop here until all relevant modules have been# processed, because in some rare cases the dependencies have# changed, and modules that depend on an uninstalled module# will not be processed on the first pass.# Its especially useful for migrations.previously_processed -1while previously_processed len(processed_modules):previously_processed len(processed_modules)processed_modules load_marked_modules(cr, graph,[installed, to upgrade, to remove],force, status, report, loaded_modules, update_module, models_to_check)if update_module:processed_modules load_marked_modules(cr, graph,[to install], force, status, report,loaded_modules, update_module, models_to_check)if update_module:# set up the registry without the patch for translated fieldsdatabase_translated_fields registry._database_translated_fieldsregistry._database_translated_fields ()registry.setup_models(cr)# determine which translated fields should no longer be translated,# and make their model fix the database schemamodels_to_untranslate set()for full_name in database_translated_fields:model_name, field_name full_name.rsplit(., 1)if model_name in registry:field registry[model_name]._fields.get(field_name)if field and not field.translate:_logger.debug(Making field %s non-translated, field)models_to_untranslate.add(model_name)registry.init_models(cr, list(models_to_untranslate), {models_to_check: True})registry.loaded Trueregistry.setup_models(cr)# check that all installed modules have been loaded by the registryenv api.Environment(cr, SUPERUSER_ID, {})Module env[ir.module.module]modules Module.search(Module._get_modules_to_load_domain(), ordername)missing [name for name in modules.mapped(name) if name not in graph]if missing:_logger.error(Some modules are not loaded, some dependencies or manifest may be missing: %s, missing)# STEP 3.5: execute migration end-scriptsmigrations odoo.modules.migration.MigrationManager(cr, graph)for package in graph:migrations.migrate_module(package, end)# check that new module dependencies have been properly installed after a migration/upgradecr.execute(SELECT name from ir_module_module WHERE state IN (to install, to upgrade))module_list [name for (name,) in cr.fetchall()]if module_list:_logger.error(Some modules have inconsistent states, some dependencies may be missing: %s, sorted(module_list))# STEP 3.6: apply remaining constraints in case of an upgraderegistry.finalize_constraints()# STEP 4: Finish and cleanup installationsif processed_modules:env api.Environment(cr, SUPERUSER_ID, {})cr.execute(SELECT model from ir_model)for (model,) in cr.fetchall():if model in registry:env[model]._check_removed_columns(logTrue)elif _logger.isEnabledFor(logging.INFO): # more an info that a warning..._logger.runbot(Model %s is declared but cannot be loaded! (Perhaps a module was partially removed or renamed), model)# Cleanup orphan recordsenv[ir.model.data]._process_end(processed_modules)env.flush_all()for kind in (init, demo, update):tools.config[kind] {}# STEP 5: Uninstall modules to removeif update_module:# Remove records referenced from ir_model_data for modules to be# removed (and removed the references from ir_model_data).cr.execute(SELECT name, id FROM ir_module_module WHERE state%s, (to remove,))modules_to_remove dict(cr.fetchall())if modules_to_remove:env api.Environment(cr, SUPERUSER_ID, {})pkgs reversed([p for p in graph if p.name in modules_to_remove])for pkg in pkgs:uninstall_hook pkg.info.get(uninstall_hook)if uninstall_hook:py_module sys.modules[odoo.addons.%s % (pkg.name,)]getattr(py_module, uninstall_hook)(cr, registry)env.flush_all()Module env[ir.module.module]Module.browse(modules_to_remove.values()).module_uninstall()# Recursive reload, should only happen once, because there should be no# modules to remove next timecr.commit()_logger.info(Reloading registry once more after uninstalling modules)registry odoo.modules.registry.Registry.new(cr.dbname, force_demo, status, update_module)cr.reset()registry.check_tables_exist(cr)cr.commit()return registry# STEP 5.5: Verify extended fields on every model# This will fix the schema of all models in a situation such as:# - module A is loaded and defines model M;# - module B is installed/upgraded and extends model M;# - module C is loaded and extends model M;# - module B and C depend on A but not on each other;# The changes introduced by module C are not taken into account by the upgrade of B.if models_to_check:registry.init_models(cr, list(models_to_check), {models_to_check: True})# STEP 6: verify custom views on every modelif update_module:env api.Environment(cr, SUPERUSER_ID, {})env[res.groups]._update_user_groups_view()View env[ir.ui.view]for model in registry:try:View._validate_custom_views(model)except Exception as e:_logger.warning(invalid custom view(s) for model %s: %s, model, tools.ustr(e))if report.wasSuccessful():_logger.info(Modules loaded.)else:_logger.error(At least one test failed when loading the modules.)# STEP 8: save installed/updated modules for post-install tests and _register_hookregistry.updated_modules processed_modules# STEP 9: call _register_hook on every model# This is done *exactly once* when the registry is being loaded. See the# management of those hooks in Registry.setup_models: all the calls to# setup_models() done here do not mess up with hooks, as registry.ready# is False.env api.Environment(cr, SUPERUSER_ID, {})for model in env.values():model._register_hook()env.flush_all() 0、初始化数据库 这里判断数据库有没有被初始化如果没有就安装base模块 initialize_sys_path()force []if force_demo:force.append(demo)models_to_check set()with registry.cursor() as cr:# prevent endless wait for locks on schema changes (during online# installs) if a concurrent transaction has accessed the table;# connection settings are automatically reset when the connection is# borrowed from the poolcr.execute(SET SESSION lock_timeout 15s)if not odoo.modules.db.is_initialized(cr):if not update_module:_logger.error(Database %s not initialized, you can force it with -i base, cr.dbname)return_logger.info(init db)odoo.modules.db.initialize(cr)update_module True # process auto-installed modulestools.config[init][all] 1if not tools.config[without_demo]:tools.config[demo][all] 1if base in tools.config[update] or all in tools.config[update]:cr.execute(update ir_module_module set state%s where name%s and state%s, (to upgrade, base, installed)) step 1、加载base模块 第一步就是加载base模块 最后还加载了其他模块的语言包 SELECT model || . || name FROM ir_model_fields WHERE translate IS TRUE #原来pg使用|| 来拼接字符串的。registry._database_translated_fields {row[0] for row in cr.fetchall()} # 这个写法也很有意思简洁# STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps)graph odoo.modules.graph.Graph()graph.add_module(cr, base, force)if not graph:_logger.critical(module base cannot be loaded! (hint: verify addons-path))raise ImportError(Module base cannot be loaded! (hint: verify addons-path))if update_module and odoo.tools.table_exists(cr, ir_model_fields):# determine the fields which are currently translated in the databasecr.execute(SELECT model || . || name FROM ir_model_fields WHERE translate IS TRUE)registry._database_translated_fields {row[0] for row in cr.fetchall()} # processed_modules: for cleanup step after install# loaded_modules: to avoid double loadingreport registry._assertion_reportloaded_modules, processed_modules load_module_graph(cr, graph, status, perform_checksupdate_module,reportreport, models_to_checkmodels_to_check)load_lang tools.config.pop(load_language)if load_lang or update_module:# some base models are used below, so make sure they are set upregistry.setup_models(cr)if load_lang:for lang in load_lang.split(,):tools.load_language(cr, lang)控制台输出 2023-11-04 07:58:50,981 1340 INFO ? odoo.service.server: HTTP service (werkzeug) running on LAPTOP-AV3CF7SO:8069 2023-11-04 07:58:50,987 1340 INFO odoo2 odoo.modules.loading: loading 1 modules... 2023-11-04 07:58:51,008 1340 INFO odoo2 odoo.modules.loading: 1 modules loaded in 0.02s, 0 queries (0 extra) 2023-11-04 07:58:51,154 1340 INFO odoo2 odoo.addons.base.models.ir_module: module base: loading translation file zh_CN for language zh_CN 2023-11-04 07:58:52,077 1340 INFO odoo2 odoo.addons.base.models.ir_module: module web: loading translation file zh_CN for language zh_CN 2023-11-04 07:58:52,256 1340 INFO odoo2 odoo.addons.base.models.ir_module: module base_setup: loading translation file zh_CN for language zh_CN 2023-11-04 07:58:52,282 1340 INFO odoo2 odoo.addons.base.models.ir_module: module bus: loading translation file zh_CN for language zh_CN 2023-11-04 07:58:52,295 1340 INFO odoo2 odoo.addons.base.models.ir_module: module web_tour: loading translation file zh_CN for language zh_CN 2023-11-04 07:58:52,304 1340 INFO odoo2 odoo.addons.base.models.ir_module: module mail: loading translation file zh_CN for language zh_CN 中间省略N行.... sql_constraint:cf.report.define.field 2023-11-04 07:58:54,087 1340 INFO odoo2 odoo.tools.translate: Skipped deprecated occurrence sql_constraint:cf.report.define 2023-11-04 07:58:54,087 1340 INFO odoo2 odoo.tools.translate: Skipped deprecated occurrence selection:cf.report.define,state 2023-11-04 07:58:54,094 1340 INFO odoo2 odoo.addons.base.models.ir_module: module estate: no translation for language zh_CN 2023-11-04 07:58:54,102 1340 INFO odoo2 odoo.addons.base.models.ir_module: module hx_base: no translation for language zh_CN 2023-11-04 07:58:54,115 1340 INFO odoo2 odoo.addons.base.models.ir_module: module hx_chp: no translation for language zh_CN 2023-11-04 07:58:54,122 1340 INFO odoo2 odoo.addons.base.models.ir_module: module hx_gift: no translation for language zh_CN 2023-11-04 07:58:54,129 1340 INFO odoo2 odoo.addons.base.models.ir_module: module hx_jixiao: no translation for language zh_CN 2023-11-04 07:58:54,136 1340 INFO odoo2 odoo.addons.base.models.ir_module: module hx_tsl: no translation for language zh_CN 2023-11-04 07:58:54,143 1340 INFO odoo2 odoo.addons.base.models.ir_module: module auth_totp: loading translation file zh_CN for step 2、加载或者升级其他模块 # STEP 2: Mark other modules to be loaded/updatedif update_module:env api.Environment(cr, SUPERUSER_ID, {})Module env[ir.module.module]_logger.info(updating modules list)Module.update_list()_check_module_names(cr, itertools.chain(tools.config[init], tools.config[update]))module_names [k for k, v in tools.config[init].items() if v]if module_names:modules Module.search([(state, , uninstalled), (name, in, module_names)])if modules:modules.button_install()module_names [k for k, v in tools.config[update].items() if v]if module_names:modules Module.search([(state, in, (installed, to upgrade)), (name, in, module_names)])if modules:modules.button_upgrade()env.flush_all()cr.execute(update ir_module_module set state%s where name%s, (installed, base))Module.invalidate_model([state])如果没有这一步就跳过了 step 3、加载除了base之外的其他模块 1、分两个步骤完成第一步加载所有已经安装的或者部分安装需要升级为第二步提供一个一致性的系统。第二步是安装新的模块。 我们在第一步中考虑了to_remove 的模块因为他们是“已安装”模块的一部分 他们将在step 6 去处理。 2、这里不得不循环处理因为要处理模块之间的依赖关系 ​ # STEP 3: Load marked modules (skipping base which was done in STEP 1)# IMPORTANT: this is done in two parts, first loading all installed or# partially installed modules (i.e. installed/to upgrade), to# offer a consistent system to the second part: installing# newly selected modules.# We include the modules to remove in the first step, because# they are part of the currently installed modules. They will# be dropped in STEP 6 later, before restarting the loading# process.# IMPORTANT 2: We have to loop here until all relevant modules have been# processed, because in some rare cases the dependencies have# changed, and modules that depend on an uninstalled module# will not be processed on the first pass.# Its especially useful for migrations.previously_processed -1# 循环加载处理相关模块while previously_processed len(processed_modules):previously_processed len(processed_modules)processed_modules load_marked_modules(cr, graph,[installed, to upgrade, to remove],force, status, report, loaded_modules, update_module, models_to_check)if update_module:processed_modules load_marked_modules(cr, graph,[to install], force, status, report,loaded_modules, update_module, models_to_check)# 处理需要升级的模块if update_module:# set up the registry without the patch for translated fieldsdatabase_translated_fields registry._database_translated_fieldsregistry._database_translated_fields ()registry.setup_models(cr)# determine which translated fields should no longer be translated,# and make their model fix the database schemamodels_to_untranslate set()for full_name in database_translated_fields:model_name, field_name full_name.rsplit(., 1)if model_name in registry:field registry[model_name]._fields.get(field_name)if field and not field.translate:_logger.debug(Making field %s non-translated, field)models_to_untranslate.add(model_name)registry.init_models(cr, list(models_to_untranslate), {models_to_check: True})registry.loaded Trueregistry.setup_models(cr)# check that all installed modules have been loaded by the registryenv api.Environment(cr, SUPERUSER_ID, {})Module env[ir.module.module]modules Module.search(Module._get_modules_to_load_domain(), ordername)missing [name for name in modules.mapped(name) if name not in graph]if missing:_logger.error(Some modules are not loaded, some dependencies or manifest may be missing: %s, missing)# STEP 3.5: execute migration end-scriptsmigrations odoo.modules.migration.MigrationManager(cr, graph)for package in graph:migrations.migrate_module(package, end)# check that new module dependencies have been properly installed after a migration/upgradecr.execute(SELECT name from ir_module_module WHERE state IN (to install, to upgrade))module_list [name for (name,) in cr.fetchall()]if module_list:_logger.error(Some modules have inconsistent states, some dependencies may be missing: %s, sorted(module_list))# STEP 3.6: apply remaining constraints in case of an upgraderegistry.finalize_constraints()控制台输出 2023-11-04 08:16:23,488 11076 INFO odoo2 odoo.modules.loading: loading 54 modules... 2023-11-04 08:16:23,882 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.hx_chp.models.change_point is not overriding the create method 2023-11-04 08:16:23,944 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.hx_tsl.models.hx_tsl_info is not overriding the create method in batch 2023-11-04 08:16:24,292 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.cfprint.models.cfprint_server_user_map is not overriding the create method in batch 2023-11-04 08:16:25,047 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.cf_report_designer.models.data_model_3 is not overriding the create method in batch 2023-11-04 08:16:25,069 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.cf_report_designer.models.data_model_4 is not overriding the create method in batch 2023-11-04 08:16:25,071 11076 WARNING odoo2 odoo.api.create: The model odoo.addons.cf_report_designer.models.data_model_4 is not overriding the create method in batch 2023-11-04 08:16:25,416 11076 INFO odoo2 odoo.modules.loading: 54 modules loaded in 1.93s, 0 queries (0 extra) step 4、完成并且清理安装过程 基本就是一些善后过程正常情况下不会执行 # STEP 4: Finish and cleanup installationsif processed_modules:env api.Environment(cr, SUPERUSER_ID, {})cr.execute(SELECT model from ir_model)for (model,) in cr.fetchall():if model in registry:env[model]._check_removed_columns(logTrue)elif _logger.isEnabledFor(logging.INFO): # more an info that a warning..._logger.runbot(Model %s is declared but cannot be loaded! (Perhaps a module was partially removed or renamed), model)# Cleanup orphan recordsenv[ir.model.data]._process_end(processed_modules)env.flush_all()for kind in (init, demo, update):tools.config[kind] {} step 5、卸载相关模块 SELECT name, id FROM ir_module_module WHERE state%s, (to remove,)如果配置了uninstall_hook要在这里执行。 然后调用module_uninstall方法来卸载 Module.browse(modules_to_remove.values()).module_uninstall()卸载完成之后刷新注册表。 5.5 是要处理一些模型之间的依赖关系。 # STEP 5: Uninstall modules to removeif update_module:# Remove records referenced from ir_model_data for modules to be# removed (and removed the references from ir_model_data).cr.execute(SELECT name, id FROM ir_module_module WHERE state%s, (to remove,))modules_to_remove dict(cr.fetchall())if modules_to_remove:env api.Environment(cr, SUPERUSER_ID, {})pkgs reversed([p for p in graph if p.name in modules_to_remove])for pkg in pkgs:uninstall_hook pkg.info.get(uninstall_hook)if uninstall_hook:py_module sys.modules[odoo.addons.%s % (pkg.name,)]getattr(py_module, uninstall_hook)(cr, registry)env.flush_all()Module env[ir.module.module]Module.browse(modules_to_remove.values()).module_uninstall()# Recursive reload, should only happen once, because there should be no# modules to remove next timecr.commit()_logger.info(Reloading registry once more after uninstalling modules)registry odoo.modules.registry.Registry.new(cr.dbname, force_demo, status, update_module)cr.reset()registry.check_tables_exist(cr)cr.commit()return registry# STEP 5.5: Verify extended fields on every model# This will fix the schema of all models in a situation such as:# - module A is loaded and defines model M;# - module B is installed/upgraded and extends model M;# - module C is loaded and extends model M;# - module B and C depend on A but not on each other;# The changes introduced by module C are not taken into account by the upgrade of B.if models_to_check:registry.init_models(cr, list(models_to_check), {models_to_check: True})step 6、确认每个模型相关的视图 # STEP 6: verify custom views on every modelif update_module:env api.Environment(cr, SUPERUSER_ID, {})env[res.groups]._update_user_groups_view()View env[ir.ui.view]for model in registry:try:View._validate_custom_views(model)except Exception as e:_logger.warning(invalid custom view(s) for model %s: %s, model, tools.ustr(e))if report.wasSuccessful():_logger.info(Modules loaded.)else:_logger.error(At least one test failed when loading the modules.)控制台输出 2023-11-04 08:35:43,841 11076 INFO odoo2 odoo.modules.loading: Modules loaded. step 8、保存安装或者升级的视图 为了post-install测试 和调用_register_hook step7 哪去了 # STEP 8: save installed/updated modules for post-install tests and _register_hookregistry.updated_modules processed_modulesstep 9、调用_register_hook 对每个model模型调用_register_hook,每次启动的时候都会调用能干什么呢 # STEP 9: call _register_hook on every model# This is done *exactly once* when the registry is being loaded. See the# management of those hooks in Registry.setup_models: all the calls to# setup_models() done here do not mess up with hooks, as registry.ready# is False.env api.Environment(cr, SUPERUSER_ID, {})for model in env.values():model._register_hook()env.flush_all()models.py def _register_hook(self): stuff to do right after the registry is built def _unregister_hook(self): Clean up what ~._register_hook has done. _register_hook 有什么用 可以在模块加载完之后动态修改模型的一些属性值。 比如修改_rec_name def _register_hook(self):setattr(type(self),_rec_name, myname)安装模块的时候也会执行load_modules函数重新加载所有的模块如果你希望你的逻辑只有在启动的时候执行而不是安装模块的时候执行在context中有个变量可以区分。 哪个变量
http://www.w-s-a.com/news/917222/

相关文章:

  • 和县建设局网站孟州网站建设
  • 网站与规划设计思路竞价培训课程
  • 网站建设设计视频专业设计企业网站
  • 湖南省建设工程网站cerntos wordpress
  • 主机屋的免费空间怎么上传网站广告公司的经营范围有哪些
  • 门户网站建设公司案例门户建设是什么意思
  • 深圳seo专家东莞网站关键词优化排名
  • 套用别人产品图片做网站如何在阿里云自主建网站
  • 网站开发需要用哪些东西wordpress页面参数
  • 大连模板网站制作哪家好wordpress 安装不上
  • 宝塔搭建网站首页图片点击率如何提高
  • 长沙找人做网站wordpress如何安装模板
  • 比较好的国外网站建设公司wordpress短代码可视化
  • 做新的网站网站个性化
  • 吉安做网站的英文网站 字体大小
  • 外贸网站服务商wordpress主题handsome
  • 云主机多个网站如何优化网站图片
  • 松江移动网站建设成都app开发制作公司
  • 锦州做网站的公司百度seo搜索营销新视角
  • 做画册找什么网站海南建设工程股份有限公司网站
  • 网站机房建设有助于网站备案
  • 北辰苏州网站建设抖音代运营投诉平台
  • 安徽住房与城乡建设部网站如何新建站点
  • 企业网站开发的感想网站开发公司所需投入资源
  • 如何拿网站后台账号wordpress 电影下载站源码
  • 公司网站建设方案书安卓应用市场免费下载安装
  • phpmysql网站设计建设好一个网站需要
  • 自己做的网站能被别人看到吗idea怎么做网页
  • 燕莎网站建设互联网排名前十的公司2021
  • 微软云怎么做网站微商城和小程序区别