summaryrefslogtreecommitdiffstats
path: root/eopayment/__init__.py
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2012-02-20 16:32:44 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2012-02-20 16:32:44 (GMT)
commite9e0d19730660b7581e83d2c40ea6ff334ddf8b6 (patch)
tree64b406014ee51ab00cb69d0a3698f68d2364326d /eopayment/__init__.py
parent315297d29f39b2d8208092a7d050ba607751614a (diff)
downloadeopayment-e9e0d19730660b7581e83d2c40ea6ff334ddf8b6.zip
eopayment-e9e0d19730660b7581e83d2c40ea6ff334ddf8b6.tar.gz
eopayment-e9e0d19730660b7581e83d2c40ea6ff334ddf8b6.tar.bz2
allow to specify the logger to user #2
Diffstat (limited to 'eopayment/__init__.py')
-rw-r--r--eopayment/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/eopayment/__init__.py b/eopayment/__init__.py
index 634a000..a6125c6 100644
--- a/eopayment/__init__.py
+++ b/eopayment/__init__.py
@@ -62,10 +62,16 @@ class Payment(object):
'''
- def __init__(self, kind, options, log_domain='eopayment'):
- self.logger = logging.getLogger(log_domain)
+ def __init__(self, kind, options, logger=None):
+ self.logger = logger
self.kind = kind
- self.backend = get_backend(kind)(options, logger=self.logger)
+ self.backend = get_backend(kind)(options, **self.__get_extra_args())
+
+ def __get_extra_args(self):
+ if self.logger:
+ return { 'logger': self.logger }
+ else:
+ return {}
def request(self, amount, email=None, next_url=None):
'''Request a payment to the payment backend.
@@ -98,7 +104,8 @@ class Payment(object):
# present the form in HTML to the user
'''
- return self.backend.request(amount, email=email, next_url=next_url, logger=self.logger)
+ return self.backend.request(amount, email=email, next_url=next_url,
+ **self.__get_extra_args())
def response(self, query_string):
'''
@@ -133,7 +140,7 @@ class Payment(object):
your site as a web service.
'''
- return self.backend.response(query_string, logger=self.logger)
+ return self.backend.response(query_string, **self.__get_extra_args())
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)