Import backend using backend name.
authorgenjix <fake@lol.u>
Fri, 6 Apr 2012 17:51:16 +0000 (18:51 +0100)
committergenjix <fake@lol.u>
Fri, 6 Apr 2012 17:51:16 +0000 (18:51 +0100)
modules/abe/__init__.py
modules/libbitcoin/__init__.py [moved from modules/python_bitcoin/__init__.py with 100% similarity]
modules/libbitcoin/composed.py [moved from modules/python_bitcoin/composed.py with 100% similarity]
server.py

index b327114..d63847d 100644 (file)
@@ -371,7 +371,7 @@ class AbeStore(Datastore_class):
 
 from processor import Processor
 
-class AbeProcessor(Processor):
+class BlockchainProcessor(Processor):
 
     def __init__(self, config):
         Processor.__init__(self)
index 71878cd..f0b2b41 100755 (executable)
--- a/server.py
+++ b/server.py
@@ -86,10 +86,10 @@ if __name__ == '__main__':
         # NativeServer cannot be used with libbitcoin
         native_port = None
         config.set('server', 'native_port', '')
-        from modules.python_bitcoin import BlockchainProcessor
-    elif backend_name == "abe":
-        from modules.abe import AbeProcessor as BlockchainProcessor
-    else:
+    try:
+        backend = __import__("modules." + backend_name,
+                             fromlist=["BlockchainProcessor"])
+    except ImportError:
         sys.stderr.write('Unknown backend specified\n')
         sys.exit(-1)
 
@@ -98,7 +98,7 @@ if __name__ == '__main__':
     shared = dispatcher.shared
 
     # Create and register processors
-    chain_proc = BlockchainProcessor(config)
+    chain_proc = backend.BlockchainProcessor(config)
     dispatcher.register('blockchain', chain_proc)
 
     server_proc = ServerProcessor(config)