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<div>Here is the core code:</div><div><br></div><div><div> passwords = {"admin":"password"}</div>
<div> users = {"admin":"Administrator"}</div><div> </div><div> realm = TestRealm(users)</div><div> </div><div> p = portal.Portal(TestRealm(users),(PasswordDictChecker(passwords),))</div>
<div> credentialFactory = BasicCredentialFactory("CorePost")</div><div> resource = HTTPAuthSessionWrapper(portal, [credentialFactory])</div><div> </div><div> print "Running..."</div><div> </div>
<div> factory = Site(resource)</div><div> reactor.listenTCP(8084, factory) </div><div> reactor.run() </div></div><div><br></div><div>Error:</div><div><br></div><div><div>Unhandled Error</div><div>Traceback (most recent call last):</div>
<div> 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</div><div> why = self.lineReceived(line)</div><div> 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</div>
<div> self.allContentReceived()</div><div> 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</div><div> req.requestReceived(command, path, version)</div>
<div> 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</div><div> self.process()</div><div>--- <exception caught here> ---</div>
<div> 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</div><div> resrc = self.site.getResourceFor(self)</div><div> 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</div>
<div> return resource.getChildForRequest(self.resource, request)</div><div> 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</div>
<div> resource = resource.getChildWithDefault(pathElement, request)</div><div> 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</div>
<div> return self._authorizedResource(request)</div><div> 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</div>
<div> return util.DeferredResource(self._login(Anonymous()))</div><div> 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</div>
<div> d = self._portal.login(credentials, None, IResource)</div><div><b>exceptions.AttributeError: 'module' object has no attribute 'login'</b></div></div><div><b><br></b></div><div>Attached the full file.</div>
<div><br></div><div>Not sure I understand what I am doing right here. The app starts up fine, but throws the error on any request.</div><div>Also, how do I hook up actual Resources?</div><div>Do I do it do the HttpAuthSessionWrapper? It is an IResources, but complains that it does not have a putChild() on it?</div>
<div>Should my TestRealm extend a Resource and I add my child Resource there?</div><div><br></div><div>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... :-(</div>
<div><br></div><div>Jacek</div>