2

我是新手。我在官方网站上看到了代码片段(粘贴在下面)。问题是如何将其部署到服务器?我在哪里设置用户名和密码凭据?在 Apache 的 httpd.conf 文件中?


from django.conf.urls.defaults import *
from piston.resource import Resource
from piston.authentication import HttpBasicAuthentication

from myapp.handlers import BlogPostHandler, ArbitraryDataHandler

auth = HttpBasicAuthentication(realm="My Realm")
ad = { 'authentication': auth }

blogpost_resource = Resource(handler=BlogPostHandler, **ad)
arbitrary_resource = Resource(handler=ArbitraryDataHandler, **ad)

urlpatterns += patterns('',
    url(r'^posts/(?P<post_slug>[^/]+)/$', blogpost_resource), 
    url(r'^other/(?P<username>[^/]+)/(?P<data>.+)/$', arbitrary_resource), 
)
4

1 回答 1

3

By default piston.authenticate.HttpBasicAuthentication uses django.contrib.auth.authenticate to check credentials.

In other words: you "set username and password credentials" simply by creating normal Django Users.

于 2010-07-21T09:43:30.890 回答