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启动-加载模块(load_modules) odoo每次启动的时候都会加载模块,加载模块的过程就是调用load_modules 函数 在函数位于 odoo\modules\loading.py 代码中注释也写的很清楚,共分了9个步骤,其实是8个步骤。 这个函…...
【入门Flink】- 02Flink经典案例-WordCount
WordCount 需求:统计一段文字中,每个单词出现的频次 添加依赖 <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 命令,现在 stdout 和 stderr 直接进入控制台: cmd.Stdout os.Stdout cmd.Stderr os.Stderrpackage mainimport ("fmt"…...
OpenGL ES入门教程(二)之绘制一个平面桌子
OpenGL ES入门教程(二)之绘制一个平面桌子 前言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…...
基于单片机的商场防盗防火系统设计
收藏和点赞,您的关注是我创作的动力 文章目录 概要 一、系统分析二、系统总设计2.1基于单片机的商场防火防盗系统的总体功能2.2系统的组成 三 软件设计4.1软件设计思路4.2软件的实现4.2.1主控模块实物 四、 结论五、 文章目录 概要 本课题设计一种商场防火防盗报警…...
【Java|golang】2103. 环和杆---位运算
总计有 n 个环,环的颜色可以是红、绿、蓝中的一种。这些环分别穿在 10 根编号为 0 到 9 的杆上。 给你一个长度为 2n 的字符串 rings ,表示这 n 个环在杆上的分布。rings 中每两个字符形成一个 颜色位置对 ,用于描述每个环: 第 …...
[SSD综述 1.4] SSD固态硬盘的架构和功能导论
依公知及经验整理,原创保护,禁止转载。 专栏 《SSD入门到精通系列》 <<<< 返回总目录 <<<<  前言 机械硬盘的存储系统由于内部结构, 其IO访问性能无法进一步提高,CPU与存储器之间的性能差距逐渐扩大。以Nand Flash为存储介质的固态硬盘技术的发展,…...
【C++那些事儿】类与对象(1)
君兮_的个人主页 即使走的再远,也勿忘启程时的初心 C/C 游戏开发 Hello,米娜桑们,这里是君兮_,我之前看过一套书叫做《明朝那些事儿》,把本来枯燥的历史讲的生动有趣。而C作为一门接近底层的语言,无疑是抽象且难度颇…...
集简云x slack(自建)无需API开发轻松连接OA、电商、营销、CRM、用户运营、推广、客服等近千款系统
slack是一个工作效率管理平台,让每个人都能够使用无代码自动化和 AI 功能,还可以无缝连接搜索和知识共享,并确保团队保持联系和参与。在世界各地,Slack 不仅受到公司的信任,同时也是人们偏好使用的平台。 官网&#x…...
JS模块化,ESM模块规范的 导入、导出、引用、调用详解
JS模块化,ESM模块规范的 导入、导出、引用、调用详解 写在前面实例代码1、模块导出 - export导出之 - 独立导出导出之 - 集中多个导出导出之 - 默认导出导出之 - 集中默认导出导出之 - 混合导出 2、模块导入 - import导入之 - 全部导入导入之 - 默认导入导入之 - 指…...
markdown常用的快捷键
一级标题 #加 空格 是一级标题 二级标题 ##加空格是二级标题 三级标题 字体 * 粗体:两个**号 斜体:一个 斜体加粗:三个 删除:两个~~ 我是字体 我是字体 我是字体 我是字体 引用 箭头符号>加空格 回车 分割线 三个 - …...
VSCode中的任务什么情况下需要配置多个问题匹配器problemMatcher?多个问题匹配器之间的关系是什么?
☞ ░ 前往老猿Python博客 ░ https://blog.csdn.net/LaoYuanPython 一、简介 在 VS Code 中,tasks.json 文件中的 problemMatcher 字段用于定义如何解析任务输出中的问题(错误、警告等)。 problemMatcher是一个描述问题匹配器的接口&…...
C语言鞍点数组改进版
题目内容: 给定一个n*n矩阵A。矩阵A的鞍点是一个位置(i,j),在该位置上的元素是第i行上的最大数,第j列上的最小数。一个矩阵A也可能没有鞍点。 你的任务是找出A的鞍点。 改进目标: 网络上很多…...
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 网络通信: ●Pod 内容器与容器之间的通信 在同一个 Pod 内的容器(Pod 内的容…...
【数据结构】树家族
目录 树的相关术语树家族二叉树霍夫曼树二叉查找树 BST平衡二叉树 AVL红黑树伸展树替罪羊树 B树B树B* 树 当谈到数据结构中的树时,我们通常指的是一种分层的数据结构,它由节点(nodes)组成,这些节点之间以边(…...
Vert.x学习笔记-Vert.x的基本处理单元Verticle
Verticle介绍 Verticle是Vert.x的基本处理单元,Vert.x应用程序中存在着处理各种事件的处理单元,比如负责HTTP API响应请求的处理单元、负责数据库存取的处理单元、负责向第三方发送请求的处理单元。Verticle就是对这些功能单元的封装,Vertic…...
干货分享:基于 LSTM 的广告库存预估算法
近年来,随着互联网的发展,在线广告营销成为一种非常重要的商业模式。出于广告流量商业化售卖和日常业务投放精细化运营的目的,需要对广告流量进行更精准的预估,从而更精细的进行广告库存管理。 因此,携程广告纵横平台…...
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中…...
vscode里如何用git
打开vs终端执行如下: 1 初始化 Git 仓库(如果尚未初始化) git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...
Java 语言特性(面试系列2)
一、SQL 基础 1. 复杂查询 (1)连接查询(JOIN) 内连接(INNER JOIN):返回两表匹配的记录。 SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id d.dept_id; 左…...
ES6从入门到精通:前言
ES6简介 ES6(ECMAScript 2015)是JavaScript语言的重大更新,引入了许多新特性,包括语法糖、新数据类型、模块化支持等,显著提升了开发效率和代码可维护性。 核心知识点概览 变量声明 let 和 const 取代 var…...
UE5 学习系列(三)创建和移动物体
这篇博客是该系列的第三篇,是在之前两篇博客的基础上展开,主要介绍如何在操作界面中创建和拖动物体,这篇博客跟随的视频链接如下: B 站视频:s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...
Nuxt.js 中的路由配置详解
Nuxt.js 通过其内置的路由系统简化了应用的路由配置,使得开发者可以轻松地管理页面导航和 URL 结构。路由配置主要涉及页面组件的组织、动态路由的设置以及路由元信息的配置。 自动路由生成 Nuxt.js 会根据 pages 目录下的文件结构自动生成路由配置。每个文件都会对…...
RNN避坑指南:从数学推导到LSTM/GRU工业级部署实战流程
本文较长,建议点赞收藏,以免遗失。更多AI大模型应用开发学习视频及资料,尽在聚客AI学院。 本文全面剖析RNN核心原理,深入讲解梯度消失/爆炸问题,并通过LSTM/GRU结构实现解决方案,提供时间序列预测和文本生成…...
【碎碎念】宝可梦 Mesh GO : 基于MESH网络的口袋妖怪 宝可梦GO游戏自组网系统
目录 游戏说明《宝可梦 Mesh GO》 —— 局域宝可梦探索Pokmon GO 类游戏核心理念应用场景Mesh 特性 宝可梦玩法融合设计游戏构想要素1. 地图探索(基于物理空间 广播范围)2. 野生宝可梦生成与广播3. 对战系统4. 道具与通信5. 延伸玩法 安全性设计 技术选…...
什么是Ansible Jinja2
理解 Ansible Jinja2 模板 Ansible 是一款功能强大的开源自动化工具,可让您无缝地管理和配置系统。Ansible 的一大亮点是它使用 Jinja2 模板,允许您根据变量数据动态生成文件、配置设置和脚本。本文将向您介绍 Ansible 中的 Jinja2 模板,并通…...
dify打造数据可视化图表
一、概述 在日常工作和学习中,我们经常需要和数据打交道。无论是分析报告、项目展示,还是简单的数据洞察,一个清晰直观的图表,往往能胜过千言万语。 一款能让数据可视化变得超级简单的 MCP Server,由蚂蚁集团 AntV 团队…...
Pinocchio 库详解及其在足式机器人上的应用
Pinocchio 库详解及其在足式机器人上的应用 Pinocchio (Pinocchio is not only a nose) 是一个开源的 C 库,专门用于快速计算机器人模型的正向运动学、逆向运动学、雅可比矩阵、动力学和动力学导数。它主要关注效率和准确性,并提供了一个通用的框架&…...
