Commit cf0bc418 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

web_service: py3

parent da94fa9b
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from erp5.component.tool.WebServiceTool import ConnectionError from erp5.component.tool.WebServiceTool import WebServiceConnectionError
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
class MethodWrapper(object): class MethodWrapper(object):
...@@ -45,11 +45,11 @@ class MethodWrapper(object): ...@@ -45,11 +45,11 @@ class MethodWrapper(object):
return method.absolute_url(), response return method.absolute_url(), response
## try: ## try:
## except ValueError, msg: ## except ValueError, msg:
## raise ConnectionError(msg) ## raise WebServiceConnectionError(msg)
## except Exception, msg: ## except Exception, msg:
## raise ConnectionError(msg) ## raise WebServiceConnectionError(msg)
else: else:
raise ConnectionError("Method %s does not exist" %(method_name)) raise WebServiceConnectionError("Method %s does not exist" %(method_name))
class DocumentConnection: class DocumentConnection:
""" """
......
...@@ -40,7 +40,7 @@ class SFTPError(Exception): ...@@ -40,7 +40,7 @@ class SFTPError(Exception):
""" """
Default exception for the connection Default exception for the connection
""" """
pass
class SFTPConnection: class SFTPConnection:
""" """
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
############################################################################## ##############################################################################
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
from erp5.component.tool.WebServiceTool import WebServiceConnectionError
class MethodWrapper(object): class MethodWrapper(object):
...@@ -42,8 +44,8 @@ class MethodWrapper(object): ...@@ -42,8 +44,8 @@ class MethodWrapper(object):
response = method(*args, **kw) response = method(*args, **kw)
return method.absolute_url(), response return method.absolute_url(), response
else: else:
from erp5.component.tool.WebServiceTool import ConnectionError raise WebServiceConnectionError("Method %s does not exist" %(method_name))
raise ConnectionError("Method %s does not exist" %(method_name))
class SQLConnection: class SQLConnection:
""" """
...@@ -52,10 +54,6 @@ class SQLConnection: ...@@ -52,10 +54,6 @@ class SQLConnection:
""" """
__allow_access_to_unprotected_subobjects__ = 1 __allow_access_to_unprotected_subobjects__ = 1
def __init__(self, *args, **kw):
""" Do nothing """
pass
def connect(self): def connect(self):
"""Get a handle to a remote connection.""" """Get a handle to a remote connection."""
return self return self
......
...@@ -34,8 +34,10 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool ...@@ -34,8 +34,10 @@ from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
import six import six
class ConnectionError(Exception):
pass class WebServiceConnectionError(Exception):
"""Error when connecting
"""
connection_plugin_registry = {} connection_plugin_registry = {}
...@@ -91,9 +93,7 @@ class WebServiceTool(BaseTool): ...@@ -91,9 +93,7 @@ class WebServiceTool(BaseTool):
""" """
Return list of available connection plugins Return list of available connection plugins
""" """
plugin_list = connection_plugin_registry.keys() return sorted(connection_plugin_registry.keys())
plugin_list.sort()
return plugin_list
security.declareProtected(Permissions.ManagePortal, 'connect') security.declareProtected(Permissions.ManagePortal, 'connect')
def connect(self, url, user_name=None, password=None, transport=None, transport_kw=None): def connect(self, url, user_name=None, password=None, transport=None, transport_kw=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment