def delete_obj(obj): """ Deletes any arbitrary object from the SQLAlchemy Session and cascades deletes to evaluations. :param obj: object to delete """ Session.delete(obj) Session.flush() Session.commit()
def _delete_date(self, id, id2): c.entity = h.fetch_obj(Entity, id, new_id=True) # get the date object date = self._get_date(id, id2) if date in c.entity.dates: idx = c.entity.dates.index(date) Session.delete(c.entity.dates[idx]) Session.commit() return "OK"
def _delete_searchpatterns(self, id): c.entity = h.fetch_obj(Entity, id, new_id=True) # add a new search pattern pattern = request.params.get("pattern", None) if pattern is None: abort(400) pattern = pattern.strip() # Boneheaded working around bogus associationproxy in SQLAlchemy 0.6.8 # Why this isn't just c.entity.searchpatterns.remove(pattern)? who knows for spattern in c.entity._spatterns: if spattern.searchpattern == pattern: Session.delete(spattern) Session.commit() return "OK"
def _delete_searchpatterns(self, id): c.entity = h.fetch_obj(Entity, id, new_id=True) # add a new search pattern pattern = request.params.get('pattern', None) if pattern is None: abort(400) pattern = pattern.strip() # Boneheaded working around bogus associationproxy in SQLAlchemy 0.6.8 # Why this isn't just c.entity.searchpatterns.remove(pattern)? who knows for spattern in c.entity._spatterns: if spattern.searchpattern == pattern: Session.delete(spattern) Session.commit() return "OK"