Odoo(OpenERP)_web 5.0.16 调试分析


Odoo(OpenERP)_web 5.0.16 调试分析

www.chinamaker.net 2011-08-18 17:05:00 admin

OpenERP_web 5.0.16 调试分析

1. 在OpenERP-web.py文件开头设置断点启动调试

2. 启动Debugger的过程

Start the external program with the file 'pydevd.py' in its pythonpathCall pydevd.settrace()def settrace(host=None, stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=True):    '''Sets the tracing function with the pydev debug function and initializes needed facilities.       @param host: the user may specify another host, if the debug server is not in the same machine (default is the local host)    @param stdoutToServer: when this is true, the stdout is passed to the debug server    @param stderrToServer: when this is true, the stderr is passed to the debug server        so that they are printed in its console and not in this process console.    @param port: specifies which port to use for communicating with the server (note that the server must be started        in the same port). @note: currently it's hard-coded at 5678 in the client    @param suspend: whether a breakpoint should be emulated as soon as this function is called.    @param trace_only_current_thread: determines if only the current thread will be traced or all future threads will also have the tracing enabled.'''

3. 变量DONT_TRACE的值

Variables:DONT_TRACEdict: {'pydevd_vm_type.py': 1, 'pydevd_tracing.py': 1, 'pydevd_psyco_stub.py': 1, 'pydevd_io.py': 1, 'pydevd_additional_thread_info.py': 1, 'pydevd_file_utils.py': 1, 'pydevd_resolver.py': 1, 'pydevd_constants.py': 1, 'threading.py': 1, 'pydevd.py': 1, 'pydevd_traceproperty.py': 1, 'Queue.py': 1, 'pydevd_vars.py': 1, 'pydevd_comm.py': 1, 'pydevd_frame.py': 1, 'socket.py': 1}      

4. 以命令行启动线程 PyDBCommandThread

pydevd_vm_type判断python的虚拟机

5. 创建debugger的实例

        #if it's available, let's change it for a stub (pydev already made use of it)        import pydevd_psyco_stub        sys.modules['psyco'] = pydevd_psyco_stub    PydevdLog(2, "Executing file ", setup['file'])    PydevdLog(2, "arguments:", str(sys.argv))     pydevd_vm_type.SetupType(setup.get('vm_type', None))       DebugInfoHolder.DEBUG_RECORD_SOCKET_READS = setup.get('DEBUG_RECORD_SOCKET_READS', False)     debugger = PyDB()    debugger.connect(setup['client'], setup['port'])       connected = True #Mark that we're connected when started from inside eclipse.   debugger.run(setup['file'], None, None)

6. pydb类

class PyDB:    """ Main debugging class    Lots of stuff going on here:       PyDB starts two threads on startup that connect to remote debugger (RDB)    The threads continuously read & write commands to RDB.    PyDB communicates with these threads through command queues.       Every RDB command is processed by calling processNetCommand.       Every PyDB net command is sent to the net by posting NetCommand to WriterThread queue             Some commands need to be executed on the right thread (suspend/resume & friends)       These are placed on the internal command queue."""

7. 读 __init__.py

8. ntpath.py

# Module 'ntpath' -- common operations on WinNT/Win95 pathnames

9. commands.py

10. FormEncode 有效性验证

 FormEncode is a validation and form generation package. The validation can be used separately from the form generation. The validation works on compound data structures, with all parts being nestable. It is separate from HTTP or any other input mechanism."""Declarative objects for FormEncode. Declarative objects have a simple protocol: you can use classes inlieu of instances and they are equivalent, and any keyword argumentsyou give to the constructor will override those instance variables.(So if a class is received, we'll simply instantiate an instance withno arguments). You can provide a variable __unpackargs__ (a list of strings), and ifthe constructor is called with non-keyword arguments they will beinterpreted as the given keyword arguments. If __unpackargs__ is ('*', name), then all the arguments will be putin a variable by that name. Also, you can define a __classinit__(cls, new_attrs) method, whichwill be called when the class is created (including subclasses)."""class classinstancemethod(object):    """    Acts like a class method when called from a class, like an    instance method when called by an instance.  The method should    take two arguments, 'self' and 'cls'; one of these will be None    depending on how the method was called."""

11. Cherrypy

CherryPy is a pythonic, object-oriented web frameworkCherryPy allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.CherryPy is now more than seven years old and it is has proven to be very fast and stable. It is being used in production by many sites, from the simplest to the most demanding ones.Features
  • A fast, HTTP/1.1-compliant, WSGI thread-pooled webserver.
  • Easy to run multiple HTTP servers (e.g. on multiple ports) at once.
  • A powerful configuration system for developers and deployers alike.
  • A flexible plugin system.
  • Built-in tools for caching, encoding, sessions, authorization, static content, and many more.
  • Swappable and customizable...everything.
  • Built-in profiling, coverage, and testing support.
  • Runs on Python 2.5+, 3.1+, Jython and Android.

12. 读openerp-web.cfg文件

# initialize the rpc session# global session variable, will be initialized with connectsession = Nonedef initialize(host, port, protocol='socket', storage=None):    """ Initialize the default rpc session.    """    global session    session = RPCSession(host, port, protocol, storage=storage)class RPCProxy(object):    """A wrapper arround xmlrpclib, provides pythonic way to access tiny resources.     For example,     >>> users = RPCProxy("ir.users")    >>> res = users.read([1], ['name', 'active_id'], session.context)"""

13. Wspbus.py

 

14. MochiKit

MochiKit 是一种有用的高端 JavaScript 库。MochiKit 主要受到 Python 和 Python 标准库提供的很多便利之处的启发,另外还缓解了浏览器版本之间的不一致性。其中的 MochiKit.DOM 尤其方便,能够以比原始 JavaScript 更友好的方式处理 DOM 对象。MochiKit.DOM 大部分都是针对 XHTML 文档定制的,如果与 MochiKit 和 Ajax 结合在一起,使用 XHTML 包装的微格式尤其方便。

小节:

首先通过pydev插件的debug函数和初始化所需的工具设置跟踪函数settrance,通过扩展的python调试器pydb创建命令行线程,创建debugger实例,import FormEncode、Cherrypy等包。初始化rpc session,RPCSession(host, port, protocol, storage=storage),通过openerp-web.cfg文件中的主机、端口和协议连接服务器。RPC(Remote Procedure Call Protocol)——远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据。在OSI网络通信模型中,RPC跨越了传输层和应用层。RPC使得开发包括网络分布式多程序在内的应用程序更加容易。RPC采用客户机/服 务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,客户机调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。在 服务器端,进程保持睡眠状态直到调用信息的到达为止。当一个调用信息到达,服务器获得进程参数,计算结果,发送答复信息,然后等待下一个调用信息,最后, 客户端调用进程接收答复信息,获得进程结果,然后调用执行继续进行。目前,有多种 RPC 模式和执行。最初由 Sun 公司提出。IETF ONC 宪章重新修订了 Sun 版本,使得 ONC RPC 协议成为 IETF 标准协议。现在使用最普遍的模式和执行是开放式软件基础的分布式计算环境

来源:苏州远鼎官网


相关标签 TAG :  OpenERP_web  5  0  16  调试分析  


苏州远鼎

运用前沿科学技术,苏州远鼎信息技术有限公司以开源管理软件产品为核心,为企业和政府组织提供软件及服务,是OpenERP(Odoo)专业服务商,中国开源管理软件服务市场的领跑者。

Read More

远鼎产品

联系远鼎

  • 苏州工业园区星湖街328号22栋301
  • +86-0512-69361217
  • odoo@chinamaker.net
  • www.chinamaker.net