monkey_patched_pickle
This commit is contained in:
2
VERSION
2
VERSION
@@ -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
|
||||
|
||||
@@ -23,11 +23,13 @@ from http import HTTP, redirect
|
||||
from fileutils import up
|
||||
from serializers import json, custom_json
|
||||
import settings
|
||||
import monkey_patch_pickle
|
||||
from utils import web2py_uuid, secure_dumps, secure_loads
|
||||
from settings import global_settings
|
||||
import hashlib
|
||||
import portalocker
|
||||
import cPickle
|
||||
import pickle
|
||||
import cStringIO
|
||||
import datetime
|
||||
import re
|
||||
@@ -977,7 +979,7 @@ class Session(Storage):
|
||||
if not previous_session_hash and not \
|
||||
any(value is not None for value in self.itervalues()):
|
||||
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()
|
||||
if previous_session_hash == session_hash:
|
||||
return True
|
||||
|
||||
9
gluon/monkey_patch_pickle.py
Normal file
9
gluon/monkey_patch_pickle.py
Normal file
@@ -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