Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 839 Bytes
layout title
default
Very simple session example

Very simple session example

put this in code.py and run python code.py

import web

web.config.db_parameters = {
                            'dbn' : 'postgres',
                            'host' : 'localhost',
                            'user' : 'web',
                            'pw' : 'web',
                            'db' : 'web'
                    }

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        s = web.ctx.session
        s.start()

        try:
            s.click += 1
        except AttributeError:
            s.click = 1

        print 'click: ', s.click
        s.save()

if __name__ == '__main__':
    web.run(urls, globals(), web.reloader)
Jump to Line
Something went wrong with that request. Please try again.