[Twisted-web] questions about guard

Federico Tomassini federicotom at yahoo.it
Thu Apr 3 12:22:53 EDT 2008

Hi alls,

i'm working on guard, having the following questions.
Questions are not specific to my problem. My hope is to understand some
guard behaviour.

1- suppose that, after the auth, the root resource R is associated to
the session. Suppose also that a child for the address /foo is defined.
Suppose I want to perform a logout when /foo/bar is requested.

How can I do it in PageFoo.locateChild() (without the need to redirect
to LOGOUT_AVATAR), returning a PageBar from there?
I mean something like that:

 class PageFoo(rend.Page):
  def locateChild(self, ctx, segs):
   if segs[0] == 'bar':
      page_bar= static.File(somefile) # it's just an example
      return page_bar, ()

2- Which is the best way to implement a realm so that:

  - if you POST to /__login__ an auth is performed and a root resource
    is assigned to the session
  - if you GET /baz the url is processed and, depending on it, a page
    is returned

   Maybe it's sufficient to handle the Anonymous login, adapting it to
   the second need (for anonymous, I associate a root resource which
   will handle the /baz request)?

thanks in advance

Today is Pungenday, the 20th day of Discord in the YOLD 3174

More information about the Twisted-web mailing list