Changeset 5703
- Timestamp:
- 07/15/07 01:24:54 (1 year ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/core/cache/backends/locmem.py (modified) (3 diffs)
- django/trunk/tests/regressiontests/cache/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r5687 r5703 238 238 Thomas Steinacher <http://www.eggdrop.ch/> 239 239 nowell strite 240 Sundance 240 241 Radek Švarz <http://www.svarz.cz/translate/> 241 242 Swaroop C H <http://www.swaroopch.info> django/trunk/django/core/cache/backends/locmem.py
r4265 r5703 3 3 from django.core.cache.backends.simple import CacheClass as SimpleCacheClass 4 4 from django.utils.synch import RWLock 5 import copy, time 5 import time 6 try: 7 import cPickle as pickle 8 except ImportError: 9 import pickle 6 10 7 11 class CacheClass(SimpleCacheClass): … … 21 25 should_delete = True 22 26 else: 23 return copy.deepcopy(self._cache[key]) 27 try: 28 return pickle.loads(self._cache[key]) 29 except pickle.PickleError: 30 return default 24 31 finally: 25 32 self._lock.reader_leaves() … … 36 43 self._lock.writer_enters() 37 44 try: 38 SimpleCacheClass.set(self, key, value, timeout) 45 try: 46 super(CacheClass, self).set(key, pickle.dumps(value), timeout) 47 except pickle.PickleError: 48 pass 39 49 finally: 40 50 self._lock.writer_leaves() django/trunk/tests/regressiontests/cache/tests.py
r5171 r5703 5 5 import time, unittest 6 6 7 # functions/classes for complex data type tests 7 # functions/classes for complex data type tests 8 8 def f(): 9 9 return 42 … … 47 47 self.assertEqual(cache.has_key("goodbye"), False) 48 48 49 def test_in(self): 50 cache.set("hello", "goodbye") 51 self.assertEqual("hello" in cache, True) 52 self.assertEqual("goodbye" in cache, False) 49 def test_in(self): 50 cache.set("hello", "goodbye") 51 self.assertEqual("hello" in cache, True) 52 self.assertEqual("goodbye" in cache, False) 53 53 54 54 def test_data_types(self): 55 # test data types56 55 stuff = { 57 56 'string' : 'this is a string', … … 62 61 'function' : f, 63 62 'class' : C, 63 'iter' : iter([1, 2 ,3]), 64 64 } 65 65 for (key, value) in stuff.items(): 66 66 cache.set(key, value) 67 67 self.assertEqual(cache.get(key), value) 68 68 69 69 def test_expiration(self): 70 70 # expiration
