# HG changeset patch # User Sandro Knauß # Date 1330183341 -3600 # Node ID 352527f2b6caa74826b87a7719a19e27aa385697 # Parent b381eaa774abcf1ea038a87f5158f03367999b8a no hostname used for reactor -> no need for option diff -r b381eaa774ab -r 352527f2b6ca iro/config.py --- a/iro/config.py Sat Feb 25 16:12:07 2012 +0100 +++ b/iro/config.py Sat Feb 25 16:22:21 2012 +0100 @@ -38,7 +38,6 @@ def __init__(self, name): self.name = name self.options={ - "hostname":Option(lambda x,y:x,long="Hostname under that twisted is running",must=True), "port":Option(partial(vInteger,minv=0),long="Port under that twisted is running",must=True), "dburl":Option(lambda x,y:x,long="Connection URL to database",must=True), } diff -r b381eaa774ab -r 352527f2b6ca iro/main.py --- a/iro/main.py Sat Feb 25 16:12:07 2012 +0100 +++ b/iro/main.py Sat Feb 25 16:22:21 2012 +0100 @@ -8,19 +8,23 @@ from .model import setEngine, setPool from .controller.pool import startPool, dbPool from .view import xmlrpc +import config -def runReactor(reactor, engine, root): +def runReactor(reactor, engine, port, root): setEngine(engine) startPool(reactor) setPool(dbPool) - reactor.listenTCP(7080, server.Site(root)) + reactor.listenTCP(port, server.Site(root)) logging.info("Server is running now...") reactor.run() if __name__ == '__main__': - engine = create_engine('mysql://test:test@localhost/test', + + config.readConfig() + + engine = create_engine(config.main.dburl, poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) @@ -32,4 +36,4 @@ root.addChild('2.0', v2) - runReactor(reactor, engine, root) + runReactor(reactor, engine, config.main.port, root) diff -r b381eaa774ab -r 352527f2b6ca tests/config.py --- a/tests/config.py Sat Feb 25 16:12:07 2012 +0100 +++ b/tests/config.py Sat Feb 25 16:22:21 2012 +0100 @@ -58,7 +58,6 @@ @patch('iro.config.ConfigParser.read') def testMain(self,pRead): sample_config = """[main] -hostname = localhost port = 8000 dburl = sdfdsafgsfdg """ @@ -69,7 +68,6 @@ @patch('iro.config.ConfigParser.read') def testMainBadPort(self,pRead): sample_config = """[main] -hostname = localhost port = -8000 dburl = sadfaserasg """ @@ -80,7 +78,6 @@ def testMainNoMust(self,pRead): sample_config = """[main] port = 8000 -dburl = asdfgdsrg """ config.configParser.readfp(io.BytesIO(sample_config)) self.assertRaises(config.NeededOption, config.configParser.read, []) @@ -91,7 +88,6 @@ config.main.options["test"] = config.Option(v) try: sample_config = """[main] -hostname = localhost dburl = sdfawersdf port = 8000 """ @@ -99,7 +95,6 @@ config.configParser.read([]) self.assertEqual(v.called,0) sample_config = """[main] -hostname = localhost dburl = adfgsdftsfg port = 8000 test = foohu