def post_page(self): notification_id_list = self.request.POST.getlist("notification_id") deleted, failed = 0, 0 for notification_id in notification_id_list: try: notification = Notification.get_unique(id=int(notification_id)) if not notification: message = "searched by notification ID %s." % notification_id raise EntityNotFoundError(Notification, message) notification.delete() deleted += 1 except Exception, exc: message = "Failed to delete notification %s: %s" % (notification_id, exc) logging.error(message) logging.exception(exc) failed += 1
def get_notification(self): notification = Notification.get_unique(id=self.notification_id) if not notification: message = "searched by notification ID %s." % self.notification_id raise EntityNotFoundError(Notification, message) return notification