equal
deleted
inserted
replaced
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
37 return '%s at %s' % (name, host.replace('.', ' dot ')) |
37 return '%s at %s' % (name, host.replace('.', ' dot ')) |
38 |
38 |
39 |
39 |
40 class EmailAddress(AnyEntity): |
40 class EmailAddress(AnyEntity): |
41 __regid__ = 'EmailAddress' |
41 __regid__ = 'EmailAddress' |
42 fetch_attrs, fetch_order = fetch_config(['address', 'alias']) |
42 fetch_attrs, cw_fetch_order = fetch_config(['address', 'alias']) |
43 rest_attr = 'eid' |
43 rest_attr = 'eid' |
44 |
44 |
45 def dc_title(self): |
45 def dc_title(self): |
46 if self.alias: |
46 if self.alias: |
47 return '%s <%s>' % (self.alias, self.display_address()) |
47 return '%s <%s>' % (self.alias, self.display_address()) |
51 def email_of(self): |
51 def email_of(self): |
52 return self.reverse_use_email and self.reverse_use_email[0] or None |
52 return self.reverse_use_email and self.reverse_use_email[0] or None |
53 |
53 |
54 @property |
54 @property |
55 def prefered(self): |
55 def prefered(self): |
56 return self.prefered_form and self.prefered_form[0] or self |
|
57 |
|
58 @deprecated('[3.6] use .prefered') |
|
59 def canonical_form(self): |
|
60 return self.prefered_form and self.prefered_form[0] or self |
56 return self.prefered_form and self.prefered_form[0] or self |
61 |
57 |
62 def related_emails(self, skipeids=None): |
58 def related_emails(self, skipeids=None): |
63 # XXX move to eemail |
59 # XXX move to eemail |
64 # check email relations are in the schema first |
60 # check email relations are in the schema first |
92 |
88 |
93 |
89 |
94 class Bookmark(AnyEntity): |
90 class Bookmark(AnyEntity): |
95 """customized class for Bookmark entities""" |
91 """customized class for Bookmark entities""" |
96 __regid__ = 'Bookmark' |
92 __regid__ = 'Bookmark' |
97 fetch_attrs, fetch_order = fetch_config(['title', 'path']) |
93 fetch_attrs, cw_fetch_order = fetch_config(['title', 'path']) |
98 |
94 |
99 def actual_url(self): |
95 def actual_url(self): |
100 url = self._cw.build_url(self.path) |
96 url = self._cw.build_url(self.path) |
101 if self.title: |
97 if self.title: |
102 urlparts = list(urlsplit(url)) |
98 urlparts = list(urlsplit(url)) |
112 |
108 |
113 |
109 |
114 class CWProperty(AnyEntity): |
110 class CWProperty(AnyEntity): |
115 __regid__ = 'CWProperty' |
111 __regid__ = 'CWProperty' |
116 |
112 |
117 fetch_attrs, fetch_order = fetch_config(['pkey', 'value']) |
113 fetch_attrs, cw_fetch_order = fetch_config(['pkey', 'value']) |
118 rest_attr = 'pkey' |
114 rest_attr = 'pkey' |
119 |
115 |
120 def typed_value(self): |
116 def typed_value(self): |
121 return self._cw.vreg.typed_value(self.pkey, self.value) |
117 return self._cw.vreg.typed_value(self.pkey, self.value) |
122 |
118 |
128 |
124 |
129 |
125 |
130 class CWCache(AnyEntity): |
126 class CWCache(AnyEntity): |
131 """Cache""" |
127 """Cache""" |
132 __regid__ = 'CWCache' |
128 __regid__ = 'CWCache' |
133 fetch_attrs, fetch_order = fetch_config(['name']) |
129 fetch_attrs, cw_fetch_order = fetch_config(['name']) |
134 |
130 |
135 def touch(self): |
131 def touch(self): |
136 self._cw.execute('SET X timestamp %(t)s WHERE X eid %(x)s', |
132 self._cw.execute('SET X timestamp %(t)s WHERE X eid %(x)s', |
137 {'t': datetime.now(), 'x': self.eid}) |
133 {'t': datetime.now(), 'x': self.eid}) |
138 |
134 |