Changeset - 9ca25e5986ba
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-05-01 04:56:51
chrisjrn@gmail.com
Makes sure that the cache is not disturbed by calling end_batch
1 file changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
registrasion/controllers/batch.py
Show inline comments
...
 
@@ -49,13 +49,23 @@ class BatchController(object):
 
        cache[cls._NESTING_KEY] -= 1
 

	
 
        if cache[cls._NESTING_KEY] == 0:
 
            cls._call_end_batch_methods(user)
 
            del cls._user_caches[user]
 

	
 
            for key in cache:
 
    @classmethod
 
    def _call_end_batch_methods(cls, user):
 
        cache = cls._user_caches[user]
 
        ended = set()
 
        while True:
 
            keys = set(cache.keys())
 
            if ended == keys:
 
                break
 
            keys_to_end = keys - ended
 
            for key in keys_to_end:
 
                item = cache[key]
 
                if hasattr(item, 'end_batch') and callable(item.end_batch):
 
                    item.end_batch()
 

	
 
            del cls._user_caches[user]
 
            ended = ended | keys_to_end
 

	
 
    @classmethod
 
    def memoise(cls, func):
0 comments (0 inline, 0 general)