[IMP] xmlrpc: versioned API.
bzr revid: vmt@openerp.com-20110925150923-au0u0nply8lriise
This commit is contained in:
+3
-3
@@ -61,18 +61,18 @@ def xmlrpc_return(start_response, service, method, params):
|
||||
|
||||
def wsgi_xmlrpc(environ, start_response):
|
||||
""" The main OpenERP WSGI handler."""
|
||||
if environ['REQUEST_METHOD'] == 'POST' and environ['PATH_INFO'].startswith('/openerp/xmlrpc'):
|
||||
if environ['REQUEST_METHOD'] == 'POST' and environ['PATH_INFO'].startswith('/openerp/6.1/xmlrpc'):
|
||||
length = int(environ['CONTENT_LENGTH'])
|
||||
data = environ['wsgi.input'].read(length)
|
||||
|
||||
params, method = xmlrpclib.loads(data)
|
||||
|
||||
path = environ['PATH_INFO'][len('/openerp/xmlrpc'):]
|
||||
path = environ['PATH_INFO'][len('/openerp/6.1/xmlrpc'):]
|
||||
if path.startswith('/'): path = path[1:]
|
||||
if path.endswith('/'): p = path[:-1]
|
||||
path = path.split('/')
|
||||
|
||||
# All routes are hard-coded. Need a way to register addons-supplied handlers.
|
||||
# All routes are hard-coded.
|
||||
|
||||
# No need for a db segment.
|
||||
if len(path) == 1:
|
||||
|
||||
+25
-1
@@ -27,6 +27,10 @@ common_proxy_60 = None
|
||||
db_proxy_60 = None
|
||||
object_proxy_60 = None
|
||||
|
||||
common_proxy_61 = None
|
||||
db_proxy_61 = None
|
||||
model_proxy_61 = None
|
||||
|
||||
def setUpModule():
|
||||
"""
|
||||
Start the OpenERP server similary to the openerp-server script and
|
||||
@@ -40,19 +44,32 @@ def setUpModule():
|
||||
global db_proxy_60
|
||||
global object_proxy_60
|
||||
|
||||
global common_proxy_61
|
||||
global db_proxy_61
|
||||
global model_proxy_61
|
||||
|
||||
# Use the old (pre 6.1) API.
|
||||
url = 'http://%s:%d/xmlrpc/' % (HOST, PORT)
|
||||
common_proxy_60 = xmlrpclib.ServerProxy(url + 'common')
|
||||
db_proxy_60 = xmlrpclib.ServerProxy(url + 'db')
|
||||
object_proxy_60 = xmlrpclib.ServerProxy(url + 'object')
|
||||
|
||||
# Use the new (6.1) API.
|
||||
url = 'http://%s:%d/openerp/6.1/xmlrpc/' % (HOST, PORT)
|
||||
common_proxy_61 = xmlrpclib.ServerProxy(url + 'common')
|
||||
db_proxy_61 = xmlrpclib.ServerProxy(url + 'db')
|
||||
model_proxy_61 = xmlrpclib.ServerProxy(url + 'model/' + DB)
|
||||
|
||||
# Mmm need to make sure the server is listening for XML-RPC requests.
|
||||
time.sleep(10)
|
||||
|
||||
def tearDownModule():
|
||||
""" Shutdown the OpenERP server similarly to a single ctrl-c. """
|
||||
openerp.service.stop_services()
|
||||
|
||||
class test_xmlrpc(unittest2.TestCase):
|
||||
|
||||
def test_xmlrpc_create_database_polling(self):
|
||||
def test_00_xmlrpc_create_database_polling(self):
|
||||
"""
|
||||
Simulate a OpenERP client requesting the creation of a database and
|
||||
polling the server until the creation is complete.
|
||||
@@ -80,6 +97,13 @@ class test_xmlrpc(unittest2.TestCase):
|
||||
'ir.model', 'search', [], {})
|
||||
assert ids
|
||||
|
||||
def test_xmlrpc_61_ir_model_search(self):
|
||||
""" Try a search on the object service. """
|
||||
ids = model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
|
||||
assert ids
|
||||
ids = model_proxy_61.execute(ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
|
||||
assert ids
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user