I am trying to understand how it works in the context of twisted.web and Resources, but I always get an exception on the portal object
passwords = {"admin":"password"}
users = {"admin":"Administrator"}
realm = TestRealm(users)
p = portal.Portal(TestRealm(users),(PasswordDictChecker(passwords),))
credentialFactory = BasicCredentialFactory("CorePost")
resource = HTTPAuthSessionWrapper(portal, [credentialFactory])
print "Running..."
factory = Site(resource)
reactor.listenTCP(8084, factory)
reactor.run()
Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/protocols/basic.py", line 564, in dataReceived
why = self.lineReceived(line)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/http.py", line 1551, in lineReceived
self.allContentReceived()
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/http.py", line 1618, in allContentReceived
req.requestReceived(command, path, version)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/http.py", line 773, in requestReceived
self.process()
--- <exception caught here> ---
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/server.py", line 131, in process
resrc = self.site.getResourceFor(self)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/server.py", line 562, in getResourceFor
return resource.getChildForRequest(self.resource, request)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/resource.py", line 65, in getChildForRequest
resource = resource.getChildWithDefault(pathElement, request)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/_auth/wrapper.py", line 142, in getChildWithDefault
return self._authorizedResource(request)
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/_auth/wrapper.py", line 106, in _authorizedResource
return util.DeferredResource(self._login(Anonymous()))
File "/usr/local/lib/python2.7/dist-packages/Twisted-12.0.0-py2.7-linux-x86_64.egg/twisted/web/_auth/wrapper.py", line 152, in _login
d = self._portal.login(credentials, None, IResource)
exceptions.AttributeError: 'module' object has no attribute 'login'
Attached the full file.
Not sure I understand what I am doing right here. The app starts up fine, but throws the error on any request.
Do I do it do the HttpAuthSessionWrapper? It is an IResources, but complains that it does not have a putChild() on it?
Sorry for all the questions, but the docs don't really cover the A-Z scenario of getting a running twisted.web app with Http auth... :-(