def get_document_store(data_source_type, data_source_name, domain, load_source="unknown"): # change this to just 'data_source_name' after June 2018 type_or_name = (data_source_type, data_source_name) if data_source_type == SOURCE_COUCH: try: return CouchDocumentStore( couch_config.get_db_for_db_name(data_source_name)) except DatabaseNotFound: # in debug mode we may be flipping around our databases so don't fail hard here if settings.DEBUG: return None raise elif FORM_SQL in type_or_name: store = ReadonlyFormDocumentStore(domain) load_counter = form_load_counter elif CASE_SQL in type_or_name: store = ReadonlyCaseDocumentStore(domain) load_counter = case_load_counter elif SMS in type_or_name: store = ReadonlySMSDocumentStore() load_counter = sms_load_counter elif LEDGER_V2 in type_or_name: store = ReadonlyLedgerV2DocumentStore(domain) load_counter = ledger_load_counter elif LEDGER_V1 in type_or_name: store = LedgerV1DocumentStore(domain) load_counter = ledger_load_counter elif LOCATION in type_or_name: return ReadonlyLocationDocumentStore(domain) elif SYNCLOG_SQL in type_or_name: return ReadonlySyncLogDocumentStore() else: raise UnknownDocumentStore( 'getting document stores for backend {} is not supported!'.format( data_source_type)) track_load = load_counter(load_source, domain) return DocStoreLoadTracker(store, track_load)
def get_document_store(data_source_type, data_source_name, domain): if data_source_type == COUCH: try: return CouchDocumentStore( couch_config.get_db_for_db_name(data_source_name)) except DatabaseNotFound: # in debug mode we may be flipping around our databases so don't fail hard here if settings.DEBUG: return None raise elif data_source_type == FORM_SQL: return ReadonlyFormDocumentStore(domain) elif data_source_type == CASE_SQL: return ReadonlyCaseDocumentStore(domain) elif data_source_type == SMS: return ReadonlySMSDocumentStore() elif data_source_type == LEDGER_V2: return ReadonlyLedgerV2DocumentStore(domain) elif data_source_type == LEDGER_V1: return LedgerV1DocumentStore(domain) else: raise UnknownDocumentStore( 'getting document stores for backend {} is not supported!'.format( data_source_type))
def dao(self): return CouchDocumentStore(FakeCouchDb())
def __init__(self, couch_db, include_docs, couch_filter=None, extra_couch_view_params=None): self._couch_db = couch_db self._document_store = CouchDocumentStore(couch_db) self._couch_filter = couch_filter self._include_docs = include_docs self._extra_couch_view_params = extra_couch_view_params or {}
def __init__(self, couch_db, couch_filter=None, extra_couch_view_params=None): self._couch_db = couch_db self._document_store = CouchDocumentStore(couch_db) self._couch_filter = couch_filter self._extra_couch_view_params = extra_couch_view_params or {} self._last_processed_seq = None