entities/lib.py
changeset 3377 dd9d292b6a6d
parent 3230 1d25e928c299
child 3418 7b49fa7e942d
equal deleted inserted replaced
3376:f5c69485381f 3377:dd9d292b6a6d
    22     except ValueError:
    22     except ValueError:
    23         return address
    23         return address
    24     return '%s at %s' % (name, host.replace('.', ' dot '))
    24     return '%s at %s' % (name, host.replace('.', ' dot '))
    25 
    25 
    26 class EmailAddress(AnyEntity):
    26 class EmailAddress(AnyEntity):
    27     id = 'EmailAddress'
    27     __regid__ = 'EmailAddress'
    28     fetch_attrs, fetch_order = fetch_config(['address', 'alias'])
    28     fetch_attrs, fetch_order = fetch_config(['address', 'alias'])
    29 
    29 
    30     def dc_title(self):
    30     def dc_title(self):
    31         if self.alias:
    31         if self.alias:
    32             return '%s <%s>' % (self.alias, self.display_address())
    32             return '%s <%s>' % (self.alias, self.display_address())
    82         return super(EmailAddress, self).after_deletion_path()
    82         return super(EmailAddress, self).after_deletion_path()
    83 
    83 
    84 
    84 
    85 class Bookmark(AnyEntity):
    85 class Bookmark(AnyEntity):
    86     """customized class for Bookmark entities"""
    86     """customized class for Bookmark entities"""
    87     id = 'Bookmark'
    87     __regid__ = 'Bookmark'
    88     fetch_attrs, fetch_order = fetch_config(['title', 'path'])
    88     fetch_attrs, fetch_order = fetch_config(['title', 'path'])
    89 
    89 
    90     def actual_url(self):
    90     def actual_url(self):
    91         url = self.req.build_url(self.path)
    91         url = self.req.build_url(self.path)
    92         if self.title:
    92         if self.title:
   101     def action_url(self):
   101     def action_url(self):
   102         return self.absolute_url() + '/follow'
   102         return self.absolute_url() + '/follow'
   103 
   103 
   104 
   104 
   105 class CWProperty(AnyEntity):
   105 class CWProperty(AnyEntity):
   106     id = 'CWProperty'
   106     __regid__ = 'CWProperty'
   107 
   107 
   108     fetch_attrs, fetch_order = fetch_config(['pkey', 'value'])
   108     fetch_attrs, fetch_order = fetch_config(['pkey', 'value'])
   109     rest_attr = 'pkey'
   109     rest_attr = 'pkey'
   110 
   110 
   111     def typed_value(self):
   111     def typed_value(self):
   124         return 'view', {}
   124         return 'view', {}
   125 
   125 
   126 
   126 
   127 class CWCache(AnyEntity):
   127 class CWCache(AnyEntity):
   128     """Cache"""
   128     """Cache"""
   129     id = 'CWCache'
   129     __regid__ = 'CWCache'
   130     fetch_attrs, fetch_order = fetch_config(['name'])
   130     fetch_attrs, fetch_order = fetch_config(['name'])
   131 
   131 
   132     def touch(self):
   132     def touch(self):
   133         self.req.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
   133         self.req.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
   134                          {'t': datetime.now(), 'x': self.eid}, 'x')
   134                          {'t': datetime.now(), 'x': self.eid}, 'x')