1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """Standard interfaces. Deprecated in favor of adapters. |
|
19 |
|
20 .. note:: |
|
21 |
|
22 The `implements` selector used to match not only entity classes but also their |
|
23 interfaces. This will disappear in a future version. You should define an |
|
24 adapter for that interface and use `adaptable('MyIFace')` selector on appobjects |
|
25 that require that interface. |
|
26 |
|
27 """ |
|
28 __docformat__ = "restructuredtext en" |
|
29 |
|
30 from logilab.common.interface import Interface |
|
31 |
|
32 |
|
33 # XXX deprecates in favor of IProgressAdapter |
|
34 class IProgress(Interface): |
|
35 """something that has a cost, a state and a progression""" |
|
36 |
|
37 @property |
|
38 def cost(self): |
|
39 """the total cost""" |
|
40 |
|
41 @property |
|
42 def done(self): |
|
43 """what is already done""" |
|
44 |
|
45 @property |
|
46 def todo(self): |
|
47 """what remains to be done""" |
|
48 |
|
49 def progress_info(self): |
|
50 """returns a dictionary describing progress/estimated cost of the |
|
51 version. |
|
52 |
|
53 - mandatory keys are (''estimated', 'done', 'todo') |
|
54 |
|
55 - optional keys are ('notestimated', 'notestimatedcorrected', |
|
56 'estimatedcorrected') |
|
57 |
|
58 'noestimated' and 'notestimatedcorrected' should default to 0 |
|
59 'estimatedcorrected' should default to 'estimated' |
|
60 """ |
|
61 |
|
62 def finished(self): |
|
63 """returns True if status is finished""" |
|
64 |
|
65 def in_progress(self): |
|
66 """returns True if status is not finished""" |
|
67 |
|
68 def progress(self): |
|
69 """returns the % progress of the task item""" |
|
70 |
|
71 # XXX deprecates in favor of IMileStoneAdapter |
|
72 class IMileStone(IProgress): |
|
73 """represents an ITask's item""" |
|
74 |
|
75 parent_type = None # specify main task's type |
|
76 |
|
77 def get_main_task(self): |
|
78 """returns the main ITask entity""" |
|
79 |
|
80 def initial_prevision_date(self): |
|
81 """returns the initial expected end of the milestone""" |
|
82 |
|
83 def eta_date(self): |
|
84 """returns expected date of completion based on what remains |
|
85 to be done |
|
86 """ |
|
87 |
|
88 def completion_date(self): |
|
89 """returns date on which the subtask has been completed""" |
|
90 |
|
91 def contractors(self): |
|
92 """returns the list of persons supposed to work on this task""" |
|
93 |
|
94 # XXX deprecates in favor of IEmbedableAdapter |
|
95 class IEmbedable(Interface): |
|
96 """interface for embedable entities""" |
|
97 |
|
98 def embeded_url(self): |
|
99 """embed action interface""" |
|
100 |
|
101 # XXX deprecates in favor of ICalendarViewsAdapter |
|
102 class ICalendarViews(Interface): |
|
103 """calendar views interface""" |
|
104 def matching_dates(self, begin, end): |
|
105 """ |
|
106 :param begin: day considered as begin of the range (`DateTime`) |
|
107 :param end: day considered as end of the range (`DateTime`) |
|
108 |
|
109 :return: |
|
110 a list of dates (`DateTime`) in the range [`begin`, `end`] on which |
|
111 this entity apply |
|
112 """ |
|
113 |
|
114 # XXX deprecates in favor of ICalendarableAdapter |
|
115 class ICalendarable(Interface): |
|
116 """interface for items that do have a begin date 'start' and an end date 'stop' |
|
117 """ |
|
118 |
|
119 @property |
|
120 def start(self): |
|
121 """return start date""" |
|
122 |
|
123 @property |
|
124 def stop(self): |
|
125 """return stop state""" |
|
126 |
|
127 # XXX deprecates in favor of ICalendarableAdapter |
|
128 class ITimetableViews(Interface): |
|
129 """timetable views interface""" |
|
130 def timetable_date(self): |
|
131 """XXX explain |
|
132 |
|
133 :return: date (`DateTime`) |
|
134 """ |
|
135 |
|
136 # XXX deprecates in favor of IGeocodableAdapter |
|
137 class IGeocodable(Interface): |
|
138 """interface required by geocoding views such as gmap-view""" |
|
139 |
|
140 @property |
|
141 def latitude(self): |
|
142 """returns the latitude of the entity""" |
|
143 |
|
144 @property |
|
145 def longitude(self): |
|
146 """returns the longitude of the entity""" |
|
147 |
|
148 def marker_icon(self): |
|
149 """returns the icon that should be used as the marker""" |
|
150 |
|
151 |
|
152 # XXX deprecates in favor of IEmailableAdapter |
|
153 class IFeed(Interface): |
|
154 """interface for entities with rss flux""" |
|
155 |
|
156 def rss_feed_url(self): |
|
157 """""" |
|
158 |
|
159 # XXX deprecates in favor of IDownloadableAdapter |
|
160 class IDownloadable(Interface): |
|
161 """interface for downloadable entities""" |
|
162 |
|
163 def download_url(self): # XXX not really part of this interface |
|
164 """return an url to download entity's content""" |
|
165 def download_content_type(self): |
|
166 """return MIME type of the downloadable content""" |
|
167 def download_encoding(self): |
|
168 """return encoding of the downloadable content""" |
|
169 def download_file_name(self): |
|
170 """return file name of the downloadable content""" |
|
171 def download_data(self): |
|
172 """return actual data of the downloadable content""" |
|
173 |
|
174 # XXX deprecates in favor of IPrevNextAdapter |
|
175 class IPrevNext(Interface): |
|
176 """interface for entities which can be linked to a previous and/or next |
|
177 entity |
|
178 """ |
|
179 |
|
180 def next_entity(self): |
|
181 """return the 'next' entity""" |
|
182 def previous_entity(self): |
|
183 """return the 'previous' entity""" |
|
184 |
|
185 # XXX deprecates in favor of IBreadCrumbsAdapter |
|
186 class IBreadCrumbs(Interface): |
|
187 |
|
188 def breadcrumbs(self, view, recurs=False): |
|
189 pass |
|
190 |
|
191 # XXX deprecates in favor of ITreeAdapter |
|
192 class ITree(Interface): |
|
193 |
|
194 def parent(self): |
|
195 """returns the parent entity""" |
|
196 |
|
197 def children(self): |
|
198 """returns the item's children""" |
|
199 |
|
200 def children_rql(self): |
|
201 """XXX returns RQL to get children""" |
|
202 |
|
203 def iterchildren(self): |
|
204 """iterates over the item's children""" |
|
205 |
|
206 def is_leaf(self): |
|
207 """returns true if this node as no child""" |
|
208 |
|
209 def is_root(self): |
|
210 """returns true if this node has no parent""" |
|
211 |
|
212 def root(self): |
|
213 """returns the root object""" |
|
214 |
|