Odoo(OpenERP)_Server 5.0.16 调试分析


Odoo(OpenERP)_Server 5.0.16 调试分析

www.chinamaker.net 2011-11-30 17:04:00 admin

OpenERP_Server 5.0.16 调试分析

1.logging

1.1C:\Python26\lib\logging\__init__.pyc#---------------------------------------------------------------------------#   Miscellaneous module data#--------------------------------------------------------------------------- ## _srcfile is used when walking the stack to check when we've got the first# caller stack frame.#if hasattr(sys, 'frozen'): #support for py2exe    _srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:])elif string.lower(__file__[-4:]) in ['.pyc', '.pyo']:    _srcfile = __file__[:-4] + '.py'else:    _srcfile = __file___srcfile = os.path.normcase(_srcfile)

1.2.ntpath.py

C:\Python26\lib\def normcase(s):    """Normalize case of pathname.     Makes all characters lowercase and all slashes into backslashes."""return s.replace("/", "\").lower()

1.3. class LogRecord

class LogRecord:    """    A LogRecord instance represents an event being logged.     LogRecord instances are created every time something is logged. They    contain all the information pertinent to the event being logged. The    main information passed in is in msg and args, which are combined    using str(msg) % args to create the message field of the record. The    record also includes information such as when the record was created,    the source line where the logging call was made, and any exception    information to be logged.    """    def __init__(self, name, level, pathname, lineno,                 msg, args, exc_info, func=None):        """        Initialize a logging record with interesting information.        """        ct = time.time()        self.name = name        self.msg = msg        #        # The following statement allows passing of a dictionary as a sole        # argument, so that you can do something like        #  logging.debug("a %(a)d b %(b)s", {'a':1, 'b':2})        # Suggested by Stefan Behnel.        # Note that without the test for args[0], we get a problem because        # during formatting, we test to see if the arg is present using        # 'if self.args:'. If the event being logged is e.g. 'Value is %d'        # and if the passed arg fails 'if self.args:' then no formatting        # is done. For example, logger.warn('Value is %d', 0) would log        # 'Value is %d' instead of 'Value is 0'.        # For the use case of passing a dictionary, this should not be a        # problem.

1.4. class Formatter

class Formatter:    """    Formatter instances are used to convert a LogRecord to text.     Formatters need to know how a LogRecord is constructed. They are    responsible for converting a LogRecord to (usually) a string which can    be interpreted by either a human or an external system. The base Formatter    allows a formatting string to be specified. If none is supplied, the    default value of "%s(message)\\n" is used.     The Formatter can be initialized with a format string which makes use of    knowledge of the LogRecord attributes - e.g. the default value mentioned    above makes use of the fact that the user's message and arguments are pre-    formatted into a LogRecord's message attribute. Currently, the useful    attributes in a LogRecord are described by:     %(name)s            Name of the logger (logging channel)    %(levelno)s         Numeric logging level for the message (DEBUG, INFO,                        WARNING, ERROR, CRITICAL)    %(levelname)s       Text logging level for the message ("DEBUG", "INFO",                        "WARNING", "ERROR", "CRITICAL")    %(pathname)s        Full pathname of the source file where the logging                        call was issued (if available)    %(filename)s        Filename portion of pathname    %(module)s          Module (name portion of filename)    %(lineno)d          Source line number where the logging call was issued                        (if available)    %(funcName)s        Function name    %(created)f         Time when the LogRecord was created (time.time()                        return value)    %(asctime)s         Textual time when the LogRecord was created    %(msecs)d           Millisecond portion of the creation time    %(relativeCreated)d Time in milliseconds when the LogRecord was created,                        relative to the time the logging module was loaded                        (typically at application startup time)    %(thread)d          Thread ID (if available)    %(threadName)s      Thread name (if available)    %(process)d         Process ID (if available)    %(message)s         The result of record.getMessage(), computed just as                        the record is emitted 

1.5. class Filter:

class Filter:    """    Filter instances are used to perform arbitrary filtering of LogRecords.     Loggers and Handlers can optionally use Filter instances to filter    records as desired. The base filter class only allows events which are    below a certain point in the logger hierarchy. For example, a filter    initialized with "A.B" will allow events logged by loggers "A.B",    "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If    initialized with the empty string, all events are passed."""

1.6. class Logger

class Logger(Filterer):    """    Instances of the Logger class represent a single logging channel. A    "logging channel" indicates an area of an application. Exactly how an    "area" is defined is up to the application developer. Since an    application can have any number of areas, logging channels are identified    by a unique string. Application areas can be nested (e.g. an area    of "input processing" might include sub-areas "read CSV files", "read    XLS files" and "read Gnumeric files"). To cater for this natural nesting,    channel names are organized into a namespace hierarchy where levels are    separated by periods, much like the Java or Python package namespace. So    in the instance given above, channel names might be "input" for the upper    level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels.    There is no arbitrary limit to the depth of nesting."""

1.7. getLogger

def getLogger(name=None):    """    Return a logger with the specified name, creating it if necessary. If no name is specified, return the root logger.

1.8. handlers

import logging.handlers

2.releace

name = 'openerp-server'version = '5.0.16'major_version = '5.0'description = 'OpenERP Server'long_desc = '''OpenERP is a complete ERP and CRM. The main features are accounting (analyticand financial), stock management, sales and purchases management, tasksautomation, marketing campaigns, help desk, POS, etc. Technical features includea distributed server, flexible workflows, an object database, a dynamic GUI,customizable reports, and XML-RPC interfaces.'''classifiers = """Development Status :: 5 - Production/StableLicense :: OSI Approved :: GNU General Public License (GPL)Programming Language :: Python"""url = 'http://www.openerp.com'author = 'OpenERP S.A.'author_email = 'info@openerp.com'support_email = 'support@openerp.com'license = 'GPL-3'download_url='http://www.openerp.com/download/stable/source/openerp-server-5.0.16.tar.gz'

3.netsvc

import traceback class xmlrpc(object):    class RpcGateway(object):        def __init__(self, name):            self.name = name class OpenERPDispatcherException(Exception):    def __init__(self, exception, traceback):        self.exception = exception        self.traceback = traceback class OpenERPDispatcher:    def log(self, title, msg):        if tools.config['log_level'] == logging.DEBUG_RPC:            Logger().notifyChannel('%s' % title, LOG_DEBUG_RPC, pformat(msg))     def dispatch(self, service_name, method, params):        if service_name not in GROUPS['web-services']:            raise Exception('AccessDenied')        try:            self.log('service', service_name)            self.log('method', method)            self.log('params', params)            result = LocalService(service_name)(method, *params)            if result is None: #we cannot marshal none in XMLRPC                result = False            self.log('result', result)            return result        except Exception, e:            self.log('exception', tools.exception_to_unicode(e))            if hasattr(e, 'traceback'):                tb = e.traceback            else:                tb = sys.exc_info()            tb_s = "".join(traceback.format_exception(*tb))            if tools.config['debug_mode']:                import pdb                pdb.post_mortem(tb[2])            raise OpenERPDispatcherException(e, tb_s)class SimpleXMLRPCRequestHandler(GenericXMLRPCRequestHandler, SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):rpc_paths = map(lambda s: '/xmlrpc/%s' % s, GROUPS.get('web-services', {}).keys()) 

4. web_services

str: D:\OpenERP\server\openerp-server-5.0.16\bin\service\web_services.pyc python26\lib\platform.py """ This module tries to retrieve as much platform-identifying data as    possible. It makes this information available via function APIs.     If called from the command line, it prints the platform    information concatenated as single string to stdout. The output    format is useable as part of a filename. webservice是一种构建应用程序的普遍模型,可以在任何支持网络通信的操作系统中实施运行;它是一种新的web 应用程序分支,是自包含、自描述、模块化的应用,可以发布、定位、通过web调用。Web Service是一个应用组件,它逻辑性的为其他应用程序提供数据与服务.各应用程序通过网络协议和规定的一些标准数据格式(Http,XML,Soap)来访问Web Service,通过Web Service内部执行得到所需结果.Web Service可以执行从简单的请求到复杂商务处理的任何功能。一旦部署以后,其他Web Service应用程序可以发现并调用它部署的服务。

小节:

首先执行logging,调用堆栈框架,每当产生日志时记录日志实例被创建,记录了使用str(msg) % args创建的信息和系统的异常信息,启动webservers

来源:苏州远鼎官网


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


苏州远鼎

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

Read More

远鼎产品

联系远鼎

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