def __init__(self, **kw): from AnkiServer.threading import getCollectionManager self.data_root = os.path.abspath(kw.get('data_root', '.')) self.base_url = kw.get('base_url', '/') self.setup_new_collection = kw.get('setup_new_collection') self.hook_pre_sync = kw.get('hook_pre_sync') self.hook_post_sync = kw.get('hook_post_sync') self.hook_download = kw.get('hook_download') self.hook_upload = kw.get('hook_upload') try: self.session_manager = kw['session_manager'] except KeyError: self.session_manager = SimpleSessionManager() try: self.user_manager = kw['user_manager'] except KeyError: self.user_manager = SimpleUserManager() try: self.collection_manager = kw['collection_manager'] except KeyError: self.collection_manager = getCollectionManager() # make sure the base_url has a trailing slash if not self.base_url.endswith('/'): self.base_url += '/'
def __init__(self, **kw): from AnkiServer.threading import getCollectionManager self.data_root = os.path.abspath(kw.get('data_root', '.')) self.base_url = kw.get('base_url', '/') self.setup_new_collection = kw.get('setup_new_collection') self.hook_pre_sync = kw.get('hook_pre_sync') self.hook_post_sync = kw.get('hook_post_sync') self.hook_download = kw.get('hook_download') self.hook_upload = kw.get('hook_upload') try: self.session_manager = kw['session_manager'] except KeyError: self.session_manager = SimpleSessionManager() try: self.user_manager = kw['user_manager'] except KeyError: self.user_manager = SimpleUserManager() try: self.collection_manager = kw['collection_manager'] except KeyError: self.collection_manager = getCollectionManager() # make sure the base_url has a trailing slash if len(self.base_url) == 0: self.base_url = '/' elif self.base_url[-1] != '/': self.base_url = base_url + '/'
def __init__(self, **kw): from AnkiServer.threading import getCollectionManager self.data_root = os.path.abspath(kw.get("data_root", ".")) self.base_url = kw.get("base_url", "/") self.base_media_url = kw.get("base_media_url", "/") self.setup_new_collection = kw.get("setup_new_collection") self.hook_pre_sync = kw.get("hook_pre_sync") self.hook_post_sync = kw.get("hook_post_sync") self.hook_download = kw.get("hook_download") self.hook_upload = kw.get("hook_upload") try: self.session_manager = kw["session_manager"] except KeyError: self.session_manager = SimpleSessionManager() try: self.user_manager = kw["user_manager"] except KeyError: self.user_manager = SimpleUserManager() try: self.collection_manager = kw["collection_manager"] except KeyError: self.collection_manager = getCollectionManager() # make sure the base_url has a trailing slash if not self.base_url.endswith("/"): self.base_url += "/" if not self.base_media_url.endswith("/"): self.base_media_url += "/"
def __init__(self, data_root, **kw): from AnkiServer.threading import getCollectionManager self.data_root = os.path.abspath(data_root) self.allowed_hosts = kw.get('allowed_hosts', '*') self.setup_new_collection = kw.get('setup_new_collection') # TODO: implement! The idea is that these will run before/after executing any handler #self.hook_pre_execute = kw.get('hook_pre_execute') #self.hook_post_execute = kw.get('hook_post_execute') if kw.get('collection_manager') is not None: self.collection_manager = kw['collection_manager'] else: self.collection_manager = getCollectionManager() self.handlers = {} for type_list in self.handler_types: if type(type_list) is not list: type_list = [type_list] for handler_type in type_list: self.handlers[handler_type] = {} if kw.get('use_default_handlers', True): self.add_handler_group('collection', CollectionHandler()) self.add_handler_group('note', NoteHandler()) self.add_handler_group('model', ModelHandler()) self.add_handler_group('deck', DeckHandler()) self.add_handler_group('card', CardHandler()) # hold per collection session data self.sessions = {}
def __init__(self, data_root, **kw): from AnkiServer.threading import getCollectionManager self.data_root = os.path.abspath(data_root) self.allowed_hosts = kw.get('allowed_hosts', '*') self.setup_new_collection = kw.get('setup_new_collection') self.hook_pre_execute = kw.get('hook_pre_execute') self.hook_post_execute = kw.get('hook_post_execute') if kw.get('collection_manager') is not None: self.collection_manager = kw['collection_manager'] else: self.collection_manager = getCollectionManager() self.handlers = {} for type_list in self.handler_types: if type(type_list) is not list: type_list = [type_list] for handler_type in type_list: self.handlers[handler_type] = {} if kw.get('use_default_handlers', True): self.add_handler_group('collection', CollectionHandler()) self.add_handler_group('note', NoteHandler()) self.add_handler_group('model', ModelHandler()) self.add_handler_group('deck', DeckHandler()) self.add_handler_group('card', CardHandler()) # hold per collection session data self.sessions = {}