rom/model.py
def redis_writer_lua(conn, pkey, namespace, id, unique, udelete, delete,
                     data, keys, scored, prefix, suffix, geo, old_data, is_delete):
    '''
    ... Actually write data to Redis. This is an internal detail. Please don't
    call me directly.
    '''
    ldata = []
    for pair in data.items():
        ldata.extend(pair)

    for item in prefix:
        item.append(_prefix_score(item[-1]))
    for item in suffix:
        item.append(_prefix_score(item[-1]))

    data = [json.dumps(x, default=_fix_bytes) for x in
            (unique, udelete, delete, ldata, keys, scored, prefix, suffix, geo, is_delete, old_data)]
    result = _redis_writer_lua(conn, [], [namespace, id] + data)

    if isinstance(conn, _Pipeline):
        # we're in a pipelined write situation, don't parse the pipeline :P
        return

    if six.PY3:
        result = result.decode()

    result = json.loads(result)
    if 'unique' in result:
        result = result['unique']
        raise UniqueKeyViolation(
            "Value %r for %s:%s:uidx not distinct (failed for pk=%s)"%(
                unique[result], namespace, result, id),
            namespace, id)

    if 'race' in result:
        result = result['race']
        if pkey in result:
            raise EntityDeletedError(
                "Entity %s:%s deleted by another writer; use .save(force=True) to re-save"%(
                    namespace, id),
                namespace, id)

        raise DataRaceError(
            "%s:%s Column(s) %r updated by another writer, write aborted!"%(
                namespace, id, result),
            namespace, id)
def redis_writer_lua(conn, pkey, namespace, id, unique, udelete, delete,
                     data, keys, scored, prefix, suffix, geo, old_data, is_delete):
    '''
    ... Actually write data to Redis. This is an internal detail. Please don't
    call me directly.
    '''
    ldata = []
    for pair in data.items():
        ldata.extend(pair)

    for item in prefix:
        item.append(_prefix_score(item[-1]))
    for item in suffix:
        item.append(_prefix_score(item[-1]))

    data = [json.dumps(x, default=_fix_bytes) for x in
            (unique, udelete, delete, ldata, keys, scored, prefix, suffix, geo, is_delete, old_data)]
    result = _redis_writer_lua(conn, [], [namespace, id] + data)

    if isinstance(conn, _Pipeline):
        # we're in a pipelined write situation, don't parse the pipeline :P
        return

    if six.PY3:
        result = result.decode()

    result = json.loads(result)
    if 'unique' in result:
        result = result['unique']
        raise UniqueKeyViolation(
            "Value %r for %s:%s:uidx not distinct (failed for pk=%s)"%(
                unique[result], namespace, result, id),
            namespace, id)

    if 'race' in result:
        result = result['race']
        if pkey in result:
            raise EntityDeletedError(
                "Entity %s:%s deleted by another writer; use .save(force=True) to re-save"%(
                    namespace, id),
                namespace, id)

        raise DataRaceError(
            "%s:%s Column(s) %r updated by another writer, write aborted!"%(
                namespace, id, result),
            namespace, id)
def redis_writer_lua ( conn , pkey , namespace , id , unique , udelete , delete , data , keys , scored , prefix , suffix , geo , old_data , is_delete ) : ldata = [ ] for pair in data . items ( ) : ldata . extend ( pair ) for item in prefix : item . append ( _prefix_score ( item [ - 1 ] ) ) for item in suffix : item . append ( _prefix_score ( item [ - 1 ] ) ) data = [ json . dumps ( x , default = _fix_bytes ) for x in ( unique , udelete , delete , ldata , keys , scored , prefix , suffix , geo , is_delete , old_data ) ] result = _redis_writer_lua ( conn , [ ] , [ namespace , id ] + data ) if isinstance ( conn , _Pipeline ) : # we're in a pipelined write situation, don't parse the pipeline :P return if six . PY3 : result = result . decode ( ) result = json . loads ( result ) if 'unique' in result : result = result [ 'unique' ] raise UniqueKeyViolation ( "Value %r for %s:%s:uidx not distinct (failed for pk=%s)" % ( unique [ result ] , namespace , result , id ) , namespace , id ) if 'race' in result : result = result [ 'race' ] if pkey in result : raise EntityDeletedError ( "Entity %s:%s deleted by another writer; use .save(force=True) to re-save" % ( namespace , id ) , namespace , id ) raise DataRaceError ( "%s:%s Column(s) %r updated by another writer, write aborted!" % ( namespace , id , result ) , namespace , id )
... Actually write data to Redis. This is an internal detail. Please don't
    call me directly.
... Actually write data to Redis . This is an internal detail . Please don t call me directly .