def simple_app(environ, start_response): session = environ['beaker.session'] if not session.has_key('value'): session['value'] = 0 session['value'] += 1 if not environ['PATH_INFO'].startswith('/nosave'): session.save() start_response('200 OK', [('Content-type', 'text/plain')]) return ['The current value is: %d and cookie is %s' % (session['value'], session)]
def simple_app(environ, start_response): session = environ["beaker.session"] if not session.has_key("value"): session["value"] = 0 session["value"] += 1 if not environ["PATH_INFO"].startswith("/nosave"): session.save() start_response("200 OK", [("Content-type", "text/plain")]) msg = "The current value is: %d and cookie is %s" % (session["value"], session) return [msg.encode("UTF-8")]
def _set_flash_messages(self, messages): # Try to store them in the session (if it exists). session = self.local_request().session if session is not None: if not messages: session.pop('_flash_messages', None) else: session['_flash_messages'] = messages session.save() # log.info('set flash messages %r into session' % messages) else: self._local.__dict__['flash_messages'] = messages
def simple_app(environ, start_response): session = environ['beaker.session'] if not session.has_key('value'): session['value'] = 0 session['value'] += 1 domain = environ.get('domain') if domain: session.domain = domain if not environ['PATH_INFO'].startswith('/nosave'): session.save() start_response('200 OK', [('Content-type', 'text/plain')]) msg = 'The current value is: %d and cookie is %s' % (session['value'], session) return [msg.encode('utf-8')]
def POST(self): session = web.ctx.environ['beaker.session'] i = web.input() if 'done' in i or 'open' in i: session['todos'] = [] for ctxName in ['done', 'open']: if i[ctxName]: newTodos = parser.makeTodos(i[ctxName].split('\n')) session['todos'].extend((newTodos)) if i['report']: session['report'] = parser.parseReport(i['report'].split('\n')) session.save() self.GET()
def invalidate_session_app(environ, start_response): session = environ['beaker.session'] session.invalidate() session.save() start_response('200 OK', [('Content-type', 'text/plain')]) return ['Cookie is %s' % session]
def invalidate_session_app(environ, start_response): session = environ["beaker.session"] session.invalidate() session.save() start_response("200 OK", [("Content-type", "text/plain")]) return [("Cookie is %s" % session).encode("UTF-8")]