def logout(self, cookie): cookie = str(cookie) userdata = UserData.get_by_key(cookie) if userdata: grumble.delete(userdata) with self._lock: if cookie in self._sessions: del self._sessions[cookie]
def remove_status(self, status): status = status.name() if isinstance(status, Status) else status assert status in self._statuses, "Cannot remove status %s from process %s" % (status, self.__class__.__name__) logger.debug("Removing status %s from process %s", status, self.__class__.__name__) statusdef = self._statuses[status] remove = None with gripe.db.Tx.begin(): for s in AddedStatus.query(parent = self): if s.status == status: remove = s if remove is not None: grumble.delete(remove) statusdef.removed(self) return
def remove_status(self, status): status = status.name() if isinstance(status, Status) else status assert status in self._statuses, "Cannot remove status %s from process %s" % ( status, self.__class__.__name__) logger.debug("Removing status %s from process %s", status, self.__class__.__name__) statusdef = self._statuses[status] remove = None with gripe.db.Tx.begin(): for s in AddedStatus.query(parent=self): if s.status == status: remove = s if remove is not None: grumble.delete(remove) statusdef.removed(self) return
def after_set(self, session, old_sessiontype, new_sessiontype): if not old_sessiontype or (old_sessiontype.name != new_sessiontype.name): t = self.get_interval_part_type(new_sessiontype, session) sameparttype = False if session.intervalpart: if isinstance(session.intervalpart, t): sameparttype = True else: part = session.intervalpart session.intervalpart = None grumble.delete(part) for i in Interval.query(ancestor = session): if i.intervalpart and not isinstance(i.intervalpart, t): part = i.intervalpart i.intervalpart = None grumble.delete(part) i.put() if t and not sameparttype: part = t(parent = session) part.put() session.intervalpart = part for i in Interval.query(ancestor = session): if i.intervalpart: part = i.intervalpart i.intervalpart = None grumble.delete(part) part = t(parent = i) part.put() i.intervalpart = part i.put()
def assigned(self, session, old_sessiontype, new_sessiontype): if not new_sessiontype: if old_sessiontype: raise grumble.errors.PropertyRequired(self.prop.name) elif not old_sessiontype or (old_sessiontype.name != new_sessiontype.name): t = self.get_interval_part_type(new_sessiontype, session) sameparttype = False if session.intervalpart: if isinstance(session.intervalpart, t): sameparttype = True else: part = session.intervalpart session.intervalpart = None grumble.delete(part) if old_sessiontype: for i in Interval.query(ancestor=session): if i.intervalpart and not isinstance(i.intervalpart, t): part = i.intervalpart i.intervalpart = None grumble.delete(part) i.put() if t and not sameparttype: part = t(parent=session) part.put() session.intervalpart = part for i in Interval.query(ancestor=session): if i.intervalpart: part = i.intervalpart i.intervalpart = None grumble.delete(part) part = t(parent=i) part.put() i.intervalpart = part i.put()
def delete_obj(self): self.object() and self.can_delete() and grumble.delete(self.object())