author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 14 Apr 2010 17:02:07 +0200 | |
branch | stable |
changeset 5259 | 61505346e28f |
parent 4936 | a4b772a0d801 |
child 5309 | e8567135a927 |
permissions | -rw-r--r-- |
0 | 1 |
"""Specific views for entities implementing IDownloadable |
2 |
||
3 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3635
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
||
9 |
__docformat__ = "restructuredtext en" |
|
10 |
||
11 |
from logilab.common.interface import Interface |
|
12 |
||
13 |
class IEmailable(Interface): |
|
14 |
"""interface for emailable entities""" |
|
1553 | 15 |
|
0 | 16 |
def get_email(self): |
17 |
"""return email address""" |
|
18 |
||
19 |
@classmethod |
|
20 |
def allowed_massmail_keys(cls): |
|
21 |
"""returns a set of allowed email substitution keys |
|
22 |
||
23 |
The default is to return the entity's attribute list but an |
|
24 |
entity class might override this method to allow extra keys. |
|
25 |
For instance, the Person class might want to return a `companyname` |
|
26 |
key. |
|
27 |
""" |
|
28 |
||
29 |
def as_email_context(self): |
|
30 |
"""returns the dictionary as used by the sendmail controller to |
|
31 |
build email bodies. |
|
1553 | 32 |
|
0 | 33 |
NOTE: the dictionary keys should match the list returned by the |
34 |
`allowed_massmail_keys` method. |
|
35 |
""" |
|
36 |
||
37 |
||
38 |
class IWorkflowable(Interface): |
|
39 |
"""interface for entities dealing with a specific workflow""" |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2747
diff
changeset
|
40 |
# XXX to be completed, see cw.entities.wfobjs.WorkflowableMixIn |
0 | 41 |
|
42 |
@property |
|
43 |
def state(self): |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2747
diff
changeset
|
44 |
"""return current state name""" |
0 | 45 |
|
46 |
def change_state(self, stateeid, trcomment=None, trcommentformat=None): |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2747
diff
changeset
|
47 |
"""change the entity's state to the state of the given name in entity's |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2747
diff
changeset
|
48 |
workflow |
0 | 49 |
""" |
1553 | 50 |
|
0 | 51 |
def latest_trinfo(self): |
52 |
"""return the latest transition information for this entity |
|
53 |
""" |
|
54 |
||
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2747
diff
changeset
|
55 |
|
0 | 56 |
class IProgress(Interface): |
57 |
"""something that has a cost, a state and a progression |
|
58 |
||
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3635
diff
changeset
|
59 |
Take a look at cubicweb.mixins.ProgressMixIn for some |
0 | 60 |
default implementations |
61 |
""" |
|
62 |
||
63 |
@property |
|
64 |
def cost(self): |
|
65 |
"""the total cost""" |
|
66 |
||
67 |
@property |
|
68 |
def done(self): |
|
69 |
"""what is already done""" |
|
70 |
||
71 |
@property |
|
72 |
def todo(self): |
|
73 |
"""what remains to be done""" |
|
1553 | 74 |
|
0 | 75 |
def progress_info(self): |
76 |
"""returns a dictionary describing progress/estimated cost of the |
|
77 |
version. |
|
78 |
||
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
79 |
- mandatory keys are (''estimated', 'done', 'todo') |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
80 |
|
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
81 |
- optional keys are ('notestimated', 'notestimatedcorrected', |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
82 |
'estimatedcorrected') |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
83 |
|
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
84 |
'noestimated' and 'notestimatedcorrected' should default to 0 |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
85 |
'estimatedcorrected' should default to 'estimated' |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4252
diff
changeset
|
86 |
""" |
0 | 87 |
|
88 |
def finished(self): |
|
89 |
"""returns True if status is finished""" |
|
90 |
||
91 |
def in_progress(self): |
|
92 |
"""returns True if status is not finished""" |
|
93 |
||
94 |
def progress(self): |
|
95 |
"""returns the % progress of the task item""" |
|
1553 | 96 |
|
97 |
||
0 | 98 |
class IMileStone(IProgress): |
99 |
"""represents an ITask's item""" |
|
1553 | 100 |
|
0 | 101 |
parent_type = None # specify main task's type |
1553 | 102 |
|
0 | 103 |
def get_main_task(self): |
104 |
"""returns the main ITask entity""" |
|
105 |
||
106 |
def initial_prevision_date(self): |
|
107 |
"""returns the initial expected end of the milestone""" |
|
1553 | 108 |
|
0 | 109 |
def eta_date(self): |
110 |
"""returns expected date of completion based on what remains |
|
111 |
to be done |
|
112 |
""" |
|
113 |
||
114 |
def completion_date(self): |
|
115 |
"""returns date on which the subtask has been completed""" |
|
116 |
||
117 |
def contractors(self): |
|
118 |
"""returns the list of persons supposed to work on this task""" |
|
119 |
||
120 |
||
121 |
class ITree(Interface): |
|
122 |
||
123 |
def parent(self): |
|
124 |
"""returns the parent entity""" |
|
125 |
||
126 |
def children(self): |
|
127 |
"""returns the item's children""" |
|
128 |
||
2747
4f9ffcd8d5a2
cleanup docstring, add actually used method to the ITree interface
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2135
diff
changeset
|
129 |
def children_rql(self): |
4f9ffcd8d5a2
cleanup docstring, add actually used method to the ITree interface
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2135
diff
changeset
|
130 |
"""XXX returns RQL to get children""" |
4f9ffcd8d5a2
cleanup docstring, add actually used method to the ITree interface
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2135
diff
changeset
|
131 |
|
3635
a56759c3c99f
do not override __iter__ on entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
132 |
def iterchildren(self): |
0 | 133 |
"""iterates over the item's children""" |
1553 | 134 |
|
0 | 135 |
def is_leaf(self): |
136 |
"""returns true if this node as no child""" |
|
137 |
||
138 |
def is_root(self): |
|
139 |
"""returns true if this node has no parent""" |
|
140 |
||
141 |
def root(self): |
|
2747
4f9ffcd8d5a2
cleanup docstring, add actually used method to the ITree interface
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2135
diff
changeset
|
142 |
"""returns the root object""" |
0 | 143 |
|
144 |
||
145 |
## web specific interfaces #################################################### |
|
146 |
||
147 |
||
148 |
class IPrevNext(Interface): |
|
149 |
"""interface for entities which can be linked to a previous and/or next |
|
150 |
entity |
|
151 |
""" |
|
1553 | 152 |
|
0 | 153 |
def next_entity(self): |
154 |
"""return the 'next' entity""" |
|
155 |
def previous_entity(self): |
|
156 |
"""return the 'previous' entity""" |
|
157 |
||
158 |
||
159 |
class IBreadCrumbs(Interface): |
|
160 |
"""interface for entities which can be "located" on some path""" |
|
1553 | 161 |
|
0 | 162 |
def breadcrumbs(self, view, recurs=False): |
163 |
"""return a list containing some: |
|
1553 | 164 |
|
0 | 165 |
* tuple (url, label) |
166 |
* entity |
|
167 |
* simple label string |
|
168 |
||
169 |
defining path from a root to the current view |
|
170 |
||
171 |
the main view is given as argument so breadcrumbs may vary according |
|
172 |
to displayed view (may be None). When recursing on a parent entity, |
|
173 |
the `recurs` argument should be set to True. |
|
174 |
""" |
|
175 |
||
176 |
||
177 |
class IDownloadable(Interface): |
|
178 |
"""interface for downloadable entities""" |
|
1553 | 179 |
|
0 | 180 |
def download_url(self): # XXX not really part of this interface |
181 |
"""return an url to download entity's content""" |
|
182 |
def download_content_type(self): |
|
183 |
"""return MIME type of the downloadable content""" |
|
184 |
def download_encoding(self): |
|
185 |
"""return encoding of the downloadable content""" |
|
186 |
def download_file_name(self): |
|
187 |
"""return file name of the downloadable content""" |
|
188 |
def download_data(self): |
|
189 |
"""return actual data of the downloadable content""" |
|
190 |
||
191 |
||
192 |
class IEmbedable(Interface): |
|
193 |
"""interface for embedable entities""" |
|
1553 | 194 |
|
0 | 195 |
def embeded_url(self): |
196 |
"""embed action interface""" |
|
1553 | 197 |
|
0 | 198 |
class ICalendarable(Interface): |
767 | 199 |
"""interface for items that do have a begin date 'start' and an end date 'stop' |
1553 | 200 |
""" |
201 |
||
2135
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
202 |
@property |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
203 |
def start(self): |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
204 |
"""return start date""" |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
205 |
|
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
206 |
@property |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
207 |
def stop(self): |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
208 |
"""return stop state""" |
55fc8b488907
[interfaces] describe more explicitly what should be implemente in the ICalendarable interface
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
209 |
|
0 | 210 |
class ICalendarViews(Interface): |
211 |
"""calendar views interface""" |
|
212 |
def matching_dates(self, begin, end): |
|
213 |
""" |
|
214 |
:param begin: day considered as begin of the range (`DateTime`) |
|
215 |
:param end: day considered as end of the range (`DateTime`) |
|
1553 | 216 |
|
0 | 217 |
:return: |
218 |
a list of dates (`DateTime`) in the range [`begin`, `end`] on which |
|
219 |
this entity apply |
|
220 |
""" |
|
1553 | 221 |
|
0 | 222 |
class ITimetableViews(Interface): |
223 |
"""timetable views interface""" |
|
224 |
def timetable_date(self): |
|
225 |
"""XXX explain |
|
1553 | 226 |
|
0 | 227 |
:return: date (`DateTime`) |
228 |
""" |
|
229 |
||
230 |
class IGeocodable(Interface): |
|
231 |
"""interface required by geocoding views such as gmap-view""" |
|
232 |
||
233 |
@property |
|
234 |
def latitude(self): |
|
235 |
"""returns the latitude of the entity""" |
|
236 |
||
237 |
@property |
|
238 |
def longitude(self): |
|
239 |
"""returns the longitude of the entity""" |
|
240 |
||
241 |
def marker_icon(self): |
|
242 |
"""returns the icon that should be used as the marker |
|
243 |
(returns None for default) |
|
244 |
""" |
|
1553 | 245 |
|
125
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
246 |
class IFeed(Interface): |
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
247 |
"""interface for entities with rss flux""" |
1553 | 248 |
|
125
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
249 |
def rss_feed_url(self): |
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
250 |
"""return an url which layout sub-entities item |
979dbe0cade3
views with rss feed
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
0
diff
changeset
|
251 |
""" |
1553 | 252 |
|
990
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
253 |
class ISiocItem(Interface): |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
254 |
"""interface for entities (which are item |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
255 |
in sioc specification) with sioc views""" |
1553 | 256 |
|
993
c1ce4c3a7c8f
removing useless method for interfaces ISiocItem and ISiocContainer.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
990
diff
changeset
|
257 |
def isioc_content(self): |
990
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
258 |
"""return content entity""" |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
259 |
|
993
c1ce4c3a7c8f
removing useless method for interfaces ISiocItem and ISiocContainer.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
990
diff
changeset
|
260 |
def isioc_container(self): |
1199
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
261 |
"""return container entity""" |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
262 |
|
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
263 |
def isioc_type(self): |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
264 |
"""return container type (post, BlogPost, MailMessage)""" |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
265 |
|
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
266 |
def isioc_replies(self): |
1553 | 267 |
"""return replies items""" |
1199
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
268 |
|
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
269 |
def isioc_topics(self): |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
270 |
"""return topics items""" |
1553 | 271 |
|
990
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
272 |
class ISiocContainer(Interface): |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
273 |
"""interface for entities (which are container |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
274 |
in sioc specification) with sioc views""" |
5f1ff5b6907a
ISiocItem is an interface that is implemented by 'post' entities (in sioc specification) i.e blogentry, mail ...
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
626
diff
changeset
|
275 |
|
993
c1ce4c3a7c8f
removing useless method for interfaces ISiocItem and ISiocContainer.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
990
diff
changeset
|
276 |
def isioc_type(self): |
1199
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
277 |
"""return container type (forum, Weblog, MailingList)""" |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
278 |
|
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
279 |
def isioc_items(self): |
7fa66717175b
fixing isioc_type comment
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
994
diff
changeset
|
280 |
"""return contained items""" |