[REF] service: netsvc.Service is removed. LocalService(object_proxy) is never used so it is removed.

bzr revid: vmt@openerp.com-20130201112232-2k8geufmryx6p249
This commit is contained in:
Vo Minh Thu 2013-02-01 12:22:32 +01:00
parent f0e4a9b01e
commit c8ffd1cedc
3 changed files with 12 additions and 29 deletions

View File

@ -28,6 +28,7 @@ import time
from openerp import SUPERUSER_ID from openerp import SUPERUSER_ID
from openerp import netsvc, tools from openerp import netsvc, tools
from openerp.osv import fields, osv from openerp.osv import fields, osv
import openerp.report.interface
from openerp.report.report_sxw import report_sxw, report_rml from openerp.report.report_sxw import report_sxw, report_rml
from openerp.tools.config import config from openerp.tools.config import config
from openerp.tools.safe_eval import safe_eval as eval from openerp.tools.safe_eval import safe_eval as eval
@ -93,9 +94,9 @@ class report_xml(osv.osv):
opj = os.path.join opj = os.path.join
cr.execute("SELECT * FROM ir_act_report_xml WHERE auto=%s ORDER BY id", (True,)) cr.execute("SELECT * FROM ir_act_report_xml WHERE auto=%s ORDER BY id", (True,))
result = cr.dictfetchall() result = cr.dictfetchall()
svcs = netsvc.Service._services reports = openerp.report.interface.report_int._reports
for r in result: for r in result:
if svcs.has_key('report.'+r['report_name']): if reports.has_key('report.'+r['report_name']):
continue continue
if r['report_rml'] or r['report_rml_content_data']: if r['report_rml'] or r['report_rml_content_data']:
report_sxw('report.'+r['report_name'], r['model'], report_sxw('report.'+r['report_name'], r['model'],

View File

@ -47,35 +47,13 @@ import openerp
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class Service(object):
""" Base class for Local services
Functionality here is trusted, no authentication.
Workflow engine and reports subclass this.
"""
_services = {}
def __init__(self, name):
Service._services[name] = self
self.__name = name
@classmethod
def exists(cls, name):
return name in cls._services
@classmethod
def remove(cls, name):
if cls.exists(name):
cls._services.pop(name)
def LocalService(name): def LocalService(name):
# Special case for addons support, will be removed in a few days when addons # Special case for addons support, will be removed in a few days when addons
# are updated to directly use openerp.osv.osv.service. # are updated to directly use openerp.osv.osv.service.
if name == 'object_proxy':
return openerp.service.model
if name == 'workflow': if name == 'workflow':
return openerp.workflow return openerp.workflow
return Service._services[name] return openerp.report.interface.report_int._reports[name]
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10) BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10)
#The background is set with 40 plus the number of the color, and the foreground with 30 #The background is set with 40 plus the number of the color, and the foreground with 30

View File

@ -23,7 +23,6 @@ import os
import re import re
from lxml import etree from lxml import etree
import openerp.netsvc as netsvc
import openerp.pooler as pooler import openerp.pooler as pooler
import openerp.tools as tools import openerp.tools as tools
@ -40,12 +39,17 @@ def toxml(value):
unicode_value = tools.ustr(value) unicode_value = tools.ustr(value)
return unicode_value.replace('&', '&amp;').replace('<','&lt;').replace('>','&gt;') return unicode_value.replace('&', '&amp;').replace('<','&lt;').replace('>','&gt;')
class report_int(netsvc.Service): class report_int(object):
_reports = {}
def __init__(self, name): def __init__(self, name):
assert not self.exists(name), 'The report "%s" already exists!' % name
super(report_int, self).__init__(name)
if not name.startswith('report.'): if not name.startswith('report.'):
raise Exception('ConceptionError, bad report name, should start with "report."') raise Exception('ConceptionError, bad report name, should start with "report."')
assert name not in self._reports, 'The report "%s" already exists!' % name
self._reports[name] = self
self.__name = name
self.name = name self.name = name
self.id = 0 self.id = 0
self.name2 = '.'.join(name.split('.')[1:]) self.name2 = '.'.join(name.split('.')[1:])