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

odoo启动-加载模块(load_modules)

odoo启动-加载模块(load_modules)

odoo每次启动的时候都会加载模块,加载模块的过程就是调用load_modules 函数

在函数位于 odoo\modules\loading.py

代码中注释也写的很清楚,共分了9个步骤,其实是8个步骤。

这个函数的作用是为一个新创建的注册表对象加载模块,这是Registry.new()的一部分,不应该用在其他地方。

def load_modules(registry, force_demo=False, status=None, update_module=False):""" 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_checks=update_module,report=report, models_to_check=models_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.#              It's 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(), order='name')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(log=True)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_checks=update_module,report=report, models_to_check=models_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.#              It's 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(), order='name')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(log=True)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_modules

step 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中有个变量可以区分。

哪个变量?

相关文章:

odoo启动-加载模块(load_modules)

odoo启动-加载模块&#xff08;load_modules&#xff09; odoo每次启动的时候都会加载模块&#xff0c;加载模块的过程就是调用load_modules 函数 在函数位于 odoo\modules\loading.py 代码中注释也写的很清楚&#xff0c;共分了9个步骤&#xff0c;其实是8个步骤。 这个函…...

【入门Flink】- 02Flink经典案例-WordCount

WordCount 需求&#xff1a;统计一段文字中&#xff0c;每个单词出现的频次 添加依赖 <properties><flink.version>1.17.0</flink.version></properties><dependencies><dependency><groupId>org.apache.flink</groupId><…...

go语言将cmd stdout和stderr作为字符串返回而不是打印到控制台

go语言将cmd stdout和stderr作为字符串返回而不是打印到控制台 1、直接打印到控制台 从 golang 应用程序中执行 bash 命令&#xff0c;现在 stdout 和 stderr 直接进入控制台&#xff1a; cmd.Stdout os.Stdout cmd.Stderr os.Stderrpackage mainimport ("fmt"…...

OpenGL ES入门教程(二)之绘制一个平面桌子

OpenGL ES入门教程&#xff08;二&#xff09;之绘制一个平面桌子 前言0. OpenGL绘制图形的整体框架概述1. 定义顶点2. 定义着色器3. 加载着色器4. 编译着色器5. 将着色器链接为OpenGL程序对象6. 将着色器需要的数据与拷贝到本地的数组相关联7. 在屏幕上绘制图形8. 让桌子有边框…...

el-select 搜索无选项时 请求接口添加输入的值

el-select 搜索无选项时 请求接口添加输入的值 <template><div class"flex"><el-select class"w250" v-model"state.brand.id" placeholder"请选择" clearable filterable :filter-method"handleQu…...

基于单片机的商场防盗防火系统设计

收藏和点赞&#xff0c;您的关注是我创作的动力 文章目录 概要 一、系统分析二、系统总设计2.1基于单片机的商场防火防盗系统的总体功能2.2系统的组成 三 软件设计4.1软件设计思路4.2软件的实现4.2.1主控模块实物 四、 结论五、 文章目录 概要 本课题设计一种商场防火防盗报警…...

【Java|golang】2103. 环和杆---位运算

总计有 n 个环&#xff0c;环的颜色可以是红、绿、蓝中的一种。这些环分别穿在 10 根编号为 0 到 9 的杆上。 给你一个长度为 2n 的字符串 rings &#xff0c;表示这 n 个环在杆上的分布。rings 中每两个字符形成一个 颜色位置对 &#xff0c;用于描述每个环&#xff1a; 第 …...

[SSD综述 1.4] SSD固态硬盘的架构和功能导论

依公知及经验整理,原创保护,禁止转载。 专栏 《SSD入门到精通系列》 <<<< 返回总目录 <<<< ​ 前言 机械硬盘的存储系统由于内部结构, 其IO访问性能无法进一步提高,CPU与存储器之间的性能差距逐渐扩大。以Nand Flash为存储介质的固态硬盘技术的发展,…...

【C++那些事儿】类与对象(1)

君兮_的个人主页 即使走的再远&#xff0c;也勿忘启程时的初心 C/C 游戏开发 Hello,米娜桑们&#xff0c;这里是君兮_&#xff0c;我之前看过一套书叫做《明朝那些事儿》&#xff0c;把本来枯燥的历史讲的生动有趣。而C作为一门接近底层的语言&#xff0c;无疑是抽象且难度颇…...

集简云x slack(自建)无需API开发轻松连接OA、电商、营销、CRM、用户运营、推广、客服等近千款系统

slack是一个工作效率管理平台&#xff0c;让每个人都能够使用无代码自动化和 AI 功能&#xff0c;还可以无缝连接搜索和知识共享&#xff0c;并确保团队保持联系和参与。在世界各地&#xff0c;Slack 不仅受到公司的信任&#xff0c;同时也是人们偏好使用的平台。 官网&#x…...

JS模块化,ESM模块规范的 导入、导出、引用、调用详解

JS模块化&#xff0c;ESM模块规范的 导入、导出、引用、调用详解 写在前面实例代码1、模块导出 - export导出之 - 独立导出导出之 - 集中多个导出导出之 - 默认导出导出之 - 集中默认导出导出之 - 混合导出 2、模块导入 - import导入之 - 全部导入导入之 - 默认导入导入之 - 指…...

markdown常用的快捷键

一级标题 #加 空格 是一级标题 二级标题 ##加空格是二级标题 三级标题 字体 * 粗体&#xff1a;两个**号 斜体&#xff1a;一个 斜体加粗&#xff1a;三个 删除&#xff1a;两个~~ 我是字体 我是字体 我是字体 我是字体 引用 箭头符号>加空格 回车 分割线 三个 - …...

VSCode中的任务什么情况下需要配置多个问题匹配器problemMatcher?多个问题匹配器之间的关系是什么?

☞ ░ 前往老猿Python博客 ░ https://blog.csdn.net/LaoYuanPython 一、简介 在 VS Code 中&#xff0c;tasks.json 文件中的 problemMatcher 字段用于定义如何解析任务输出中的问题&#xff08;错误、警告等&#xff09;。 problemMatcher是一个描述问题匹配器的接口&…...

C语言鞍点数组改进版

题目内容&#xff1a; 给定一个n*n矩阵A。矩阵A的鞍点是一个位置&#xff08;i&#xff0c;j&#xff09;&#xff0c;在该位置上的元素是第i行上的最大数&#xff0c;第j列上的最小数。一个矩阵A也可能没有鞍点。 你的任务是找出A的鞍点。 改进目标&#xff1a; 网络上很多…...

K8s:部署 CNI 网络组件+k8s 多master集群部署+负载均衡及Dashboard k8s仪表盘图像化展示

目录 1 部署 CNI 网络组件 1.1 部署 flannel 1.2 部署 Calico 1.3 部署 CoreDNS 2 负载均衡部署 3 部署 Dashboard 1 部署 CNI 网络组件 1.1 部署 flannel K8S 中 Pod 网络通信&#xff1a; ●Pod 内容器与容器之间的通信 在同一个 Pod 内的容器&#xff08;Pod 内的容…...

【数据结构】树家族

目录 树的相关术语树家族二叉树霍夫曼树二叉查找树 BST平衡二叉树 AVL红黑树伸展树替罪羊树 B树B树B* 树 当谈到数据结构中的树时&#xff0c;我们通常指的是一种分层的数据结构&#xff0c;它由节点&#xff08;nodes&#xff09;组成&#xff0c;这些节点之间以边&#xff08…...

Vert.x学习笔记-Vert.x的基本处理单元Verticle

Verticle介绍 Verticle是Vert.x的基本处理单元&#xff0c;Vert.x应用程序中存在着处理各种事件的处理单元&#xff0c;比如负责HTTP API响应请求的处理单元、负责数据库存取的处理单元、负责向第三方发送请求的处理单元。Verticle就是对这些功能单元的封装&#xff0c;Vertic…...

干货分享:基于 LSTM 的广告库存预估算法

近年来&#xff0c;随着互联网的发展&#xff0c;在线广告营销成为一种非常重要的商业模式。出于广告流量商业化售卖和日常业务投放精细化运营的目的&#xff0c;需要对广告流量进行更精准的预估&#xff0c;从而更精细的进行广告库存管理。 因此&#xff0c;携程广告纵横平台…...

dataframe删除某一列

drop import pandas as pd data {‘A’: [1, 2, 3], ‘B’: [4, 5, 6], ‘C’: [7, 8, 9]} df pd.DataFrame(data) #使用drop方法删除列 df df.drop(‘B’, axis1) # 通过指定列名和axis1来删除列 del import pandas as pd data {‘A’: [1, 2, 3], ‘B’: [4, 5, 6]…...

提升ChatGPT答案质量和准确性的方法Prompt engineering

文章目录 怎么获得优质的答案设计一个优质prompt的步骤:Prompt公式:示例怎么获得优质的答案 影响模型回答精确度的因素 我们应该知道一个好的提示词,要具备一下要点: 清晰简洁,不要有歧义; 有明确的任务/问题,任务如果太复杂,需要拆分成子任务分步完成; 确保prompt中…...

C++实现分布式网络通信框架RPC(3)--rpc调用端

目录 一、前言 二、UserServiceRpc_Stub 三、 CallMethod方法的重写 头文件 实现 四、rpc调用端的调用 实现 五、 google::protobuf::RpcController *controller 头文件 实现 六、总结 一、前言 在前边的文章中&#xff0c;我们已经大致实现了rpc服务端的各项功能代…...

云启出海,智联未来|阿里云网络「企业出海」系列客户沙龙上海站圆满落地

借阿里云中企出海大会的东风&#xff0c;以**「云启出海&#xff0c;智联未来&#xff5c;打造安全可靠的出海云网络引擎」为主题的阿里云企业出海客户沙龙云网络&安全专场于5.28日下午在上海顺利举办&#xff0c;现场吸引了来自携程、小红书、米哈游、哔哩哔哩、波克城市、…...

ESP32 I2S音频总线学习笔记(四): INMP441采集音频并实时播放

简介 前面两期文章我们介绍了I2S的读取和写入&#xff0c;一个是通过INMP441麦克风模块采集音频&#xff0c;一个是通过PCM5102A模块播放音频&#xff0c;那如果我们将两者结合起来&#xff0c;将麦克风采集到的音频通过PCM5102A播放&#xff0c;是不是就可以做一个扩音器了呢…...

spring:实例工厂方法获取bean

spring处理使用静态工厂方法获取bean实例&#xff0c;也可以通过实例工厂方法获取bean实例。 实例工厂方法步骤如下&#xff1a; 定义实例工厂类&#xff08;Java代码&#xff09;&#xff0c;定义实例工厂&#xff08;xml&#xff09;&#xff0c;定义调用实例工厂&#xff…...

三体问题详解

从物理学角度&#xff0c;三体问题之所以不稳定&#xff0c;是因为三个天体在万有引力作用下相互作用&#xff0c;形成一个非线性耦合系统。我们可以从牛顿经典力学出发&#xff0c;列出具体的运动方程&#xff0c;并说明为何这个系统本质上是混沌的&#xff0c;无法得到一般解…...

QT3D学习笔记——圆台、圆锥

类名作用Qt3DWindow3D渲染窗口容器QEntity场景中的实体&#xff08;对象或容器&#xff09;QCamera控制观察视角QPointLight点光源QConeMesh圆锥几何网格QTransform控制实体的位置/旋转/缩放QPhongMaterialPhong光照材质&#xff08;定义颜色、反光等&#xff09;QFirstPersonC…...

【JVM】Java虚拟机(二)——垃圾回收

目录 一、如何判断对象可以回收 &#xff08;一&#xff09;引用计数法 &#xff08;二&#xff09;可达性分析算法 二、垃圾回收算法 &#xff08;一&#xff09;标记清除 &#xff08;二&#xff09;标记整理 &#xff08;三&#xff09;复制 &#xff08;四&#xff…...

数学建模-滑翔伞伞翼面积的设计,运动状态计算和优化 !

我们考虑滑翔伞的伞翼面积设计问题以及运动状态描述。滑翔伞的性能主要取决于伞翼面积、气动特性以及飞行员的重量。我们的目标是建立数学模型来描述滑翔伞的运动状态,并优化伞翼面积的设计。 一、问题分析 滑翔伞在飞行过程中受到重力、升力和阻力的作用。升力和阻力与伞翼面…...

针对药品仓库的效期管理问题,如何利用WMS系统“破局”

案例&#xff1a; 某医药分销企业&#xff0c;主要经营各类药品的批发与零售。由于药品的特殊性&#xff0c;效期管理至关重要&#xff0c;但该企业一直面临效期问题的困扰。在未使用WMS系统之前&#xff0c;其药品入库、存储、出库等环节的效期管理主要依赖人工记录与检查。库…...

深入解析 ReentrantLock:原理、公平锁与非公平锁的较量

ReentrantLock 是 Java 中 java.util.concurrent.locks 包下的一个重要类,用于实现线程同步,支持可重入性,并且可以选择公平锁或非公平锁的实现方式。下面将详细介绍 ReentrantLock 的实现原理以及公平锁和非公平锁的区别。 ReentrantLock 实现原理 基本架构 ReentrantLo…...