cubicweb/entities/lib.py
changeset 12539 10159a3d1d72
parent 11767 432f87a63057
child 12567 26744ad37953
equal deleted inserted replaced
12538:114b05d48c44 12539:10159a3d1d72
   123     def dc_description(self, format='text/plain'):
   123     def dc_description(self, format='text/plain'):
   124         try:
   124         try:
   125             return self._cw._(self._cw.vreg.property_info(self.pkey)['help'])
   125             return self._cw._(self._cw.vreg.property_info(self.pkey)['help'])
   126         except UnknownProperty:
   126         except UnknownProperty:
   127             return u''
   127             return u''
   128 
       
   129 
       
   130 class CWCache(AnyEntity):
       
   131     """Cache"""
       
   132     __regid__ = 'CWCache'
       
   133     fetch_attrs, cw_fetch_order = fetch_config(['name'])
       
   134 
       
   135     def __init__(self, *args, **kwargs):
       
   136         warn('[3.19] CWCache entity type is going away soon. '
       
   137              'Other caching mechanisms can be used more reliably '
       
   138              'to the same effect.',
       
   139              DeprecationWarning)
       
   140         super(CWCache, self).__init__(*args, **kwargs)
       
   141 
       
   142     def touch(self):
       
   143         self._cw.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
       
   144                          {'t': datetime.now(), 'x': self.eid})
       
   145 
       
   146     def valid(self, date):
       
   147         if date:
       
   148             return date > self.timestamp
       
   149         return False