示例#1
0
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)]
示例#2
0
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")]
示例#3
0
    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
示例#4
0
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')]
示例#5
0
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')]
示例#6
0
文件: server.py 项目: ThomRosario/as
    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()    
示例#7
0
 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]
示例#8
0
 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")]