[MERGE] forward port of branch saas-1 up to revid 4893 chs@openerp.com-20130701153735-xnbb8zauabf1k63u
bzr revid: chs@openerp.com-20130702144745-763n9cdphkppshxl
This commit is contained in:
commit
5a58a48ef5
|
@ -1067,6 +1067,8 @@ class function(_column):
|
|||
self._classic_write = True
|
||||
if type=='binary':
|
||||
self._symbol_get=lambda x:x and str(x)
|
||||
else:
|
||||
self._prefetch = True
|
||||
|
||||
if type == 'float':
|
||||
self._symbol_c = float._symbol_c
|
||||
|
|
|
@ -385,11 +385,11 @@ class browse_record(object):
|
|||
# if the field is a classic one or a many2one, we'll fetch all classic and many2one fields
|
||||
if col._prefetch:
|
||||
# gen the list of "local" (ie not inherited) fields which are classic or many2one
|
||||
fields_to_fetch = filter(lambda x: x[1]._classic_write, self._table._columns.items())
|
||||
fields_to_fetch = filter(lambda x: x[1]._classic_write and x[1]._prefetch, self._table._columns.items())
|
||||
# gen the list of inherited fields
|
||||
inherits = map(lambda x: (x[0], x[1][2]), self._table._inherit_fields.items())
|
||||
# complete the field list with the inherited fields which are classic or many2one
|
||||
fields_to_fetch += filter(lambda x: x[1]._classic_write, inherits)
|
||||
fields_to_fetch += filter(lambda x: x[1]._classic_write and x[1]._prefetch, inherits)
|
||||
# otherwise we fetch only that field
|
||||
else:
|
||||
fields_to_fetch = [(name, col)]
|
||||
|
@ -1034,6 +1034,7 @@ class BaseModel(object):
|
|||
'ondelete': field['on_delete'],
|
||||
'translate': (field['translate']),
|
||||
'manual': True,
|
||||
'_prefetch': False,
|
||||
#'select': int(field['select_level'])
|
||||
}
|
||||
|
||||
|
|
|
@ -116,10 +116,13 @@ def _process_text(self, txt):
|
|||
result += tools.ustr(self.localcontext.get('translate', lambda x:x)(to_translate))
|
||||
if sps:
|
||||
txt = None
|
||||
expr = sps.pop(0)
|
||||
txt = eval(expr, self.localcontext)
|
||||
if txt and isinstance(txt, basestring):
|
||||
txt = tools.ustr(txt)
|
||||
try:
|
||||
expr = sps.pop(0)
|
||||
txt = eval(expr, self.localcontext)
|
||||
if txt and isinstance(txt, basestring):
|
||||
txt = tools.ustr(txt)
|
||||
except Exception:
|
||||
_logger.error("Failed to evaluate expression [[ %s ]] with context %r while rendering report, ignored.", expr, self.localcontext)
|
||||
if isinstance(txt, basestring):
|
||||
result += txt
|
||||
elif txt and (txt is not None) and (txt is not False):
|
||||
|
|
|
@ -196,7 +196,7 @@ class Multicorn(object):
|
|||
|
||||
def stop(self, graceful=True):
|
||||
if self.long_polling_pid is not None:
|
||||
self.worker_kill(self.long_polling_pid, signal.SIGTERM)
|
||||
self.worker_kill(self.long_polling_pid, signal.SIGKILL) # FIXME make longpolling process handle SIGTERM correctly
|
||||
self.long_polling_pid = None
|
||||
if graceful:
|
||||
_logger.info("Stopping gracefully")
|
||||
|
@ -392,14 +392,18 @@ class WorkerCron(Worker):
|
|||
interval = 60 + self.pid % 10 # chorus effect
|
||||
time.sleep(interval)
|
||||
|
||||
def process_work(self):
|
||||
rpc_request = logging.getLogger('openerp.netsvc.rpc.request')
|
||||
rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
|
||||
_logger.debug("WorkerCron (%s) polling for jobs", self.pid)
|
||||
def _db_list(self):
|
||||
if config['db_name']:
|
||||
db_names = config['db_name'].split(',')
|
||||
else:
|
||||
db_names = openerp.service.db.exp_list(True)
|
||||
return db_names
|
||||
|
||||
def process_work(self):
|
||||
rpc_request = logging.getLogger('openerp.netsvc.rpc.request')
|
||||
rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
|
||||
_logger.debug("WorkerCron (%s) polling for jobs", self.pid)
|
||||
db_names = self._db_list()
|
||||
if len(db_names):
|
||||
self.db_index = (self.db_index + 1) % len(db_names)
|
||||
db_name = db_names[self.db_index]
|
||||
|
@ -433,8 +437,15 @@ class WorkerCron(Worker):
|
|||
self.db_index = 0
|
||||
|
||||
def start(self):
|
||||
os.nice(10) # mommy always told me to be nice with others...
|
||||
Worker.start(self)
|
||||
self.multi.socket.close()
|
||||
openerp.service.start_internal()
|
||||
|
||||
# chorus effect: make cron workers do not all start at first database
|
||||
mct = config['max_cron_threads']
|
||||
p = float(self.pid % mct) / mct
|
||||
self.db_index = int(len(self._db_list()) * p)
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue