[Twisted-web] guarded example using external login form file

Matt Goodall matt at pollenation.net
Wed Apr 27 13:33:43 MDT 2005

Pedro Sanchez wrote:

> Hello,
> I'm learning nevow and I would appreciate some help modifying this
> example:
> http://nevowexamples.adytum.us/sources/guarded.py
> This "logs in" a user validating it with a username and password.
> The form used to accept user input is embedded in the code using
> the stan tags in the NotLoggedIn() class. What I want is to have
> the login form in an external xhtml file (login.html), like the one
> that follows my signature. My new NotLoggedIn() class simply looks
> like this:
> class NotLoggedIn(rend.Page): """The resource that is returned when
> you are not logged in""" addSlash = True docFactory =
> loaders.xmlfile("login.html")
> I believe the only thing that has to change in the xhtml file
> (other than the nevow xml space declaration) is on the first line,
> the "action" thing (guard.LOGIN_AVATAR in guarded.py). But I can't
> figure out what nevow tag to use there.
> Can you suggest how to do it?

There is no tag specifically for this. Instead, add a render directive
to the <form> element in the HTML template and set the form action in
the render_ method ...

<form n:render="loginForm">

def render_loginForm(self, ctx, data):
    return ctx.tag(action=url.root.child(guard.LOGIN_AVATAR))

- Matt

    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \           Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.

More information about the Twisted-web mailing list