def getUserData(*, userID='', c): if userID: userOb = c.execute('SELECT * FROM users WHERE id = ?', [userID]).fetchone() entityOb = c.execute('SELECT * FROM entities WHERE id = ?', [userID]).fetchone() user = readRows('users', {'id': userID})[0] entity = readRows('entities', {'id': userID})[0] return (user, entity) return ('', '')
def canUserModifyRelationship(userID, relationshipID, c): if userID and relationshipID: thing = readRows('relationships', { 'owner': userID, 'id': relationshipID }) return thing[0] if thing else False else: return None
def canUserModifyEntity(userID, entityID, c): if userID and entityID: thing = readRows('relationships', { 'owner': userID, 'property': entityID }) return thing[0] if thing else False else: return None
def read(apikey, id='*', category=None, name=None, description=None, count=10, page=1, method='and'): args = locals() result = readRows(__tablename, args) return buildResponse(result)
def read(apikey, id='*', description=None, owner=None, _property=None, count=None, page=None, method='and'): args = locals() result = readRows(__tablename, args) return buildResponse(result)
def claimEntity(userID, entityID, c): """Claims an entity for the provided userID, provided its not already claimed""" existantRelationships = readRows('relationships', {'property': entityID}) ownership = [x for x in existantRelationships if indicatesOwnership(x)] if ownership: return False else: return addRows('relationships', [{ 'owner': userID, 'user': userID, 'property': entityID }])