def __request(self, url, params): """ Make an HTTP POST request to the server and return JSON data. :param url: HTTP URL to object. :returns: Response as dict. """ log.debug('request: %s %s' %(url, str(params))) try: response = urlopen(url, urlencode(params)).read() if params.get('action') != 'data': log.debug('response: %s' % response) if params.get('action', None) == 'data': return response else: return json.loads(response) except TypeError, e: log.exception('request error') raise ServerError(e)
def __call__(self, *args): log.exception(*args)