Merge lp:~xmo-deactivatedaccount/openerp-client-lib/trunk into lp:openerp-client-lib

Proposed by Xavier (Open ERP)
Status: Merged
Merged at revision: 27
Proposed branch: lp:~xmo-deactivatedaccount/openerp-client-lib/trunk
Merge into: lp:openerp-client-lib
Diff against target: 155 lines (+34/-33)
1 file modified
openerplib/main.py (+34/-33)
To merge this branch: bzr merge lp:~xmo-deactivatedaccount/openerp-client-lib/trunk
Reviewer Review Type Date Requested Status
Nicolas Vanhoren (OpenERP) Pending
Review via email: mp+75328@code.launchpad.net

Description of the change

Bunch o' fixes:

* Added links to the homepage and code repo in the module docstring
* Fixed typos, docstring location errors, logging calls, noops, an overly complex loop and too broad exception handlers

To post a comment you must log in.
34. By Xavier (Open ERP)

[FIX] typo

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Fixed a code typo in an iteration

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerplib/main.py'
2--- openerplib/main.py 2011-09-14 09:52:52 +0000
3+++ openerplib/main.py 2011-09-14 11:51:43 +0000
4@@ -32,6 +32,9 @@
5
6 """
7 OpenERP Client Library
8+
9+Home page: http://pypi.python.org/pypi/openerp-client-lib
10+Code repository: https://code.launchpad.net/~niv-openerp/openerp-client-lib/trunk
11 """
12
13 import xmlrpclib
14@@ -40,14 +43,12 @@
15
16 try:
17 import cPickle as pickle
18- pickle.__name__
19-except:
20+except ImportError:
21 import pickle
22
23 try:
24 import cStringIO as StringIO
25- StringIO.__name__
26-except:
27+except ImportError:
28 import StringIO
29
30 _logger = logging.getLogger(__name__)
31@@ -102,7 +103,7 @@
32 self.faultString = faultString
33 self.args = (faultCode, faultString)
34
35-class NetRPC:
36+class NetRPC(object):
37 """
38 Low level class for NetRPC protocol.
39 """
40@@ -191,7 +192,7 @@
41 socket.disconnect()
42 return result
43
44-class Service:
45+class Service(object):
46 """
47 A class to execute RPC calls on a specific service of the remote server.
48 """
49@@ -215,13 +216,13 @@
50 """
51 self.__logger.debug('args: %r', args)
52 result = self.connector.send(self.service_name, method, *args)
53- self.__logger.debug('result: %r' % result)
54+ self.__logger.debug('result: %r', result)
55 return result
56 return proxy
57
58 class Connection(object):
59 """
60- A class to represent a connection with authentification to an OpenERP Server.
61+ A class to represent a connection with authentication to an OpenERP Server.
62 It also provides utility methods to interact with the server more easily.
63 """
64 __logger = _getChildLogger(_logger, 'connection')
65@@ -263,8 +264,8 @@
66
67 def check_login(self, force=True):
68 """
69- Checks that the login information is valid. Throws an AuthentificationError if the
70- authentification fails.
71+ Checks that the login information is valid. Throws an AuthenticationError if the
72+ authentication fails.
73
74 :param force: Force to re-check even if this Connection was already validated previously.
75 Default to True.
76@@ -273,46 +274,46 @@
77 return
78
79 if not self.database or not self.login or self.password is None:
80- raise AuthentificationError("Creditentials not provided")
81+ raise AuthenticationError("Creditentials not provided")
82
83 self.user_id = self.get_service("common").login(self.database, self.login, self.password)
84 if not self.user_id:
85- raise AuthentificationError("Authentification failure")
86- self.__logger.debug("Authentified with user id %s" % self.user_id)
87-
88- """
89- Returns a Model instance to allow easy remote manipulation of an OpenERP model.
90-
91- :param model_name: The name of the model.
92- """
93+ raise AuthenticationError("Authentication failure")
94+ self.__logger.debug("Authenticated with user id %s", self.user_id)
95+
96 def get_model(self, model_name):
97+ """
98+ Returns a Model instance to allow easy remote manipulation of an OpenERP model.
99+
100+ :param model_name: The name of the model.
101+ """
102 return Model(self, model_name)
103
104- """
105- Returns a Service instance to allow easy manipulation of one of the services offered by the remote server.
106- Please note this Connection instance does not need to have valid authenfication information since authentification
107- is only necessary for the "object" service that handles models.
108-
109- :param service_name: The name of the service.
110- """
111 def get_service(self, service_name):
112+ """
113+ Returns a Service instance to allow easy manipulation of one of the services offered by the remote server.
114+ Please note this Connection instance does not need to have valid authentication information since authentication
115+ is only necessary for the "object" service that handles models.
116+
117+ :param service_name: The name of the service.
118+ """
119 return Service(self.connector, service_name)
120
121-class AuthentificationError(Exception):
122+class AuthenticationError(Exception):
123 """
124- An error thrown when an authentification to an OpenERP server failed.
125+ An error thrown when an authentication to an OpenERP server failed.
126 """
127 pass
128
129 class Model(object):
130 """
131 Useful class to dialog with one of the models provided by an OpenERP server.
132- An instance of this class depends on a Connection instance with valid authenfication information.
133+ An instance of this class depends on a Connection instance with valid authentication information.
134 """
135
136 def __init__(self, connection, model_name):
137 """
138- :param connection: A valid Connection instance with correct authentification information.
139+ :param connection: A valid Connection instance with correct authentication information.
140 :param model_name: The name of the model.
141 """
142 self.connection = connection
143@@ -341,10 +342,10 @@
144 if method == "read":
145 if isinstance(result, list) and len(result) > 0 and "id" in result[0]:
146 index = {}
147- for i in xrange(len(result)):
148- index[result[i]["id"]] = result[i]
149+ for r in result:
150+ index[r['id']] = r
151 result = [index[x] for x in args[0]]
152- self.__logger.debug('result: %r' % result)
153+ self.__logger.debug('result: %r', result)
154 return result
155 return proxy
156

Subscribers

People subscribed via source and target branches

to all changes: