Example #1
0
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)
    elif data_source_type == LOCATION:
        return ReadonlyLocationDocumentStore(domain)
    else:
        raise UnknownDocumentStore(
            'getting document stores for backend {} is not supported!'.format(
                data_source_type))
def get_document_store(data_source_type, data_source_name, domain):
    # 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:
        return ReadonlyFormDocumentStore(domain)
    elif CASE_SQL in type_or_name:
        return ReadonlyCaseDocumentStore(domain)
    elif SMS in type_or_name:
        return ReadonlySMSDocumentStore()
    elif LEDGER_V2 in type_or_name:
        return ReadonlyLedgerV2DocumentStore(domain)
    elif LEDGER_V1 in type_or_name:
        return LedgerV1DocumentStore(domain)
    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))
Example #3
0
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)
    elif data_source_type == LOCATION:
        return ReadonlyLocationDocumentStore(domain)
    else:
        raise UnknownDocumentStore(
            'getting document stores for backend {} is not supported!'.format(data_source_type)
        )
Example #4
0
def get_document_store(data_source_type, data_source_name, domain):
    # 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:
        return ReadonlyFormDocumentStore(domain)
    elif CASE_SQL in type_or_name:
        return ReadonlyCaseDocumentStore(domain)
    elif SMS in type_or_name:
        return ReadonlySMSDocumentStore()
    elif LEDGER_V2 in type_or_name:
        return ReadonlyLedgerV2DocumentStore(domain)
    elif LEDGER_V1 in type_or_name:
        return LedgerV1DocumentStore(domain)
    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)
        )
Example #5
0
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 = FormDocumentStore(domain)
        load_counter = form_load_counter
    elif CASE_SQL in type_or_name:
        store = CaseDocumentStore(domain)
        load_counter = case_load_counter
    elif SMS in type_or_name:
        store = SMSDocumentStore()
        load_counter = sms_load_counter
    elif LEDGER_V2 in type_or_name:
        store = LedgerV2DocumentStore(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 LocationDocumentStore(domain)
    elif SYNCLOG_SQL in type_or_name:
        return SyncLogDocumentStore()
    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)