extras/iro.tac
branchdevel
changeset 286 ec5a280707f3
parent 270 665c3ea02d35
child 294 0e75bd39767d
--- a/extras/iro.tac	Fri Aug 10 13:13:20 2012 +0200
+++ b/extras/iro.tac	Fri Aug 10 13:20:42 2012 +0200
@@ -1,58 +1,11 @@
-from twisted.application.service import Service, Application
-from twisted.application import internet
-from twisted.web import resource, server
-from twisted.internet import reactor
-from twisted.python import log
-
-from sqlalchemy import create_engine, pool
-
-from iro import config, install
-from iro.view import xmlrpc
-from iro.model import setEngine, setPool
-from iro.controller.pool import startPool, dbPool
+from twisted.application.service import Application
 
-class IroService(Service):
-    def startService(self):
-        log.msg("Starting service...")
-        engine = create_engine(config.main.dburl,
-               poolclass = pool.SingletonThreadPool,  pool_size=dbPool.maxthreads, )
-
-        setEngine(engine)
-        startPool(reactor)
-        setPool(dbPool)
-        reactor.callWhenRunning(config.readConfig)
-        Service.startService(self)
-
+from iro import iro
 
 def get_application():
     app = Application("Iro")
-    if not install.checkConfig():
-        log.err("You can create a sample configuration file by running iro-install")
-        raise Exception("Please update or create your configuration file iro.conf.")
-    config.init()
-
-    if not install.checkDatabaseConnection():
-        raise Exception("Can't connect to database")
-    
-    if not install.checkDatabase():
-        raise Exception("Database not in right format. Please run iro-install --install")
-
-    routes = [ s for s in config.configParser.sections() if not s in ["main",]]
-    ao =  install.getAllRoutes(routes, False)
-    for o in  ao["orphand"]:
-        log.msg("Offer(%s) is orphand (no route using this offer)."%o)
-    if ao["added"]:
-        raise Exception("offerlist is not up-to-date.\nPlease run iro-install --update")
-
-    root = resource.Resource()
-    root = xmlrpc.appendResource(root)
-    
-    v2 = resource.Resource()
-    v2 = xmlrpc.appendResource(root)
-    root.putChild('2.0', v2)
-
-    internet.TCPServer(config.main.port, server.Site(root)).setServiceParent(app)
-    IroService().setServiceParent(app)
+    cfg={"config":"iro.conf"}
+    iro.makeService(cfg).setServiceParent(app)
     return app
 
 application = get_application()