7.odoo入门——初探odoo后台启动过程(一)

来源:互联网 发布:optisystem mac air 编辑:程序博客网 时间:2024/06/07 06:38

“投资理财”项目——设计需求文档

导师要求用Xmind设计需求文档——不过我们今天并没有整这个东西,因为需求不明确

同组师兄要求我学习jQuery,我就去看jQuery教程:

http://www.runoob.com/jquery/jquery-tutorial.html

在学习过程中会用到CSS选择器,事件触发,回调函数(好想好多编程语言里面都有这个概念)

基本扫过了一遍所有的知识点,等到运用的时候现用现查。

参考:

 http://www.bubuko.com/infodetail-1892284.html

http://www.cnblogs.com/qianheng/p/6240819.html



回到之前关于odoo启动的过程:

进入cli目录,先执行的是__init__.py脚本,那么看到cli/__init__.py的代码:

import loggingimport sysimport osimport odoofrom command import Command, mainimport deployimport scaffoldimport serverimport shellimport start

看到第7行,从command.py中import了main函数,所以我们运行的odoo.cli.main()函数执行的是command.py下的main()函数:

回想起在start.py中的一个注释:

# use: python start.py -c config/local.config

再看到odoo10/config/local.config下的文件结构大致是:

db_host = 127.0.0.1xxx = xxx...

其实就是传入了一堆命令行参数,看到command.py下的main()函数:

def main():    args = sys.argv[1:]#可以参考:https://zhidao.baidu.com/question/1831257626170092300.html#那么得到了后续输入的所有命令行参数    # The only shared option is '--addons-path=' needed to discover additional    # commands from modules    if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"):        # parse only the addons-path, do not setup the logger...        odoo.tools.config._parse_config([args[0]])        args = args[1:]    # Default legacy command#上述语句中,由于我们的配置文件config/local.config的开头是 #db_host = 127.0.0.1#那么上述if语句不执行    command = "server"    # TODO: find a way to properly discover addons subcommands without importing the world    # Subcommand discovery    if len(args) and not args[0].startswith("-"): #args[0] = “-c”,不进入        logging.disable(logging.CRITICAL)#参考   http://www.bitscn.com/Python/536260.html#其作用是禁用所有日志(当其级别在给定级及以下),暂时截流日志输出#也就是要在logging.CRITICAL级别以上时才记录在日志中(但是CRITICAL是最高级别了- - )        for module in get_modules():#看到在头文件中有一句代码:from odoo.modules import get_modules, #在odor/modules/module.py中有get_modules()函数#我们暂时不去考虑它的实现过程,反正它返回了含各个模块名字的列表            if isdir(joinpath(get_module_path(module), 'cli')):                __import__('odoo.addons.' + module)#参考 http://david-je.iteye.com/blog/1756788 , 其实就是导入了这个模块        logging.disable(logging.NOTSET)#要在logging.NOSET级别以上时才记录在日志中        command = args[0]        args = args[1:]    if command in commands: #commands暂时不知道怎么来的,毕竟源码结构复杂        o = commands[command]()        o.run(args)#这个时候就需要参考 http://www.cnblogs.com/qianheng/p/6240819.html#得到commands的内容,server代表的是 <class 'odoo.cli.server.Server'>#也就是说,现在这个main函数就是调用server.py的函数罗!    else:        sys.exit('Unknow command %r' % (command,))#未知的命令







原创粉丝点击