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

View File

@ -47,35 +47,13 @@ import openerp
_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):
# Special case for addons support, will be removed in a few days when addons
# are updated to directly use openerp.osv.osv.service.
if name == 'object_proxy':
return openerp.service.model
if name == '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)
#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
from lxml import etree
import openerp.netsvc as netsvc
import openerp.pooler as pooler
import openerp.tools as tools
@ -40,12 +39,17 @@ def toxml(value):
unicode_value = tools.ustr(value)
return unicode_value.replace('&', '&amp;').replace('<','&lt;').replace('>','&gt;')
class report_int(netsvc.Service):
class report_int(object):
_reports = {}
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.'):
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.id = 0
self.name2 = '.'.join(name.split('.')[1:])