← Back to team overview

oerppy-hackers team mailing list archive

[Branch ~oerppy-hackers/oerppy/trunk] Rev 23: Added a value check for Service parameters.

 

------------------------------------------------------------
revno: 23
committer: duncan@xxxxxxxxxx
branch nick: trunk
timestamp: Wed 2011-06-01 12:55:24 -0600
message:
  Added a value check for Service parameters.
modified:
  oerppy/exceptions.py
  oerppy/service.py
  oerppy/util.py


--
lp:oerppy
https://code.launchpad.net/~oerppy-hackers/oerppy/trunk

Your team oerppy Hackers is subscribed to branch lp:oerppy.
To unsubscribe from this branch go to https://code.launchpad.net/~oerppy-hackers/oerppy/trunk/+edit-subscription
=== modified file 'oerppy/exceptions.py'
--- oerppy/exceptions.py	2011-06-01 04:07:52 +0000
+++ oerppy/exceptions.py	2011-06-01 18:55:24 +0000
@@ -2,5 +2,5 @@
     pass
 
 
-class OpenERPPyConfigurationError(OpenERPPyError):
+class OpenERPPyConfigError(OpenERPPyError):
     pass

=== modified file 'oerppy/service.py'
--- oerppy/service.py	2011-06-01 16:58:57 +0000
+++ oerppy/service.py	2011-06-01 18:55:24 +0000
@@ -151,6 +151,11 @@
     """
     """
     def __init__(self, url, dbname, user, password):
+        for variable in [url, dbname, user, password]:
+            if not variable:
+                raise exception.OpenERPPyConfigError(
+                    "url, dbname, user and password must "
+                    "all have values set.")
         self.endpoints = ServiceEndpoints(url)
         self.dbname = dbname
         self.credentials = Credentials(user, password)

=== modified file 'oerppy/util.py'
--- oerppy/util.py	2011-06-01 18:49:40 +0000
+++ oerppy/util.py	2011-06-01 18:55:24 +0000
@@ -12,7 +12,7 @@
     """
     src_file = os.path.abspath(const.CONFIG_TEMPLATE)
     if not os.path.isfile(src_file):
-        raise exceptions.OpenERPPyConfigurationError(
+        raise exceptions.OpenERPPyConfigError(
             "Could not locate default configuration file '%s'." % src_file)
     src = open(src_file)
     data = src.read()