Add patch for issue4592: allow to provide ssl_context in proteus

This commit is contained in:
Guillem Barba 2015-02-23 13:44:30 +01:00
parent ff90fad934
commit b0928b7ed6
2 changed files with 52 additions and 0 deletions

51
issue6951002_1.diff Normal file
View File

@ -0,0 +1,51 @@
# HG changeset patch
# User Guillem Barba <guillembarba@gmail.com>
allow to provide ssl_context to set_xmlrpc()
issue4592
review6951002
Index: proteus/proteus/config.py
===================================================================
--- a/proteus/proteus/config.py
+++ b/proteus/proteus/config.py
@@ -10,6 +10,7 @@
from decimal import Decimal
import datetime
import os
+import ssl
import urlparse
@@ -286,10 +287,13 @@
class XmlrpcConfig(Config):
'Configuration for XML-RPC'
- def __init__(self, url):
+ def __init__(self, url, ssl_context=None):
super(XmlrpcConfig, self).__init__()
self.url = url
- self.server = xmlrpclib.ServerProxy(url, allow_none=1, use_datetime=1)
+ if ssl_context is None:
+ ssl_context = ssl.create_default_context()
+ self.server = xmlrpclib.ServerProxy(url, allow_none=1, use_datetime=1,
+ context=ssl_context)
# TODO add user
self.user = None
self._context = self.server.model.res.user.get_preferences(True, {})
@@ -320,9 +324,9 @@
and '.' not in x[len(object_) + 1:]]
-def set_xmlrpc(url):
+def set_xmlrpc(url, ssl_context=None):
'Set XML-RPC as backend'
- _CONFIG.current = XmlrpcConfig(url)
+ _CONFIG.current = XmlrpcConfig(url, ssl_context=ssl_context)
return _CONFIG.current

1
series
View File

@ -40,3 +40,4 @@ issue10091002_1.diff
issue9911002_80001.diff
issue14971002_1.diff
issue6021003_1.diff
issue6951002_1.diff