Merge lp:~fabien-morin/unifield-server/fm-us-959 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3767
Proposed branch: lp:~fabien-morin/unifield-server/fm-us-959
Merge into: lp:unifield-server
Diff against target: 106 lines (+48/-9)
2 files modified
bin/pooler.py (+23/-7)
bin/service/web_services.py (+25/-2)
To merge this branch: bzr merge lp:~fabien-morin/unifield-server/fm-us-959
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+295494@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pooler.py'
--- bin/pooler.py 2015-03-05 16:54:18 +0000
+++ bin/pooler.py 2016-05-24 07:29:48 +0000
@@ -23,7 +23,20 @@
2323
24pool_dic = {}24pool_dic = {}
2525
26def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True):26def get_db_and_pool(db_name, force_demo=False, status=None,
27 update_module=False, pooljobs=True, upgrade_modules=True):
28 '''
29 Return the db and pool.
30
31 :param db_name: database name
32 :param force_demo: load demo data
33 :param status: status dictionary for keeping track of progress
34 :param update_module: update the list of available modules
35 :pooljobs: restart the cron job
36 :upgrade_modules: start the modules upgrade process ('-u base') if needed
37 :rtype: list of two object: (dabase, pool)
38
39 '''
27 if not status:40 if not status:
28 status={}41 status={}
2942
@@ -47,10 +60,11 @@
47 try:60 try:
48 pool.init_set(cr, False)61 pool.init_set(cr, False)
49 pool.get('ir.actions.report.xml').register_all(cr)62 pool.get('ir.actions.report.xml').register_all(cr)
50 if not updater.do_upgrade(cr, pool):63 if upgrade_modules:
51 pool_dic.pop(db_name)64 if not updater.do_upgrade(cr, pool):
52 # please do not change "updater.py" in the message, or change unifield-web/addons/openerp/utils/rpc.py accordingly65 pool_dic.pop(db_name)
53 raise Exception("updater.py told us that OpenERP version doesn't match database version!")66 # please do not change "updater.py" in the message, or change unifield-web/addons/openerp/utils/rpc.py accordingly
67 raise Exception("updater.py told us that OpenERP version doesn't match database version!")
54 cr.commit()68 cr.commit()
55 finally:69 finally:
56 cr.close()70 cr.close()
@@ -81,8 +95,10 @@
81 return get_db_and_pool(db_name)[0]95 return get_db_and_pool(db_name)[0]
8296
8397
84def get_pool(db_name, force_demo=False, status=None, update_module=False):98def get_pool(db_name, force_demo=False, status=None, update_module=False,
85 pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]99 upgrade_modules=True):
100 pool = get_db_and_pool(db_name, force_demo, status, update_module,
101 upgrade_modules=upgrade_modules)[1]
86 return pool102 return pool
87103
88# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:104# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
89105
=== modified file 'bin/service/web_services.py'
--- bin/service/web_services.py 2016-02-04 12:55:56 +0000
+++ bin/service/web_services.py 2016-05-24 07:29:48 +0000
@@ -72,7 +72,8 @@
72 passwd = params[0]72 passwd = params[0]
73 params = params[1:]73 params = params[1:]
74 security.check_super(passwd)74 security.check_super(passwd)
75 elif method in [ 'db_exist', 'list', 'list_lang', 'server_version', 'check_timezone' ]:75 elif method in [ 'db_exist', 'list', 'list_lang', 'server_version',
76 'check_timezone', 'connected_to_prod_sync_server' ]:
76 # params = params77 # params = params
77 # No security check for these methods78 # No security check for these methods
78 pass79 pass
@@ -338,6 +339,28 @@
338 res.sort()339 res.sort()
339 return res340 return res
340341
342 def exp_connected_to_prod_sync_server(self, db_name):
343 """Return True if db_name is connected to a production SYNC_SERVER,
344 False otherwise"""
345
346 connection = sql_db.db_connect(db_name)
347 # it the db connnected to a sync_server ?
348 server_connecion_module = pooler.get_pool(db_name, upgrade_modules=False).get('sync.client.sync_server_connection')
349 if not server_connecion_module:
350 return False
351
352 if not getattr(server_connecion_module, '_uid', False):
353 return False
354
355 cr = connection.cursor()
356 cr.execute('''SELECT host, database
357 FROM sync_client_sync_server_connection''')
358 host, database = cr.fetchone()
359 cr.close()
360 if host and 'localhost' in host and database == 'fm-us-959_SYNC_SERVER':
361 return True
362 return False
363
341 def exp_change_admin_password(self, new_password):364 def exp_change_admin_password(self, new_password):
342 tools.config['admin_passwd'] = new_password365 tools.config['admin_passwd'] = new_password
343 tools.config.save()366 tools.config.save()
@@ -435,7 +458,7 @@
435 elif method == 'logout':458 elif method == 'logout':
436 if auth:459 if auth:
437 auth.logout(params[1])460 auth.logout(params[1])
438 logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db))461 logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s' % (params[1], db))
439 return True462 return True
440 elif method in ['about', 'timezone_get', 'get_server_environment',463 elif method in ['about', 'timezone_get', 'get_server_environment',
441 'login_message','get_stats', 'check_connectivity',464 'login_message','get_stats', 'check_connectivity',

Subscribers

People subscribed via source and target branches