(self, callback, context)
| 1442 | self.json_dumps = json_dumps |
| 1443 | |
| 1444 | def apply(self, callback, context): |
| 1445 | dumps = self.json_dumps |
| 1446 | if not dumps: return callback |
| 1447 | def wrapper(*a, **ka): |
| 1448 | rv = callback(*a, **ka) |
| 1449 | if isinstance(rv, dict): |
| 1450 | #Attempt to serialize, raises exception on failure |
| 1451 | json_response = dumps(rv) |
| 1452 | #Set content type only if serialization succesful |
| 1453 | response.content_type = 'application/json' |
| 1454 | return json_response |
| 1455 | return rv |
| 1456 | return wrapper |
| 1457 | |
| 1458 | |
| 1459 | class HooksPlugin(object): |
no outgoing calls
no test coverage detected