entities/lib.py
branchtls-sprint
changeset 1016 26387b836099
parent 713 5adb6d8e5fa7
child 1154 9b23a6836c32
equal deleted inserted replaced
1014:4792a1bb72a9 1016:26387b836099
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
     8 
     8 
     9 from urlparse import urlsplit, urlunsplit
     9 from urlparse import urlsplit, urlunsplit
    10 from mx.DateTime import now
    10 from datetime import datetime
    11 
    11 
    12 from logilab.common.decorators import cached
    12 from logilab.common.decorators import cached
    13 
    13 
    14 from cubicweb.entity import _marker
    14 from cubicweb.entity import _marker
    15 from cubicweb.entities import AnyEntity, fetch_config
    15 from cubicweb.entities import AnyEntity, fetch_config
   151         return self.title
   151         return self.title
   152 
   152 
   153     def dc_description(self, format='text/plain'):
   153     def dc_description(self, format='text/plain'):
   154         return self.synopsis or u''
   154         return self.synopsis or u''
   155 
   155 
       
   156 
   156 class ECache(AnyEntity):
   157 class ECache(AnyEntity):
   157     """Cache"""
   158     """Cache"""
   158     id = 'ECache'
   159     id = 'ECache'
   159     
   160     
   160     fetch_attrs, fetch_order = fetch_config(['name'])
   161     fetch_attrs, fetch_order = fetch_config(['name'])
   161 
   162 
   162     def touch(self):
   163     def touch(self):
   163         self.req.execute('SET X timestamp %(t)s WHERE X eid %(x)s', {'t': now(), 'x': self.eid}, 'x')
   164         self.req.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
       
   165                          {'t': datetime.now(), 'x': self.eid}, 'x')
   164 
   166 
   165     def valid(self, date):
   167     def valid(self, date):
   166         return date < self.timestamp
   168         return date < self.timestamp