zoukankan      html  css  js  c++  java
  • odoo.cli.main()做了什么?

    先把代码贴过来

     1 def main():
     2     args = sys.argv[1:] 
     3 
     4     # The only shared option is '--addons-path=' needed to discover additional
     5     # commands from modules
     6     if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"): 如果有插件路径参数,则解析之
     7         # parse only the addons-path, do not setup the logger...
     8         odoo.tools.config._parse_config([args[0]])
     9         args = args[1:]
    10 
    11     # Default legacy command  这是要启动server吗?
    12     command = "server"
    13 
    14     # TODO: find a way to properly discover addons subcommands without importing the world 需要一种方法确定必须导入的模块,而不是所有的模块
    15     # Subcommand discovery
    16     if len(args) and not args[0].startswith("-"):
    17         logging.disable(logging.CRITICAL)
    18         for module in get_modules():
    19             if isdir(joinpath(get_module_path(module), 'cli')):
    20                 __import__('odoo.addons.' + module)
    21         logging.disable(logging.NOTSET)
    22         command = args[0]
    23         args = args[1:]
    24 
    25     if command in commands:
    26         o = commands[command]()
    27         o.run(args)
    28     else:
    29         sys.exit('Unknow command %r' % (command,))

    at last o.run(args)

    其中,command=‘server’

    在python运行时探测得知

    commands的内容是

    {'shell': <class 'odoo.cli.shell.Shell'>, 'help': <class 'odoo.cli.command.Help'>, 'deploy': <class 'odoo.cli.deploy.Deploy'>, 'scaffold': <class 'odoo.cli.scaffold.Scaffold'>, 'server': <class 'odoo.cli.server.Server'>, 'star
    t': <class 'odoo.cli.start.Start'>}

    也就是说server 代表的是<class 'odoo.cli.server.Server'>

    by the way

    args is ”-w odoo -r odoo --addons-path=addons,../mymodules --db-filter=mydb$“

    let's go!<class 'odoo.cli.server.Server'>

  • 相关阅读:
    Jquery 公告 滚动+AJAX后台得到数据。
    图片上添加文字。
    javascript的window.onload与jquery的$(document).ready()
    后台JS写法
    Ajax xmlhttprequest原理(一)
    SQL语句二次排序。先根据是否置顶字段。再根据最后更新时间排序。
    引以为戒的SQL语句写法
    C#中var关键字怎么用 ~
    上传文件 解析
    简易公告
  • 原文地址:https://www.cnblogs.com/qianheng/p/6240819.html
Copyright © 2011-2022 走看看