monkey_patched_pickle
This commit is contained in:
committed by
Michele Comitini
parent
dafbc17826
commit
aebb331fe7
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.08.27.06.33.47
|
Version 2.6.0-development+timestamp.2013.08.27.15.54.04
|
||||||
|
|||||||
+3
-1
@@ -23,11 +23,13 @@ from http import HTTP, redirect
|
|||||||
from fileutils import up
|
from fileutils import up
|
||||||
from serializers import json, custom_json
|
from serializers import json, custom_json
|
||||||
import settings
|
import settings
|
||||||
|
import monkey_patch_pickle
|
||||||
from utils import web2py_uuid, secure_dumps, secure_loads
|
from utils import web2py_uuid, secure_dumps, secure_loads
|
||||||
from settings import global_settings
|
from settings import global_settings
|
||||||
import hashlib
|
import hashlib
|
||||||
import portalocker
|
import portalocker
|
||||||
import cPickle
|
import cPickle
|
||||||
|
import pickle
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
@@ -977,7 +979,7 @@ class Session(Storage):
|
|||||||
if not previous_session_hash and not \
|
if not previous_session_hash and not \
|
||||||
any(value is not None for value in self.itervalues()):
|
any(value is not None for value in self.itervalues()):
|
||||||
return True
|
return True
|
||||||
session_pickled = cPickle.dumps(dict(self))
|
session_pickled = pickle.dumps(dict(self)) # requires monkey patched pickle
|
||||||
session_hash = hashlib.md5(session_pickled).hexdigest()
|
session_hash = hashlib.md5(session_pickled).hexdigest()
|
||||||
if previous_session_hash == session_hash:
|
if previous_session_hash == session_hash:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
from pickle import Pickler, MARK, DICT, EMPTY_DICT
|
||||||
|
from types import DictionaryType
|
||||||
|
|
||||||
|
def save_dict(self, obj):
|
||||||
|
self.write(EMPTY_DICT if self.bin else MARK+DICT)
|
||||||
|
self.memoize(obj)
|
||||||
|
self._batch_setitems([(key,obj[key]) for key in sorted(obj)])
|
||||||
|
|
||||||
|
Pickler.dispatch[DictionaryType] = save_dict
|
||||||
Reference in New Issue
Block a user