Пример #1
0
    def get_app(self):
        # At the point Tornado
        patcher = mock.patch.object(tornado_options.mockable(), 'port',
                                    self.get_http_port())

        patcher.start()
        self.patchers.append(patcher)
        db = self.get_db()

        return application.get_application('..', db, tornado.options.options)
Пример #2
0
    def get_app(self):
        # At the point Tornado
        patcher = mock.patch.object(
            tornado_options.mockable(), 'port', self.get_http_port())

        patcher.start()
        self.patchers.append(patcher)
        db = self.get_db()

        return application.get_application('..', db, tornado.options.options)
Пример #3
0
# TODO: Nginx cache media
# TODO: sitemap.xml


if __name__ == "__main__":
    define_options(opts)
    opts.parse_command_line()
    for handler in logging.getLogger().handlers:
        if hasattr(handler, 'baseFilename'):
            print 'Logging to', handler.baseFilename
            break

    # TODO: Mongo connection options
    db = motor.MotorClient().motorblog
    loop = tornado.ioloop.IOLoop.current()
    loop.run_sync(partial(cache.startup, db))

    if opts.rebuild_indexes or opts.ensure_indexes:
        indexes.ensure_indexes(
            db.connection.sync_client().motorblog,
            drop=opts.rebuild_indexes)

    this_dir = os.path.dirname(__file__)
    application = application.get_application(this_dir, db, opts)
    http_server = httpserver.HTTPServer(application, xheaders=True)
    http_server.listen(opts.port)
    msg = 'Listening on port %s' % opts.port
    print msg
    logging.info(msg)
    loop.start()
Пример #4
0
# TODO: RPC over HTTPS
# TODO: a static-url function to set long cache TTL on media URLs
# TODO: Nginx cache media
# TODO: sitemap.xml

if __name__ == "__main__":
    define_options(opts)
    opts.parse_command_line()
    for handler in logging.getLogger().handlers:
        if hasattr(handler, 'baseFilename'):
            print 'Logging to', handler.baseFilename
            break

    # TODO: Mongo connection options
    db = motor.MotorClient().open_sync().motorblog
    cache.startup(db)

    if opts.rebuild_indexes or opts.ensure_indexes:
        indexes.ensure_indexes(db.connection.sync_client().motorblog,
                               drop=opts.rebuild_indexes)

    this_dir = os.path.dirname(__file__)
    application = application.get_application(this_dir, db, opts)
    http_server = httpserver.HTTPServer(application, xheaders=True)
    http_server.listen(opts.port)
    msg = 'Listening on port %s' % opts.port
    print msg
    logging.info(msg)
    tornado.ioloop.IOLoop.instance().start()