[merge] 5.0 in branch
bzr revid: xmo@tinyerp.com-20091202072808-fozu0u3rjiggzwiu
This commit is contained in:
@@ -14,31 +14,30 @@ login := admin
|
||||
password := admin
|
||||
|
||||
start:
|
||||
python $(interrogation_file) start-server --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port)
|
||||
python $(interrogation_file) start-server --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port)
|
||||
|
||||
create-db:
|
||||
python $(interrogation_file) create-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --login=$(login) --password=$(password)
|
||||
python $(interrogation_file) create-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port) --login=$(login) --password=$(password)
|
||||
|
||||
drop-db:
|
||||
python $(interrogation_file) drop-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port)
|
||||
python $(interrogation_file) drop-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port)
|
||||
|
||||
install-module:
|
||||
python $(interrogation_file) install-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --extra-addons=$(extra-addons) --port=$(port) --login=$(login) --password=$(password)
|
||||
python $(interrogation_file) install-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --extra-addons=$(extra-addons) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password)
|
||||
|
||||
upgrade-module:
|
||||
python $(interrogation_file) upgrade-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --login=$(login) --password=$(password)
|
||||
python $(interrogation_file) upgrade-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port) --login=$(login) --password=$(password)
|
||||
|
||||
|
||||
install-translation:
|
||||
python $(interrogation_file) install-translation --database=$(database) --translate-in=$(i18n-import) --port=$(port) --login=$(login) --password=$(password) --root-path=$(root-path) --addons-path=$(addons-path)
|
||||
python $(interrogation_file) install-translation --database=$(database) --translate-in=$(i18n-import) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password) --root-path=$(root-path) --addons-path=$(addons-path)
|
||||
|
||||
|
||||
version:
|
||||
python bin/openerp-server.py --version
|
||||
|
||||
check-quality:
|
||||
python $(interrogation_file) check-quality --database=$(database) --modules=$(module) --port=$(port) --login=$(login) --password=$(password) --addons-path=$(addons-path) --root-path=$(root-path)
|
||||
python $(interrogation_file) check-quality --database=$(database) --modules=$(module) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password) --addons-path=$(addons-path) --root-path=$(root-path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-1
@@ -82,7 +82,7 @@ class Graph(dict):
|
||||
|
||||
## and we update the default values with values from the database
|
||||
additional_data.update(dict([(x.pop('name'), x) for x in cr.dictfetchall()]))
|
||||
|
||||
|
||||
for package in self.values():
|
||||
for k, v in additional_data[package.name].items():
|
||||
setattr(package, k, v)
|
||||
@@ -602,6 +602,16 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
|
||||
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
|
||||
has_updates = True
|
||||
for kind in ('init', 'update'):
|
||||
if package.state=='to upgrade':
|
||||
# upgrading the module information
|
||||
modobj.write(cr, 1, [mid], {
|
||||
'description': package.data.get('description', ''),
|
||||
'shortdesc': package.data.get('name', ''),
|
||||
'author': package.data.get('author', 'Unknown'),
|
||||
'website': package.data.get('website', ''),
|
||||
'license': package.data.get('license', 'GPL-2'),
|
||||
'certificate': package.data.get('certificate') or None,
|
||||
})
|
||||
for filename in package.data.get('%s_xml' % kind, []):
|
||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename))
|
||||
name, ext = os.path.splitext(filename)
|
||||
|
||||
@@ -49,8 +49,8 @@ def to_decode(s):
|
||||
except UnicodeError:
|
||||
return s
|
||||
|
||||
def start_server(root_path, port, addons_path):
|
||||
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --port=%s --no-netrpc --addons-path=%s' %(root_path, str(port), addons_path))
|
||||
def start_server(root_path, port, netport, addons_path):
|
||||
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --port=%s --net_port=%s --addons-path=%s' %(root_path, str(port),str(netport),addons_path))
|
||||
def clean():
|
||||
if os.path.isfile('openerp.pid'):
|
||||
ps = open('openerp.pid')
|
||||
@@ -292,6 +292,7 @@ parser.add_option("--addons-path", dest="addons_path", help="specify the addons
|
||||
parser.add_option("--quality-logs", dest="quality_logs", help="specify the path of quality logs files which has to stores")
|
||||
parser.add_option("--root-path", dest="root_path", help="specify the root path")
|
||||
parser.add_option("-p", "--port", dest="port", help="specify the TCP port", type="int")
|
||||
parser.add_option("--net_port", dest="netport",help="specify the TCP port for netrpc")
|
||||
parser.add_option("-d", "--database", dest="db_name", help="specify the database name")
|
||||
parser.add_option("--login", dest="login", help="specify the User Login")
|
||||
parser.add_option("--password", dest="pwd", help="specify the User Password")
|
||||
@@ -324,6 +325,7 @@ options = {
|
||||
'root-path' : opt.root_path or '',
|
||||
'translate-in': [],
|
||||
'port' : opt.port or 8069,
|
||||
'netport':opt.netport or 8070,
|
||||
'database': opt.db_name or 'terp',
|
||||
'modules' : opt.modules or [],
|
||||
'login' : opt.login or 'admin',
|
||||
@@ -346,7 +348,7 @@ if opt.translate_in:
|
||||
uri = 'http://localhost:' + str(options['port'])
|
||||
|
||||
server_thread = threading.Thread(target=start_server,
|
||||
args=(options['root-path'], options['port'], options['addons-path']))
|
||||
args=(options['root-path'], options['port'],options['netport'], options['addons-path']))
|
||||
try:
|
||||
server_thread.start()
|
||||
if command == 'create-db':
|
||||
|
||||
+8
-2
@@ -721,7 +721,7 @@ class related(function):
|
||||
t_id=t_data['id']
|
||||
t_data = t_data[self.arg[i]]
|
||||
if t_id:
|
||||
obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values})
|
||||
obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values}, context=context)
|
||||
|
||||
def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None):
|
||||
self._field_get2(cr, uid, obj, context)
|
||||
@@ -744,7 +744,7 @@ class related(function):
|
||||
except:
|
||||
t_data = False
|
||||
break
|
||||
if field_detail['type'] in ('one2many', 'many2many'):
|
||||
if field_detail['type'] in ('one2many', 'many2many') and i != len(self.arg) - 1:
|
||||
t_data = t_data[self.arg[i]][0]
|
||||
else:
|
||||
t_data = t_data[self.arg[i]]
|
||||
@@ -760,6 +760,12 @@ class related(function):
|
||||
for r in res:
|
||||
if res[r]:
|
||||
res[r] = (res[r], ng[res[r]])
|
||||
elif self._type in ('one2many', 'many2many'):
|
||||
for r in res:
|
||||
if res[r]:
|
||||
res[r] = [x.id for x in res[r]]
|
||||
|
||||
|
||||
return res
|
||||
|
||||
def __init__(self, *arg, **args):
|
||||
|
||||
@@ -88,14 +88,14 @@ class report_rml(report_int):
|
||||
def create(self, cr, uid, ids, datas, context):
|
||||
xml = self.create_xml(cr, uid, ids, datas, context)
|
||||
xml = tools.ustr(xml).encode('utf8')
|
||||
if datas.get('report_type', 'pdf') == 'raw':
|
||||
return xml
|
||||
report_type = datas.get('report_type', 'pdf')
|
||||
if report_type == 'raw':
|
||||
return (xml,report_type)
|
||||
rml = self.create_rml(cr, xml, uid, context)
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
|
||||
report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
|
||||
self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
|
||||
report_type = datas.get('report_type', 'pdf')
|
||||
create_doc = self.generators[report_type]
|
||||
pdf = create_doc(rml, title=self.title)
|
||||
return (pdf, report_type)
|
||||
|
||||
@@ -286,11 +286,8 @@ class db(netsvc.Service):
|
||||
return True
|
||||
|
||||
def db_exist(self, db_name):
|
||||
try:
|
||||
db = sql_db.db_connect(db_name)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
## Not True: in fact, check if connection to database is possible. The database may exists
|
||||
return bool(sql_db.db_connect(db_name))
|
||||
|
||||
def list(self):
|
||||
db = sql_db.db_connect('template1')
|
||||
|
||||
+29
-6
@@ -53,6 +53,7 @@ psycopg2.extensions.register_type(psycopg2.extensions.new_type((700, 701, 1700,)
|
||||
import tools
|
||||
from tools.func import wraps
|
||||
from datetime import datetime as mdt
|
||||
from datetime import timedelta
|
||||
import threading
|
||||
|
||||
import re
|
||||
@@ -128,18 +129,21 @@ class Cursor(object):
|
||||
raise
|
||||
|
||||
if self.sql_log:
|
||||
delay = mdt.now() - now
|
||||
delay = delay.seconds * 1E6 + delay.microseconds
|
||||
|
||||
log("query: %s" % self._obj.query)
|
||||
self.sql_log_count+=1
|
||||
res_from = re_from.match(query.lower())
|
||||
if res_from:
|
||||
self.sql_from_log.setdefault(res_from.group(1), [0, 0])
|
||||
self.sql_from_log[res_from.group(1)][0] += 1
|
||||
self.sql_from_log[res_from.group(1)][1] += mdt.now() - now
|
||||
self.sql_from_log[res_from.group(1)][1] += delay
|
||||
res_into = re_into.match(query.lower())
|
||||
if res_into:
|
||||
self.sql_into_log.setdefault(res_into.group(1), [0, 0])
|
||||
self.sql_into_log[res_into.group(1)][0] += 1
|
||||
self.sql_into_log[res_into.group(1)][1] += mdt.now() - now
|
||||
self.sql_into_log[res_into.group(1)][1] += delay
|
||||
return res
|
||||
|
||||
def print_log(self):
|
||||
@@ -155,9 +159,11 @@ class Cursor(object):
|
||||
sum = 0
|
||||
log("SQL LOG %s:" % (type,))
|
||||
for r in sqllogitems:
|
||||
log("table: %s: %s/%s" %(r[0], str(r[1][1]), r[1][0]))
|
||||
delay = timedelta(microseconds=r[1][1])
|
||||
log("table: %s: %s/%s" %(r[0], str(delay), r[1][0]))
|
||||
sum+= r[1][1]
|
||||
log("SUM:%s/%d" % (sum, self.sql_log_count))
|
||||
sum = timedelta(microseconds=sum)
|
||||
log("SUM:%s/%d" % (str(sum), self.sql_log_count))
|
||||
sqllogs[type].clear()
|
||||
process('from')
|
||||
process('into')
|
||||
@@ -235,7 +241,7 @@ class ConnectionPool(object):
|
||||
|
||||
result = None
|
||||
for i, (cnx, used) in enumerate(self._connections):
|
||||
if not used and cnx.dsn == dsn:
|
||||
if not used and dsn_are_equals(cnx.dsn, dsn):
|
||||
self._debug('Existing connection found at index %d' % i)
|
||||
|
||||
self._connections.pop(i)
|
||||
@@ -276,7 +282,7 @@ class ConnectionPool(object):
|
||||
@locked
|
||||
def close_all(self, dsn):
|
||||
for i, (cnx, used) in tools.reverse_enumerate(self._connections):
|
||||
if cnx.dsn == dsn:
|
||||
if dsn_are_equals(cnx.dsn, dsn):
|
||||
cnx.close()
|
||||
self._connections.pop(i)
|
||||
|
||||
@@ -295,6 +301,7 @@ class Connection(object):
|
||||
|
||||
def __del__(self):
|
||||
if self._unique:
|
||||
close_db(self.dbname)
|
||||
self.__LOCKS[self.dbname].release()
|
||||
|
||||
def cursor(self, serialized=False):
|
||||
@@ -303,6 +310,15 @@ class Connection(object):
|
||||
def serialized_cursor(self):
|
||||
return self.cursor(True)
|
||||
|
||||
def __nonzero__(self):
|
||||
"""Check if connection is possible"""
|
||||
try:
|
||||
cr = self.cursor()
|
||||
cr.close()
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
_dsn = ''
|
||||
for p in ('host', 'port', 'user', 'password'):
|
||||
@@ -313,6 +329,13 @@ for p in ('host', 'port', 'user', 'password'):
|
||||
def dsn(db_name):
|
||||
return '%sdbname=%s' % (_dsn, db_name)
|
||||
|
||||
def dsn_are_equals(first, second):
|
||||
def key(dsn):
|
||||
k = dict(x.split('=', 1) for x in dsn.strip().split())
|
||||
k.pop('password', None) # password is not relevant
|
||||
return k
|
||||
return key(first) == key(second)
|
||||
|
||||
|
||||
_Pool = ConnectionPool(int(tools.config['db_maxconn']))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user