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

Pedro Sanchez psanchez at nortel.com
Thu Apr 28 09:00:53 MDT 2005


> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
> > xmlns:nevow="http://nevow.com/ns/nevow/0.1">
>         ^^^^^
> 
> >   <form n:render="loginForm" method="post">
>           ^
> 
> 	"n" != "nevow"
Thanks, that was the problem.

Please bear with me for a little while more. I have two more questions:

1) I don't understand what the third parameters(noLogout and
resc.logout) in these return statements do:

    def requestAvatar(self, avatarId, mind, *interfaces):
      ...
      return (inevow.IResource, resc, noLogout)
      ...
      return (inevow.IResource, resc, resc.logout)

   Can you give me a hint?

2) Now I'm trying to move the LoggedIn class into an external
"welcome.html" file. I get this error (files follow my signature):

exceptions.AttributeError: 'NoneType' object has no attribute 'load'

I get this error even without using any nevow tags in welcome.html.


Thank you for your time,

-- 
Pedro


This is my new LoggedIn class:

class LoggedIn(rend.Page):
    """The resource that is returned when you login"""
    addSlash = True
    docfactory = loaders.xmlfile("welcome.html")

    def render_welcome(self, ctx, data):
        return ctx.tag[ "Hello, %s!" % data]

    def render_logout(self, context, data):
        return ctx.tag(href=url.root.child(guard.LOGOUT_AVATAR))

    def logout(self):
        print "%s logged out!" % self.original


And this is welcome.html:

<html>
  <head>
    <title>Welcome!</title>
  </head>

  <body>

    <h1>nevow:render="welcome"</h1>

    <a nevow:render=logout">Logout</a>

  </body>
</html>





More information about the Twisted-web mailing list