(uid, klass, token, fname="", url=None, action=PULL)
return result
Push or pull an object from a remote host or database.
Push or pull an object from a remote host or database.
Push or pull an object from a remote host or database .
def push_pull(uid, klass, token, fname="", url=None, action=PULL):
    """
    Push or pull an object from a remote host or database.
    """

    logger.info(f"{action.upper()} action being taken on {url or 'database'}.")

    # Send data to remote host
    if url:
        return api_response(url=url, action=action, fname=fname, token=token)

    # Handle object internally.
    obj = klass.objects.filter(uid=uid).first()

    if not obj:
        logger.error("Object does not exist")
        return

    # Push into database
    if action == PUSH:
        stream = open(fname, "r")
        data = hjson.load(stream)
        result = update(obj=obj, data=data)
    # Pull from database
    else:
        result = obj.api_data

    return result
def push_pull ( uid , klass , token , fname = "" , url = None , action = PULL ) : logger . info ( f"{action.upper()} action being taken on {url or 'database'}." ) # Send data to remote host if url : return api_response ( url = url , action = action , fname = fname , token = token ) # Handle object internally. obj = klass . objects . filter ( uid = uid ) . first ( ) if not obj : logger . error ( "Object does not exist" ) return # Push into database if action == PUSH : stream = open ( fname , "r" ) data = hjson . load ( stream ) result = update ( obj = obj , data = data ) # Pull from database else : result = obj . api_data return result