-2

「disqus_dumpdata」コマンドの発行時に 400 エラーを受け取りました (リンク)。Google と github を検索しましたが、この問題を経験したのは私だけのようです。

以下は私のトレースバックです。「disqus_dumpdata.py」の「32行目」と私の短縮名またはAPIキーになると思っていましたが、そうではありません:

(pinax073)[user@web142 mysite]$ python2.6 manage.py disqus_dumpdata --traceback
Traceback (most recent call last):
  File "manage.py", line 28, in <module>
    execute_from_command_line()
  File "/home/user/webapps/whw/lib/python2.6/django/core/management/__init__.py", line 429, in execute_from_command_line
    utility.execute()
  File "/home/user/webapps/whw/lib/python2.6/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/webapps/whw/lib/python2.6/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/user/webapps/whw/lib/python2.6/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/management/commands/disqus_dumpdata.py", line 32, in handle
    forum_list = client.get_forum_list(user_api_key=settings.DISQUS_API_KEY)
  File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/api.py", line 53, in call_method
    return self.call(attr, **kwargs)
  File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/api.py", line 79, in call
    response = urllib2.urlopen(request)
  File "/usr/local/lib/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/local/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: BAD REQUEST

400: ('Bad Request', 'Bad request syntax or unsupported method')

私の api.py ファイルの 77,78,79 行を見ると、すべて問題ないように見えます。何が原因でしょうか?

request = self._get_request(url, self.METHODS[method], **params)
        try:
            response = urllib2.urlopen(request)
4

1 に答える 1

0

発生しているエラーを実際に読むことをお勧めします。その行の周りに try/except を追加します。

try:
    response = urllib2.urlopen(url)
except urllib2.HTTPError, error:
    contents = error.read()
    logging.debug(contents)
    raise 
于 2011-05-04T16:42:07.630 に答える