def format(self, request): from quixote import get_session_manager get_session_manager().revoke_session_cookie(request) msg = PublishError.format(self, request) if self.session_id: msg = msg + ": " + self.session_id return msg
def logout(self): if get_user(): content = htmltext('<p>Goodbye, %s.</p>') % get_user() else: content = htmltext('<p>That would be redundant.</p>') content += href("..", "start over") get_session_manager().expire_session() # This is the important part. return format_page("Quixote Session Demo: Logout", content)
def _q_index(request): user = request.user if request.method == 'POST': if user: continue_url = request.get_form_var( 'continue', '') or request.get_form_var('Referer', '') get_session_manager().expire_session(request) return request.redirect(continue_url or '/') context = {} context['current_user'] = user return st('logout.html', **context)
def _q_index(self): content = htmltext('') if not get_user(): content += htmltext('<p>%s</p>' % href('login', 'login')) else: content += htmltext('<p>Hello, %s.</p>') % get_user() content += htmltext('<p>%s</p>' % href('logout', 'logout')) sessions = sorted([(s.id, s) for s in get_session_manager()]) if sessions: content += htmltext('<table><tr>' '<th></th>' '<th>Session</th>' '<th>User</th>' '<th>Number of Requests</th>' '</tr>') this_session = get_session() for index, (id, session) in enumerate(sessions): if session is this_session: formatted_id = htmltext( '<span style="font-weight:bold">%s</span>' % id) else: formatted_id = id content += htmltext( '<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td>' % (index, formatted_id, session.user or htmltext("<em>None</em>"), session.num_requests)) content += htmltext('</table>') return format_page("Quixote Session Management Demo", content)
def logout(self): # expire session session_manager = get_session_manager() session_manager.expire_session() # redirect to index page. return redirect(get_path(1) + '/')
def _q_index(self): content = htmltext('') if not get_user(): content += htmltext('<p>%s</p>' % href('login', 'login')) else: content += htmltext( '<p>Hello, %s.</p>') % get_user() content += htmltext('<p>%s</p>' % href('logout', 'logout')) sessions = get_session_manager().items() if sessions: sessions.sort() content += htmltext('<table><tr>' '<th></th>' '<th>Session</th>' '<th>User</th>' '<th>Number of Requests</th>' '</tr>') this_session = get_session() for index, (id, session) in enumerate(sessions): if session is this_session: formatted_id = htmltext( '<span style="font-weight:bold">%s</span>' % id) else: formatted_id = id content += htmltext( '<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td>' % ( index, formatted_id, session.user or htmltext("<em>None</em>"), session.num_requests)) content += htmltext('</table>') return format_page("Quixote Session Management Demo", content)
def logoutfail(self): """ Expire the session, raise PublishException. Effect: no log out. """ session_manager = get_session_manager() session_manager.expire_session() raise Exception("oops.")
def logout(self): """ Expire the session, redirect back to index page. """ # expire session session_manager = get_session_manager() session_manager.expire_session() # redirect to index page. return redirect(get_path(1) + '/')
def logout(self): get_response().expire_cookie('user',path='/') get_session_manager().expire_session() body = Template.Kind_Body % (Template.Kind_Top,"Has logout!","") html = Template.HTML % ("Logout",body) return html