Пример #1
0
 def put(self, switch):
     session = Session()
     data = session.query(Switch).filter_by(pin=switch).first()
     if data is None:
         raise tornado.web.HTTPError(404)
     data.description = self.get_argument("description")
     try:
         session.commit()
     except Exception as e:
         #log.exception(e)
         session.rollback()
         raise tornado.web.HTTPError(500)
Пример #2
0
 def post(self):
     session = Session()
     try:
         switch = Switch()
         switch.pin = int(self.get_argument("pin"))
         switch.description = self.get_argument("description")
         session.add(switch)
         session.commit()
     except Exception as e:
         #log.exception(e)
         session.rollback()
         raise tornado.web.HTTPError(500)
Пример #3
0
    def delete(self, switch):
        session = Session()
        data = session.query(Switch).filter_by(pin=switch).first()
        if data is None:
            raise tornado.web.HTTPError(404)

        try:
            session.delete(data)
            session.commit()
        except Exception as e:
            #log.exception(e)
            session.rollback()
            raise tornado.web.HTTPError(500)