@@ -98,6 +98,7 @@ def action_put(self, resource_uri, input):
9898 def action_delete (self , resource_uri , input ):
9999 # TODO: should I allow user to delete the whole collection ?
100100 # TODO: BUG with DELETE without form data. Working with random data
101+ # crash at line self.form = cgi.FieldStorage(fp=request.rfile, environ=env)
101102 class_name = resource_uri
102103 try :
103104 class_obj = self .db .getclass (class_name )
@@ -136,24 +137,14 @@ def dispatch(self, method, uri, input):
136137 input_form = ["%s=%s" % (item .name , item .value ) for item in input ]
137138 # TODO: process input_form directly instead of making a new array
138139 # TODO: rest server
139- # TODO: use named function for this instead
140140 # TODO: check roundup/actions.py
141141 # TODO: if uri_path has more than 2 child, return 404
142142 # TODO: custom JSONEncoder to handle other data type
143143 # TODO: catch all error and display error.
144- output = "METHOD is not supported"
145- if method == "GET" :
146- output = self .action_get (uri_path [1 ], input_form )
147- elif method == "POST" :
148- output = self .action_post (uri_path [1 ], input_form )
149- elif method == "PUT" :
150- output = self .action_put (uri_path [1 ], input_form )
151- elif method == "DELETE" :
152- output = self .action_delete (uri_path [1 ], input_form )
153- elif method == "PATCH" :
154- output = self .action_patch (uri_path [1 ], input_form )
155- else :
156- pass
144+ try :
145+ output = getattr (self , "action_%s" % method .lower ())(uri_path [1 ], input_form )
146+ except AttributeError :
147+ raise NotImplementedError
157148
158149 print "Response Length: %s - Response Content (First 50 char): %s" % \
159150 (len (output ), output [:50 ])
0 commit comments