2011-04-13 64 views
1

我的活塞應用程序工作正常,當我使用python manage.py runserver命令命令在本地運行,但在Apache返回如何調試django-piston應用程序?

urllib2.HTTPError: HTTP Error 403: FORBIDDEN

。我如何調試django-piston應用程序?

+0

更新活塞到最新版本解決了這個問題,但它仍然不清楚如何調試活塞應用程序。 – Tom 2011-04-14 09:41:01

回答

0

我通常調試活塞應用:

  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) 

要通過使用捲曲的用戶名和密碼,使用-u選項:

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

因此,在您的本地設置模塊,只要您想使用基本身份驗證,只需設置API_DEBUG=True即可。