1

私のピストン アプリケーションは、python manage.py runserver コマンドを使用してローカルで実行すると正しく動作しますが、返されます。

urllib2.HTTPError: HTTP エラー 403: 禁止されています

アパッチの下。django-piston アプリケーションをデバッグするにはどうすればよいですか?

4

1 に答える 1

0

私は通常、次の方法で Piston アプリをデバッグします。

  1. 通常は別のものを使用している場合でも、基本認証を使用するようにハンドラーを設定します。
  2. curlを使用してリクエストを行う
  3. 必要に応じてpdb (またはipdb ) を使用して、ハンドラーにブレークポイントを設定します。

次のように、条件付きで BasicAuthentication に変更できます。

auth = {'authentication': WhateverYouAreUsingForAuthentication(realm="YourSite")}

if getattr(settings, "API_DEBUG", None):
    from piston.authentication import HttpBasicAuthentication
    auth = {'authentication': HttpBasicAuthentication(realm="Spling")}

some_handler = Resource(SomeHandler, **auth)

curl を使用してユーザー名とパスワードを渡すには、次の-uオプションを使用します。

curl -u username:password http://localhost:8000/api/some/endpoint/

したがって、ローカル設定モジュールで、API_DEBUG=True基本認証を使用するたびに設定するだけです。

于 2011-09-30T20:13:04.823 に答える