I have integrated the new simplified session module re-implemented by
Devi. The earlier implementation wasn't as simple as it should be, so
it needed an overhaul.
Here is a complete web.py application using sessions to implement a counter.
import web
urls = (
"/count", "count",
"/reset", "reset"
)
app = web.application(urls, locals())
session = web.session.Session(app,
web.session.DiskStore('sessions'), initializer={'count': 0})
class count:
def GET(self):
session.count += 1
return str(session.count)
class reset:
def GET(self):
session.kill()
return ""
if __name__ == "__main__":
app.run()
Session is loaded/created before handling the request and saved after
handling the request, if modified.
There are 2 implementations of stores provided, DiskStore and DBStore.
The optional initializer argument can be used to specify the initial
session data.
In case you want to tweak the default behavior, change
web.config.session_parameters.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---