Show More
@@ -30,6 +30,7 b' import json' | |||
|
30 | 30 | import logging |
|
31 | 31 | import types |
|
32 | 32 | import urllib |
|
33 | from itertools import izip_longest | |
|
33 | 34 | |
|
34 | 35 | from paste.response import replace_header |
|
35 | 36 | |
@@ -132,7 +133,12 b' class JSONRPCController(WSGIController):' | |||
|
132 | 133 | |
|
133 | 134 | # now that we have a method, add self._req_params to |
|
134 | 135 | # self.kargs and dispatch control to WGIController |
|
135 |
arg |
|
|
136 | argspec = inspect.getargspec(self._func) | |
|
137 | arglist = argspec[0][1:] | |
|
138 | defaults = argspec[3] | |
|
139 | default_empty = types.NotImplementedType | |
|
140 | kwarglist = list(izip_longest(reversed(arglist),reversed(defaults), | |
|
141 | fillvalue=default_empty)) | |
|
136 | 142 | |
|
137 | 143 | # this is little trick to inject logged in user for |
|
138 | 144 | # perms decorators to work they expect the controller class to have |
@@ -149,14 +155,18 b' class JSONRPCController(WSGIController):' | |||
|
149 | 155 | (self._func.__name__, USER_SESSION_ATTR)) |
|
150 | 156 | |
|
151 | 157 | # get our arglist and check if we provided them as args |
|
152 | for arg in arglist: | |
|
158 | for arg,default in kwarglist: | |
|
153 | 159 | if arg == USER_SESSION_ATTR: |
|
154 | 160 | # USER_SESSION_ATTR is something translated from api key and |
|
155 | 161 | # this is checked before so we don't need validate it |
|
156 | 162 | continue |
|
157 | 163 | |
|
158 | if not self._req_params or arg not in self._req_params: | |
|
159 | return jsonrpc_error(message='Missing %s arg in JSON DATA' % arg) | |
|
164 | # skip the required param check if it's default value is | |
|
165 | # NotImplementedType (default_empty) | |
|
166 | if not self._req_params or (type(default) == default_empty | |
|
167 | and arg not in self._req_params): | |
|
168 | return jsonrpc_error(message=('Missing non optional %s arg ' | |
|
169 | 'in JSON DATA') % arg) | |
|
160 | 170 | |
|
161 | 171 | self._rpc_args = {USER_SESSION_ATTR:u} |
|
162 | 172 | self._rpc_args.update(self._req_params) |
General Comments 0
You need to be logged in to leave comments.
Login now