From 1c76a88d6b17aa8748b1c32416162c13740de008 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 18 Jun 2013 16:22:22 +0200 Subject: [PATCH] transports: when transport is a tuple the second are keyword arguments for the constructor --- portail_citoyen_announces/transports.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/portail_citoyen_announces/transports.py b/portail_citoyen_announces/transports.py index d3830ee..bca6744 100644 --- a/portail_citoyen_announces/transports.py +++ b/portail_citoyen_announces/transports.py @@ -42,10 +42,14 @@ def get_transports(): if __TRANSPORTS is None: transports = [] for class_path in app_settings.transport_modes: + if not isinstance(class_path, basestring): + class_path, kwargs = class_path + else: + kwargs = {} module_path, class_name = class_path.rsplit('.', 1) try: module = import_module(module_path) - transports.append(getattr(module, class_name)()) + transports.append(getattr(module, class_name)(**kwargs)) except (ImportError, AttributeError), e: raise ImportError('Unable to load transport class %s' % class_path, e) __TRANSPORTS = transports