from ExamplePage import ExamplePage from MiscUtils.Funcs import uniqueId class LoginPage(ExamplePage): """A log-in screen for the example pages.""" def title(self): return 'Log In' def htBodyArgs(self): return ExamplePage.htBodyArgs(self) + \ ' onload="document.loginform.username.focus();"' % locals() def writeContent(self): self.writeln('
') request = self.request() extra = request.field('extra', None) if not extra and request.isSessionExpired() and not request.hasField('logout'): extra = 'You have been automatically logged out due to inactivity.' if extra: self.writeln('
%s
' % self.htmlEncode(extra)) if self.session().hasValue('loginid'): loginid = self.session().value('loginid') else: # Create a "unique" login id and put it in the form as well as in the session. # Login will only be allowed if they match. loginid = uniqueId(self) self.session().setValue('loginid', loginid) action = request.field('action', '') if action: action = ' action="%s"' % action self.writeln('''Please log in to view the example. The username and password is alice or bob.
\n