1234567891011121314151617181920212223242526272829 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- import json
- from collections import namedtuple
- from django.http import HttpResponse
- from apilib.systypes import StrEnum
- from apilib.utils_json import DescriptiveJSONEncoder
- class OfflineTaskType(StrEnum):
- AD_REPORT = u'广告报表'
- class MyJsonOkResponse(HttpResponse):
- def __init__(self, data, safe = True, ordered = False, **kwargs):
- if safe and not isinstance(data, dict):
- raise TypeError('In order to allow non-dict objects to be '
- 'serialized set the safe parameter to False')
- kwargs.setdefault('content_type', 'application/json')
- content = json.dumps(data, sort_keys = ordered, cls = DescriptiveJSONEncoder, ensure_ascii = False)
- super(MyJsonOkResponse, self).__init__(content = content, **kwargs)
- def json(self):
- return json.loads(self.content, encoding = 'utf-8')
- AdUser = namedtuple('AdUser', ['openId', 'feature_keys', 'feature_map'])
|