def _json_from_post(request, *args, **kwargs): """Return the json content of the given request. The json must be in the request's POST data.""" rawjson = request.raw_post_data if kwargs.pop('allow_empty', False) and not rawjson: return None return jsonutil.loads(rawjson, *args, **kwargs)
def test_datetime(self): expected_date = datetime.datetime(year= 2010,month=12, day=5) ts = time.mktime(expected_date.timetuple()) dct = {'__type__': 'datetime.datetime', 'timestamp': ts} s = json.dumps(dct) o = jsonutil.loads(s) self.assertEquals(o, expected_date)
def run(self, rawjson): jsondata = jsonutil.loads(rawjson) dispatchid = uuid.UUID(self.request.id).hex taskname = jsondata['name'] args = jsondata.get('args', []) kwargs = jsondata.get('kwargs', {}) options = jsondata.get('options', {}) rate = jsondata['rate'] runfor = jsondata['runfor'] demo_dispatch(taskname, dispatchid, runfor, rate, options, args, kwargs)