/usr/share/pyshared/circuits/web/sessions.py is in python-circuits 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # Module: sessions
# Date: 22nd February 2009
# Author: James Mills, prologic at shortcircuit dot net dot au
"""Session Components
This module implements Session Components that can be used to store
and access persistent information.
"""
from uuid import uuid4 as uuid
from collections import defaultdict
from circuits import handler, Component
class Sessions(Component):
channel = "web"
def __init__(self, name="circuits.session", *args, **kwargs):
super(Sessions, self).__init__(*args, **kwargs)
self._name = name
self._data = defaultdict(dict)
def _load(self, id):
return self._data[id]
def _save(self, id, data):
self._data[id] = data
@handler("request", priority=10)
def request(self, request, response):
if self._name in request.cookie:
id = request.cookie[self._name].value
else:
id = str(uuid())
request.sid = id
request.session = self._load(id)
response.cookie[self._name] = id
|