Fix import of backend when used from another directory

This commit is contained in:
Frédéric Péters 2011-04-30 18:48:41 +02:00
parent 179a2e5fc9
commit 2a1c50c136
1 changed files with 7 additions and 1 deletions

View File

@ -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):