fixed problem with session __hash
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.1.1 (2012-10-15 19:39:19) dev
|
Version 2.1.1 (2012-10-15 20:43:47) dev
|
||||||
|
|||||||
+13
-5
@@ -608,7 +608,8 @@ class Session(Storage):
|
|||||||
rcookies = response.cookies
|
rcookies = response.cookies
|
||||||
rcookies[response.session_id_name] = response.session_id
|
rcookies[response.session_id_name] = response.session_id
|
||||||
rcookies[response.session_id_name]['path'] = '/'
|
rcookies[response.session_id_name]['path'] = '/'
|
||||||
self.__hash = hashlib.md5(str(self)).digest()
|
pickle = cPickle.dumps(self)
|
||||||
|
self.__hash = hashlib.md5(pickle).digest()
|
||||||
if self.flash:
|
if self.flash:
|
||||||
(response.flash, self.flash) = (self.flash, None)
|
(response.flash, self.flash) = (self.flash, None)
|
||||||
|
|
||||||
@@ -653,16 +654,20 @@ class Session(Storage):
|
|||||||
|
|
||||||
# don't save if no change to session
|
# don't save if no change to session
|
||||||
__hash = self.__hash
|
__hash = self.__hash
|
||||||
|
pickle = None
|
||||||
if __hash is not None:
|
if __hash is not None:
|
||||||
del self.__hash
|
del self.__hash
|
||||||
if __hash == hashlib.md5(str(self)).digest():
|
pickle = cPickle.dumps(self)
|
||||||
|
if __hash == hashlib.md5(pickle).digest():
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
pickle = cPickle.dumps(self)
|
||||||
|
|
||||||
(record_id_name, table, record_id, unique_key) = \
|
(record_id_name, table, record_id, unique_key) = \
|
||||||
response._dbtable_and_field
|
response._dbtable_and_field
|
||||||
dd = dict(locked=False, client_ip=request.client.replace(':','.'),
|
dd = dict(locked=False, client_ip=request.client.replace(':','.'),
|
||||||
modified_datetime=request.now,
|
modified_datetime=request.now,
|
||||||
session_data=cPickle.dumps(dict(self)),
|
session_data=pickle,
|
||||||
unique_key=unique_key)
|
unique_key=unique_key)
|
||||||
if record_id:
|
if record_id:
|
||||||
table._db(table.id == record_id).update(**dd)
|
table._db(table.id == record_id).update(**dd)
|
||||||
@@ -680,9 +685,11 @@ class Session(Storage):
|
|||||||
|
|
||||||
# don't save if no change to session
|
# don't save if no change to session
|
||||||
__hash = self.__hash
|
__hash = self.__hash
|
||||||
|
pickle = None
|
||||||
if __hash is not None:
|
if __hash is not None:
|
||||||
del self.__hash
|
del self.__hash
|
||||||
if __hash == hashlib.md5(str(self)).digest():
|
pickle = cPickle.dumps(self)
|
||||||
|
if __hash == hashlib.md5(pickle).digest():
|
||||||
self._close(response)
|
self._close(response)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -700,7 +707,8 @@ class Session(Storage):
|
|||||||
response.session_locked = True
|
response.session_locked = True
|
||||||
|
|
||||||
if response.session_file:
|
if response.session_file:
|
||||||
cPickle.dump(dict(self), response.session_file)
|
if not pickle: pickle = cPickle.dumps(self)
|
||||||
|
response.session_file.write(pickle)
|
||||||
response.session_file.truncate()
|
response.session_file.truncate()
|
||||||
self._close(response)
|
self._close(response)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user