summaryrefslogtreecommitdiff
path: root/paste/session.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2006-04-24 17:10:50 +0000
committerianb <devnull@localhost>2006-04-24 17:10:50 +0000
commitbf27b42f00f8303ab2cbd0cacd5347e09f13dad0 (patch)
treec3417d8ea5f3aa7f57402f42f2d4e2935bb04e5e /paste/session.py
parente0ca65bd6beb4935a70331a6b24b79d9f4005966 (diff)
downloadpaste-bf27b42f00f8303ab2cbd0cacd5347e09f13dad0.tar.gz
Added a chmod option to paste.session
Diffstat (limited to 'paste/session.py')
-rw-r--r--paste/session.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/paste/session.py b/paste/session.py
index e9d100e..a15b2c6 100644
--- a/paste/session.py
+++ b/paste/session.py
@@ -136,7 +136,11 @@ class SessionFactory(object):
class FileSession(object):
- def __init__(self, sid, create=False, session_file_path='/tmp'):
+ def __init__(self, sid, create=False, session_file_path='/tmp',
+ chmod=None):
+ if isinstance(chmod, basestring):
+ chmod = oct(chmod)
+ self.chmod = chmod
if not sid:
# Invalid...
raise KeyError
@@ -164,10 +168,13 @@ class FileSession(object):
def close(self):
if self._data is not None:
filename = self.filename()
+ exists = os.path.exists(filename)
if not self._data:
- if os.path.exists(filename):
+ if exists:
os.unlink(filename)
else:
- f = open(self.filename(), 'wb')
+ f = open(filename, 'wb')
cPickle.dump(self._data, f)
f.close()
+ if not exists and self.chmod:
+ os.chmod(self.chmod, filename)