On Mon, Aug 17, 2009 at 11:45 AM, Reza Lotun <rlotun@gmail.com> wrote:
The short answer is that you need to use twisted.cred.

You don't need to do that at all, it just happens to be the best way.
 
  wrapper = guard.HTTPAuthSessionWrapper(
                   Portal(SimpleRealm(), checkers),
                   [guard.BasicCredentialFactory('yoursite.com')])
 

Where is Portal and SimpleRealm in your example? Those are actually quite large constructs which are crucial to guard doing anything useful at all.

Since there are numerous circumstances that people need Htauth, it is implemented as follows

from twisted.web import http
# and other stuff...

class HTTPAuthPage(rend.Page):
    def renderHTTP(self, ctx):
        request = inevow.IRequest(ctx)
        username, password = request.getUser(), request.getPassword()

        if [My auth details check out]:
            return rend.Page.renderHTTP(self, ctx)

        else:
            request.setHeader('WWW-Authenticate', 'Basic realm="My realm name"')
            request.setResponseCode(http.UNAUTHORIZED)
            return "Authentication required."