Beispiel #1
0
def to_objectid(objid):
    """字符对象转换成objectid
    """
    if objid is None:
        return objid

    try:
        objid = ObjectId(objid)
    except:
        util_log.error('%s is invalid objectid' % objid)
        return None

    return objid
Beispiel #2
0
def to_objectid(objid):
    """字符对象转换成objectid
    """  
    if objid is None:
        return objid
        
    try:
        objid = ObjectId(objid)
    except:
        util_log.error("%s is invalid objectid" % objid)
        return None
    
    return objid
Beispiel #3
0
def to_float(value, default=None):
    try:
        return float(value)
    except ValueError as e:
        util_log.error(e)
Beispiel #4
0
def json_decode(data, **kwargs):
    try:
        return json.loads(data, **kwargs)
    except:
        util_log.error('Uncaught exception in json_decode', exc_info=True)
Beispiel #5
0
def json_encode(data, **kwargs):
    try:
        return json.dumps(data, **kwargs)
    except Exception as e:
        util_log.error("Uncaught exception in json_encode", exc_info=True)
Beispiel #6
0
def to_float(value, default=None):
    try:
        return float(value)
    except ValueError as e:
        util_log.error(e)
Beispiel #7
0
def json_decode(data, **kwargs):
    try:
        return json.loads(data, **kwargs)
    except:
        util_log.error('Uncaught exception in json_decode', exc_info=True)
Beispiel #8
0
def json_encode(data, **kwargs):
    try:
        return json.dumps(data, **kwargs)
    except Exception as e:
        util_log.error("Uncaught exception in json_encode", exc_info=True)