Exemplo n.º 1
0
def db_count(data_descriptor, session=None):
    schema = data_descriptor.getSchema()
    if schema < SCHEMA.schema_default_end:
        handler = default_db_get(data_descriptor, session)
    elif schema in user_handler_map:
        handler = user_handler_map[schema]("count", data_descriptor, session)
    else:
        print "data_function::db_get not support schema ", schema
        return None
    if handler is None:
        return None
    try:
        amount = handler.processCount()
    finally:
        handler.cleanup()
    return amount
Exemplo n.º 2
0
def db_count(data_descriptor, session = None):
    schema = data_descriptor.getSchema()
    if schema < SCHEMA.schema_default_end:
        handler = default_db_get(data_descriptor, session)
    elif schema in user_handler_map:
        handler = user_handler_map[schema]("count", data_descriptor, session)
    else :
        print "data_function::db_get not support schema ", schema
        return None
    if handler is None:
        return None
    try:
        amount = handler.processCount()
    finally:
        handler.cleanup()
    return amount
Exemplo n.º 3
0
    schema = data_descriptor.getSchema()
    data_type = data_descriptor.getDataType()

    handler = None
    #if session is None:
    #    session = create_session()

    # firstly try the default handler, and if there is no support data
    # type found, try to use the user defined handler, this feature can
    # allow the the extention of the default schema to extent its datatype,
    # and better to give the named of the handler who exttended schema
    # a _ext suffix
    try_user_defined_handler = True
    if schema < SCHEMA.schema_default_end:
        try:
            handler = default_db_get(data_descriptor, session)
            try_user_defined_handler = False
        except NoSupportDataType:
            try_user_defined_handler = True

    if try_user_defined_handler is True:
        if schema in user_handler_map:
            handler = user_handler_map[schema]("get", data_descriptor, session)
        else:
            logger.error("data_function::db_get not support schema %s" %
                         schema)
            return None

    if handler is None:
        return None
    result = handler.processQuery()
Exemplo n.º 4
0
    schema = data_descriptor.getSchema()
    data_type = data_descriptor.getDataType()

    handler = None
    #if session is None:
    #    session = create_session()

    # firstly try the default handler, and if there is no support data
    # type found, try to use the user defined handler, this feature can
    # allow the the extention of the default schema to extent its datatype,
    # and better to give the named of the handler who exttended schema
    # a _ext suffix
    try_user_defined_handler = True
    if schema < SCHEMA.schema_default_end:
        try:
            handler = default_db_get(data_descriptor, session)
            try_user_defined_handler = False
        except NoSupportDataType:
            try_user_defined_handler = True
        
    if try_user_defined_handler is True:
        if schema in user_handler_map:
            handler = user_handler_map[schema]("get", data_descriptor, session)
        else:
            logger.error("data_function::db_get not support schema %s"%schema)
            return None

    if handler is None:
        return None
    result = handler.processQuery()