equal
deleted
inserted
replaced
23 ONESECOND = timedelta(0, 1, 0) |
23 ONESECOND = timedelta(0, 1, 0) |
24 |
24 |
25 class Cache(dict): |
25 class Cache(dict): |
26 def __init__(self): |
26 def __init__(self): |
27 super(Cache, self).__init__() |
27 super(Cache, self).__init__() |
28 self.cache_creation_date = None |
28 _now = datetime.now() |
29 self.latest_cache_lookup = datetime.now() |
29 self.cache_creation_date = _now |
|
30 self.latest_cache_lookup = _now |
30 |
31 |
31 CACHE_REGISTRY = {} |
32 CACHE_REGISTRY = {} |
32 |
33 |
33 class AppRsetObject(VObject): |
34 class AppRsetObject(VObject): |
34 """This is the base class for CubicWeb application objects |
35 """This is the base class for CubicWeb application objects |
125 - etc. |
126 - etc. |
126 """ |
127 """ |
127 if cachename in CACHE_REGISTRY: |
128 if cachename in CACHE_REGISTRY: |
128 cache = CACHE_REGISTRY[cachename] |
129 cache = CACHE_REGISTRY[cachename] |
129 else: |
130 else: |
130 cache = Cache() |
131 cache = CACHE_REGISTRY[cachename] = Cache() |
131 CACHE_REGISTRY[cachename] = cache |
|
132 _now = datetime.now() |
132 _now = datetime.now() |
133 if _now > cache.latest_cache_lookup + ONESECOND: |
133 if _now > cache.latest_cache_lookup + ONESECOND: |
134 ecache = self.req.execute('Any C,T WHERE C is CWCache, C name %(name)s, C timestamp T', |
134 ecache = self.req.execute('Any C,T WHERE C is CWCache, C name %(name)s, C timestamp T', |
135 {'name':cachename}).get_entity(0,0) |
135 {'name':cachename}).get_entity(0,0) |
136 cache.latest_cache_lookup = _now |
136 cache.latest_cache_lookup = _now |