def post(self):
     '''
     @summary: deals with POST for adding a resource
     '''
     resource = self.get_argument('resource')
     title = self.get_argument('title')
     lifetime = int(self.get_argument('lifetime'))
     wait = int(self.get_argument('wait'))
     logging.info("Resource - %s - Lock Requested with (%s, %s, %s)" % (resource, title, lifetime, wait))
     lock = Lock(resource, title, wait, lifetime)
     LOCK_MANAGER_INSTANCE.add_lock(resource, lock)
     logging.debug(lock.uid)
     self.render("requestlockresponse.html", name=resource, uid=lock.uid)
 def post(self, name):
     '''
     @summary: deals with POST request (acquiring locks on resource)
     @param name: name of the resource
     '''
     raw_body = self.request.body.decode('utf-8')
     if len(raw_body) == 0:
         self.send_error(status_code=400, message="empty body")
         return
     lock = Lock.from_json(name, raw_body)
     if not(lock):
         self.send_error(status_code=400, message="invalid json body")
         return
     lock.set_callbacks(functools.partial(self.on_active_wrapper, name, lock),
                        self.on_delete_wrapper)
     LOCK_MANAGER_INSTANCE.add_lock(name, lock)
예제 #3
0
 def post(self, name):
     '''
     @summary: deals with POST request (acquiring locks on resource)
     @param name: name of the resource
     '''
     raw_body = self.request.body.decode('utf-8')
     if len(raw_body) == 0:
         self.send_error(status_code=400, message="empty body")
         return
     lock = Lock.from_json(name, raw_body)
     if not (lock):
         self.send_error(status_code=400, message="invalid json body")
         return
     lock.set_callbacks(
         functools.partial(self.on_active_wrapper, name, lock),
         self.on_delete_wrapper)
     LOCK_MANAGER_INSTANCE.add_lock(name, lock)
 def post(self, name):
     '''
     @summary: deals with POST request (acquiring locks on resource)
     @param name: name of the resource
     '''
     raw_body = self.request.body.decode('utf-8')
     if len(raw_body) == 0:
         self.send_error(status_code=400, message="empty body")
         return
     lock = Lock.from_json(name, raw_body)
     if not (lock):
         self.send_error(status_code=400, message="invalid json body")
         return
     elif CONF_READER.VALIDATE_RESOURCE is True:
         if FILE_OPERATIONS.is_resource_valid(name) is False:
             self.send_error(
                 status_code=400,
                 message=
                 "invalid resource, add resource before requesting lock")
             return
     lock.set_callbacks(
         functools.partial(self.on_active_wrapper, name, lock),
         self.on_delete_wrapper)
     LOCK_MANAGER_INSTANCE.add_lock(name, lock)