Python Twisted库HTTP认证问题
我请你帮我找到以下代码的问题根源。 我使用页面 http://jcalderone.livejournal.com/53074.html 作为指南。 我的代码的唯一区别是资源不是从 .rpy 文件提供的。 此外,任何地方都没有 cache() 调用。
打开页面的结果为 https://serveraddr:serverport/services/admin 是 403 禁止。 它需要显示 UpdateManager.render_GET() 的输出。
在 server.tac 中:
...
root = resource.ForbiddenResource()
err = resource.ForbiddenResource()
root.putChild("service", err)
upd = UpdateXMLProcessor()
err.putChild("update2", upd)
portal = Portal(PublicHTMLRealm(), [FilePasswordDB('httpd.password')])
credentialFactory = DigestCredentialFactory("md5", "House of Life Updates")
admin = HTTPAuthSessionWrapper(portal, [credentialFactory])
err.putChild('admin', admin)
...
在 auth.py 中:
class PublicHTMLRealm(object):
implements(IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if IResource in interfaces:
resc = UpdateManager()
resc.realm = self
return (IResource, resc, lambda: None)
raise NotImplementedError()
在 admin.py 中:
class UpdateManager(resource.Resource):
isLeaf = False
pathFromRoot = '/service/admin'
def __init__(self):
resource.Resource.__init__(self)
self.newFull = NewFullResource()
self.putChild('new_full', self.newFull)
self.newDelta = NewDeltaResource()
self.putChild('new_delta', self.newDelta)
self.switch = SwitchResource()
self.putChild('switch', self.switch)
self.putChild('', self)
def render_GET(self, request):
...
这些代码部分有什么问题吗? 我在运行的控制台中没有显示错误
twistd -ny server.tac
I ask you to help me finding the source of problems with the following code.
I used page http://jcalderone.livejournal.com/53074.html as a guide.
The only difference of my code is that resource isn't served from .rpy file.
Also there is no cache() call anywhere.
The result of opening page at
https://serveraddr:serverport/services/admin is 403 Forbidden.
It needs to show the output from UpdateManager.render_GET().
In server.tac:
...
root = resource.ForbiddenResource()
err = resource.ForbiddenResource()
root.putChild("service", err)
upd = UpdateXMLProcessor()
err.putChild("update2", upd)
portal = Portal(PublicHTMLRealm(), [FilePasswordDB('httpd.password')])
credentialFactory = DigestCredentialFactory("md5", "House of Life Updates")
admin = HTTPAuthSessionWrapper(portal, [credentialFactory])
err.putChild('admin', admin)
...
In auth.py:
class PublicHTMLRealm(object):
implements(IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if IResource in interfaces:
resc = UpdateManager()
resc.realm = self
return (IResource, resc, lambda: None)
raise NotImplementedError()
in admin.py:
class UpdateManager(resource.Resource):
isLeaf = False
pathFromRoot = '/service/admin'
def __init__(self):
resource.Resource.__init__(self)
self.newFull = NewFullResource()
self.putChild('new_full', self.newFull)
self.newDelta = NewDeltaResource()
self.putChild('new_delta', self.newDelta)
self.switch = SwitchResource()
self.putChild('switch', self.switch)
self.putChild('', self)
def render_GET(self, request):
...
Is anything wrong here in these code parts?
I have no errors shown in the console running with
twistd -ny server.tac
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论