From 2a1c50c136c7293e9bc271e7366daba501a31111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 30 Apr 2011 18:48:41 +0200 Subject: [PATCH] Fix import of backend when used from another directory --- eopayment/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eopayment/__init__.py b/eopayment/__init__.py index 0a9bceb..dcc5719 100644 --- a/eopayment/__init__.py +++ b/eopayment/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import logging +import os +import sys from common import URL, HTML @@ -42,7 +44,11 @@ class Payment(object): def __init__(self, kind, options): self.kind = kind - module = __import__(kind) + sys.path.append(os.path.dirname(__file__)) + try: + module = __import__(kind) + finally: + sys.path.pop() self.backend = module.Payment(options) def request(self, amount, email=None, next_url=None):