def checkPin(self): """Check for PIN existence.""" pin = request.params.get('val') try: Session.query(ModeratorPin).filter(or_(ModeratorPin.pin == pin, ParticipantPin.pin == pin)).one() except NoResultFound, e: return('Pin available') response.status = '500 Pin Unavailable' return def delete(self, id): """Delete a certain PIN""" try: obj = Session.query(ModeratorPin).get(id) except Exception, e: log.critical('Could not fetch the pin because: %s' % e) try: if obj is not None: Session.delete(obj) Session.commit() h.flash('PIN has been deleted.') redirect(request.headers.get('REFERER', url(controller='main/new_pin', action='index'))) except SQLAlchemyError, e: log.critical('Could not delete the PIN(%s) because: %s' % (id, e)) h.flash('Could not delete the PIN.') redirect(request.headers.get('REFERER', url(controller='main/new_pin', action='index')))