Revision 94195dd0 api/util.py
b/api/util.py | ||
---|---|---|
22 | 22 |
import dateutil.parser |
23 | 23 |
import logging |
24 | 24 |
|
25 |
def binary_search_name(a, x, lo = 0, hi = None): |
|
26 |
if hi is None: |
|
27 |
hi = len(a) |
|
28 |
while lo < hi: |
|
29 |
mid = (lo + hi) // 2 |
|
30 |
midval = a[mid]['name'] |
|
31 |
if midval < x: |
|
32 |
lo = mid + 1 |
|
33 |
elif midval > x: |
|
34 |
hi = mid |
|
35 |
else: |
|
36 |
return mid |
|
37 |
raise ValueError() |
|
38 |
|
|
39 | 25 |
# class UTC(tzinfo): |
40 | 26 |
# def utcoffset(self, dt): |
41 | 27 |
# return timedelta(0) |
... | ... | |
173 | 159 |
# data = json.dumps(d) |
174 | 160 |
|
175 | 161 |
# resp = HttpResponse(data, status=fault.code) |
176 |
resp = HttpResponse(status=fault.code)
|
|
162 |
resp = HttpResponse(status = fault.code)
|
|
177 | 163 |
update_response_headers(request, resp) |
178 | 164 |
return resp |
179 | 165 |
|
... | ... | |
209 | 195 |
def wrapper(request, *args, **kwargs): |
210 | 196 |
try: |
211 | 197 |
request.serialization = request_serialization(request, format_allowed) |
198 |
# TODO: Authenticate. |
|
199 |
# TODO: Return 401/404 when the account is not found. |
|
200 |
request.user = "test" |
|
201 |
# TODO: Check parameter sizes. |
|
212 | 202 |
if http_method and request.method != http_method: |
213 | 203 |
raise BadRequest('Method not allowed.') |
214 | 204 |
|
Also available in: Unified diff