from SecurePage import SecurePage class SecureCountVisits(SecurePage): """Secured version of counting visits example.""" def writeContent(self): count = self.session().value('secure_count', 0) + 1 self.session().setValue('secure_count', count) plural = count > 1 and 's' or '' self.writeln('
Your session has expired.
') self.writeln("You've been here" ' %d ' ' time%s.
' % (count, plural)) self.writeln('This page records your visits using a session object.' ' Every time you reload or' ' revisit this page, the counter will increase.' ' If you close your browser, then your session will end and you' ' will see the counter go back to 1 on your next visit.
') self.writeln('Try hitting ' 'reload now.
') user = self.loggedInUser() if user: self.writeln('Authenticated user is %s.
' % user) self.writeln('Revisit this page | ' 'Logout
')