def _get_relationship(self, sourcefilename): session = sql.get_session() query = session.query(Relationship) query = query.filter_by(sourcefile=sourcefilename) try: relationship_ref = query.one() return relationship_ref except sql.NotFound: raise exception.NotFound(sourcefilename)
def _get_acl(self, sourcefilename): session = sql.get_session() query = session.query(ACL) query = query.filter_by(sourcefile=sourcefilename) try: acl_ref = query.one() return acl_ref except sql.NotFound: raise exception.NotFound(sourcefilename)
def get_acl(self, acl_id): session = sql.get_session() return identity.filter_user(self._get_acl(session, acl_id).to_dict())
def create_acl(self,id, acl): session = sql.get_session() with session.begin(): acl_ref = ACL.from_dict(acl) session.add(acl_ref) return acl_ref.to_dict()
def delete_relationship(self,sourcefilename): session = sql.get_session() with session.begin(): ref = self._get_relationship(sourcefilename) session.delete(ref)
def create_relationship(self, id, relationship): session = sql.get_session() with session.begin(): relationship_ref = Relationship.from_dict(relationship) session.add(relationship_ref) return relationship_ref.to_dict()
def create_acl(self, id, acl): session = sql.get_session() with session.begin(): acl_ref = ACL.from_dict(acl) session.add(acl_ref) return acl_ref.to_dict()
def delete_relationship(self, sourcefilename): session = sql.get_session() with session.begin(): ref = self._get_relationship(sourcefilename) session.delete(ref)