def _update_map(self, map, name=None, filepath=None): """ Delete a mapfile entry from database. """ if name: map.name = name if filepath: map.filepath = filepath Session.commit()
def _new_map_from_user(self, user, name, filepath): """ Create a new mapfile entry in database. """ map = Map(name, filepath) map.user = Session.query(User).filter(User.login==user).one() Session.add(map) Session.commit() return map
def _new_map_from_user(self, user, name, filepath): """ Create a new mapfile entry in database. """ map = Map(name, filepath) map.user = Session.query(User).filter(User.login == user).one() Session.add(map) Session.commit() return map
def _delete_map_from_user_by_id(self, user, map_id): """ Delete a mapfile entry from database. """ map = self._get_map_from_user_by_id(user, map_id) if map is None: return None Session.delete(map) Session.commit() return map
def _get_map_from_user_by_id(self, user, map_id): """ Get a mapfile owned by a user from the database by map_id. """ req = Session.query(Map).select_from(join(Map, User)) try: return req.filter(and_(User.login==user, Map.id==map_id)).one() except Exception, e: return None
def _get_map_from_user_by_id(self, user, map_id): """ Get a mapfile owned by a user from the database by map_id. """ req = Session.query(Map).select_from(join(Map, User)) try: return req.filter(and_(User.login == user, Map.id == map_id)).one() except Exception, e: return None
def _get_maps_from_user(self, user): """ Get mapfiles owned by a user from the database. """ req = Session.query(Map).select_from(join(Map, User)) return req.filter(User.login==user).all()
def _get_datastore_by_id(self, datastore_id): """ Get from the database the datastore identifier by datastore_id. """ return Session.query(model.DataStore).get(datastore_id)
def _get_maps_from_user(self, user): """ Get mapfiles owned by a user from the database. """ req = Session.query(Map).select_from(join(Map, User)) return req.filter(User.login == user).all()