comparison roundup/rest.py @ 5575:7a7927643357 REST-rebased

Added OPTIONS method Fix a bug with class response header not allowing GET committer: Ralf Schlatterbeck <rsc@runtux.com>
author Chau Nguyen <dangchau1991@yahoo.com>
date Wed, 30 Jan 2019 10:26:34 +0100
parents 55f97de157e7
children 77d11a24f718
comparison
equal deleted inserted replaced
5574:55f97de157e7 5575:7a7927643357
222 raise Reject('Invalid request') 222 raise Reject('Invalid request')
223 223
224 def patch_element(self, class_name, item_id, input): 224 def patch_element(self, class_name, item_id, input):
225 raise NotImplementedError 225 raise NotImplementedError
226 226
227 def options_collection(self, class_name, input):
228 return 204, ""
229
230 def options_element(self, class_name, item_id, input):
231 self.client.setHeader("Accept-Patch",
232 "application/x-www-form-urlencoded, "
233 "multipart/form-data")
234 return 204, ""
235
227 def dispatch(self, method, uri, input): 236 def dispatch(self, method, uri, input):
228 # PATH is split to multiple pieces 237 # PATH is split to multiple pieces
229 # 0 - rest 238 # 0 - rest
230 # 1 - resource 239 # 1 - resource
231 # 2 - attribute 240 # 2 - attribute
251 260
252 output = None 261 output = None
253 try: 262 try:
254 if resource_uri in self.db.classes: 263 if resource_uri in self.db.classes:
255 self.client.setHeader("Allow", 264 self.client.setHeader("Allow",
256 "HEAD, OPTIONS, POST, DELETE") 265 "HEAD, OPTIONS, GET, POST, DELETE")
257 self.client.setHeader("Access-Control-Allow-Methods", 266 self.client.setHeader("Access-Control-Allow-Methods",
258 "HEAD, OPTIONS, POST, DELETE") 267 "HEAD, OPTIONS, GET, POST, DELETE")
259 response_code, output = getattr(self, "%s_collection" % method.lower())( 268 response_code, output = getattr(self, "%s_collection" % method.lower())(
260 resource_uri, input) 269 resource_uri, input)
261 else: 270 else:
262 class_name, item_id = hyperdb.splitDesignator(resource_uri) 271 class_name, item_id = hyperdb.splitDesignator(resource_uri)
263 self.client.setHeader("Allow", 272 self.client.setHeader("Allow",

Roundup Issue Tracker: http://roundup-tracker.org/