class Handler(object): def __init__(self, libraries, opts, testing=False, notify_changes=None): ctx = Context(libraries, opts, testing=testing, notify_changes=notify_changes) self.auth_controller = None if opts.auth: has_ssl = opts.ssl_certfile is not None and opts.ssl_keyfile is not None prefer_basic_auth = {'auto':has_ssl, 'basic':True}.get(opts.auth_mode, False) self.auth_controller = AuthController(user_credentials=ctx.user_manager, prefer_basic_auth=prefer_basic_auth) self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller) for module in SRV_MODULES: module = import_module('calibre.srv.' + module) self.router.load_routes(vars(module).itervalues()) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log if self.auth_controller is not None: self.auth_controller.log = log def set_jobs_manager(self, jobs_manager): self.router.ctx.jobs_manager = jobs_manager def close(self): self.router.ctx.library_broker.close() @property def ctx(self): return self.router.ctx
class Handler: def __init__(self, libraries, opts, testing=False, notify_changes=None): ctx = Context(libraries, opts, testing=testing, notify_changes=notify_changes) self.auth_controller = None if opts.auth: has_ssl = opts.ssl_certfile is not None and opts.ssl_keyfile is not None prefer_basic_auth = {'auto':has_ssl, 'basic':True}.get(opts.auth_mode, False) self.auth_controller = AuthController( user_credentials=ctx.user_manager, prefer_basic_auth=prefer_basic_auth, ban_time_in_minutes=opts.ban_for, ban_after=opts.ban_after) self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller) for module in SRV_MODULES: module = import_module('calibre.srv.' + module) self.router.load_routes(itervalues(vars(module))) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log if self.auth_controller is not None: self.auth_controller.log = log def set_jobs_manager(self, jobs_manager): self.router.ctx.jobs_manager = jobs_manager def close(self): self.router.ctx.library_broker.close() @property def ctx(self): return self.router.ctx
class Handler(object): def __init__(self, libraries, opts, testing=False): ctx = Context(libraries, opts, testing=testing) self.auth_controller = None if opts.auth: has_ssl = opts.ssl_certfile is not None and opts.ssl_keyfile is not None prefer_basic_auth = { 'auto': has_ssl, 'basic': True }.get(opts.auth_mode, 'digest') self.auth_controller = AuthController( user_credentials=ctx.user_manager, prefer_basic_auth=prefer_basic_auth) self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller) for module in ('content', 'ajax', 'code'): module = import_module('calibre.srv.' + module) self.router.load_routes(vars(module).itervalues()) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log if self.auth_controller is not None: self.auth_controller.log = log def close(self): self.router.ctx.library_broker.close()
class Handler(object): def __init__(self, libraries, opts, testing=False): ctx = Context(libraries, opts, testing=testing) self.auth_controller = None if opts.auth: has_ssl = opts.ssl_certfile is not None and opts.ssl_keyfile is not None prefer_basic_auth = {'auto':has_ssl, 'basic':True}.get(opts.auth_mode, 'digest') self.auth_controller = AuthController(user_credentials=ctx.user_manager, prefer_basic_auth=prefer_basic_auth) self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller) for module in ('content', 'ajax', 'code', 'legacy', 'opds', 'books'): module = import_module('calibre.srv.' + module) self.router.load_routes(vars(module).itervalues()) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log if self.auth_controller is not None: self.auth_controller.log = log def set_jobs_manager(self, jobs_manager): self.router.ctx.jobs_manager = jobs_manager def close(self): self.router.ctx.library_broker.close()
class Handler(object): def __init__(self, libraries, opts, testing=False): self.router = Router(ctx=Context(libraries, opts, testing=testing), url_prefix=opts.url_prefix) for module in ('content', 'ajax'): module = import_module('calibre.srv.' + module) self.router.load_routes(vars(module).itervalues()) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log
class Handler(object): def __init__(self, libraries, opts, testing=False): self.router = Router(ctx=Context(libraries, opts, testing=testing), url_prefix=opts.url_prefix) for module in ('content', 'ajax', 'code'): module = import_module('calibre.srv.' + module) self.router.load_routes(vars(module).itervalues()) self.router.finalize() self.router.ctx.url_for = self.router.url_for self.dispatch = self.router.dispatch def set_log(self, log): self.router.ctx.log = log def close(self): self.router.ctx.library_broker.close()