def raw_query_mongo_db(kwargs, database_name, collection_name):
    # for key in kwargs:
    #    print "arg: %s: %s" % (key, kwargs[key])
    """return a result list or an empty list"""
    l = []
    response_dict = {}

    try:
        mongodb_client_url = getattr(settings, 'MONGODB_CLIENT',
                                 'mongodb://localhost:27017/')
        mc = MongoClient(mongodb_client_url,document_class=OrderedDict)
        db = mc[database_name]
        transactions = db[collection_name]
        mysearchresult = transactions.find(kwargs)
        mysearchcount = mysearchresult.count()
        if mysearchcount > 0:
            response_dict['code'] = 200
            for d in mysearchresult:
                l.append(d)
            response_dict['results'] = l
    except:
        # print "Error reading from Mongo"
        # print str(sys.exc_info())
        response_dict['code'] = 400

        response_dict['type'] = "Error"
        response_dict['message'] = str(sys.exc_info())
    return response_dict
def raw_query_mongo_db ( kwargs , database_name , collection_name ) : l = [ ] response_dict = { } try : mongodb_client_url = getattr ( settings , 'MONGODB_CLIENT' , 'mongodb://localhost:27017/' ) mc = MongoClient ( mongodb_client_url , document_class = OrderedDict ) db = mc [ database_name ] transactions = db [ collection_name ] mysearchresult = transactions . find ( kwargs ) mysearchcount = mysearchresult . count ( ) if mysearchcount > 0 : response_dict [ 'code' ] = 200 for d in mysearchresult : l . append ( d ) response_dict [ 'results' ] = l except : response_dict [ 'code' ] = 400 response_dict [ 'type' ] = "Error" response_dict [ 'message' ] = str ( sys . exc_info ( ) ) return response_dict
return a result list or an empty list