]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
hub: Refactor main application
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 16:15:04 +0000 (17:15 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 16:15:04 +0000 (17:15 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/hub/__init__.py

index 9035e0e2c819e66a553bee9bf667946c11947bcb..e7b7391d14c0770e7cabc29458c308ddbd1b5d41 100644 (file)
@@ -8,6 +8,7 @@ import tornado.options
 import tornado.web
 
 from .. import Backend
+from ..decorators import *
 
 from . import handlers
 
@@ -17,16 +18,12 @@ tornado.options.parse_command_line()
 
 class Application(tornado.web.Application):
        def __init__(self):
-               self.__pakfire = None
-
                settings = dict(
                        debug = tornado.options.options.debug,
                        gzip  = True,
                )
 
-               tornado.web.Application.__init__(self, **settings)
-
-               self.add_handlers(r"pakfirehub.ipfire.org", [
+               tornado.web.Application.__init__(self, [
                        # Redirect strayed users.
                        #(r"/", handlers.RedirectHandler),
 
@@ -61,16 +58,13 @@ class Application(tornado.web.Application):
                        (r"/uploads/(.*)/sendchunk", handlers.UploadsSendChunkHandler),
                        (r"/uploads/(.*)/finished", handlers.UploadsFinishedHandler),
                        (r"/uploads/(.*)/destroy", handlers.UploadsDestroyHandler),
-               ])
+               ], **settings)
 
                logging.info("Successfully initialied application")
 
-       @property
-       def pakfire(self):
-               if self.__pakfire is None:
-                       self.__pakfire = Backend()
-
-               return self.__pakfire
+       @lazy_property
+       def backend(self):
+               return Backend()
 
        def __del__(self):
                logging.info("Shutting down application")