interfaces.py
branchtls-sprint
changeset 1553 3f91ef2397d0
parent 1263 01152fffd593
child 1802 d628defebc17
equal deleted inserted replaced
1552:7563b652341a 1553:3f91ef2397d0
     9 
     9 
    10 from logilab.common.interface import Interface
    10 from logilab.common.interface import Interface
    11 
    11 
    12 class IEmailable(Interface):
    12 class IEmailable(Interface):
    13     """interface for emailable entities"""
    13     """interface for emailable entities"""
    14     
    14 
    15     def get_email(self):
    15     def get_email(self):
    16         """return email address"""
    16         """return email address"""
    17 
    17 
    18     @classmethod
    18     @classmethod
    19     def allowed_massmail_keys(cls):
    19     def allowed_massmail_keys(cls):
    26         """
    26         """
    27 
    27 
    28     def as_email_context(self):
    28     def as_email_context(self):
    29         """returns the dictionary as used by the sendmail controller to
    29         """returns the dictionary as used by the sendmail controller to
    30         build email bodies.
    30         build email bodies.
    31         
    31 
    32         NOTE: the dictionary keys should match the list returned by the
    32         NOTE: the dictionary keys should match the list returned by the
    33         `allowed_massmail_keys` method.
    33         `allowed_massmail_keys` method.
    34         """
    34         """
    35 
    35 
    36 
    36 
    43 
    43 
    44     def change_state(self, stateeid, trcomment=None, trcommentformat=None):
    44     def change_state(self, stateeid, trcomment=None, trcommentformat=None):
    45         """change the entity's state according to a state defined in given
    45         """change the entity's state according to a state defined in given
    46         parameters
    46         parameters
    47         """
    47         """
    48     
    48 
    49     def can_pass_transition(self, trname):
    49     def can_pass_transition(self, trname):
    50         """return true if the current user can pass the transition with the
    50         """return true if the current user can pass the transition with the
    51         given name
    51         given name
    52         """
    52         """
    53     
    53 
    54     def latest_trinfo(self):
    54     def latest_trinfo(self):
    55         """return the latest transition information for this entity
    55         """return the latest transition information for this entity
    56         """
    56         """
    57 
    57 
    58 class IProgress(Interface):
    58 class IProgress(Interface):
    71         """what is already done"""
    71         """what is already done"""
    72 
    72 
    73     @property
    73     @property
    74     def todo(self):
    74     def todo(self):
    75         """what remains to be done"""
    75         """what remains to be done"""
    76     
    76 
    77     def progress_info(self):
    77     def progress_info(self):
    78         """returns a dictionary describing progress/estimated cost of the
    78         """returns a dictionary describing progress/estimated cost of the
    79         version.
    79         version.
    80 
    80 
    81         mandatory keys are (''estimated', 'done', 'todo')
    81         mandatory keys are (''estimated', 'done', 'todo')
    91     def in_progress(self):
    91     def in_progress(self):
    92         """returns True if status is not finished"""
    92         """returns True if status is not finished"""
    93 
    93 
    94     def progress(self):
    94     def progress(self):
    95         """returns the % progress of the task item"""
    95         """returns the % progress of the task item"""
    96         
    96 
    97     
    97 
    98 class IMileStone(IProgress):
    98 class IMileStone(IProgress):
    99     """represents an ITask's item"""
    99     """represents an ITask's item"""
   100     
   100 
   101     parent_type = None # specify main task's type
   101     parent_type = None # specify main task's type
   102     
   102 
   103     def get_main_task(self):
   103     def get_main_task(self):
   104         """returns the main ITask entity"""
   104         """returns the main ITask entity"""
   105 
   105 
   106     def initial_prevision_date(self):
   106     def initial_prevision_date(self):
   107         """returns the initial expected end of the milestone"""
   107         """returns the initial expected end of the milestone"""
   108         
   108 
   109     def eta_date(self):
   109     def eta_date(self):
   110         """returns expected date of completion based on what remains
   110         """returns expected date of completion based on what remains
   111         to be done
   111         to be done
   112         """
   112         """
   113 
   113 
   126     def children(self):
   126     def children(self):
   127         """returns the item's children"""
   127         """returns the item's children"""
   128 
   128 
   129     def __iter__(self):
   129     def __iter__(self):
   130         """iterates over the item's children"""
   130         """iterates over the item's children"""
   131         
   131 
   132     def is_leaf(self):
   132     def is_leaf(self):
   133         """returns true if this node as no child"""
   133         """returns true if this node as no child"""
   134 
   134 
   135     def is_root(self):
   135     def is_root(self):
   136         """returns true if this node has no parent"""
   136         """returns true if this node has no parent"""
   144 
   144 
   145 class IPrevNext(Interface):
   145 class IPrevNext(Interface):
   146     """interface for entities which can be linked to a previous and/or next
   146     """interface for entities which can be linked to a previous and/or next
   147     entity
   147     entity
   148     """
   148     """
   149     
   149 
   150     def next_entity(self):
   150     def next_entity(self):
   151         """return the 'next' entity"""
   151         """return the 'next' entity"""
   152     def previous_entity(self):
   152     def previous_entity(self):
   153         """return the 'previous' entity"""
   153         """return the 'previous' entity"""
   154 
   154 
   155 
   155 
   156 class IBreadCrumbs(Interface):
   156 class IBreadCrumbs(Interface):
   157     """interface for entities which can be "located" on some path"""
   157     """interface for entities which can be "located" on some path"""
   158     
   158 
   159     def breadcrumbs(self, view, recurs=False):
   159     def breadcrumbs(self, view, recurs=False):
   160         """return a list containing some:
   160         """return a list containing some:
   161         
   161 
   162         * tuple (url, label)
   162         * tuple (url, label)
   163         * entity
   163         * entity
   164         * simple label string
   164         * simple label string
   165 
   165 
   166         defining path from a root to the current view
   166         defining path from a root to the current view
   171         """
   171         """
   172 
   172 
   173 
   173 
   174 class IDownloadable(Interface):
   174 class IDownloadable(Interface):
   175     """interface for downloadable entities"""
   175     """interface for downloadable entities"""
   176     
   176 
   177     def download_url(self): # XXX not really part of this interface
   177     def download_url(self): # XXX not really part of this interface
   178         """return an url to download entity's content"""
   178         """return an url to download entity's content"""
   179     def download_content_type(self):
   179     def download_content_type(self):
   180         """return MIME type of the downloadable content"""
   180         """return MIME type of the downloadable content"""
   181     def download_encoding(self):
   181     def download_encoding(self):
   186         """return actual data of the downloadable content"""
   186         """return actual data of the downloadable content"""
   187 
   187 
   188 
   188 
   189 class IEmbedable(Interface):
   189 class IEmbedable(Interface):
   190     """interface for embedable entities"""
   190     """interface for embedable entities"""
   191     
   191 
   192     def embeded_url(self):
   192     def embeded_url(self):
   193         """embed action interface"""
   193         """embed action interface"""
   194     
   194 
   195 class ICalendarable(Interface):
   195 class ICalendarable(Interface):
   196     """interface for items that do have a begin date 'start' and an end date 'stop'
   196     """interface for items that do have a begin date 'start' and an end date 'stop'
   197     """    
   197     """
   198     
   198 
   199 class ICalendarViews(Interface):
   199 class ICalendarViews(Interface):
   200     """calendar views interface"""
   200     """calendar views interface"""
   201     def matching_dates(self, begin, end):
   201     def matching_dates(self, begin, end):
   202         """
   202         """
   203         :param begin: day considered as begin of the range (`DateTime`)
   203         :param begin: day considered as begin of the range (`DateTime`)
   204         :param end: day considered as end of the range (`DateTime`)
   204         :param end: day considered as end of the range (`DateTime`)
   205         
   205 
   206         :return:
   206         :return:
   207           a list of dates (`DateTime`) in the range [`begin`, `end`] on which
   207           a list of dates (`DateTime`) in the range [`begin`, `end`] on which
   208           this entity apply
   208           this entity apply
   209         """
   209         """
   210         
   210 
   211 class ITimetableViews(Interface):
   211 class ITimetableViews(Interface):
   212     """timetable views interface"""
   212     """timetable views interface"""
   213     def timetable_date(self):
   213     def timetable_date(self):
   214         """XXX explain
   214         """XXX explain
   215         
   215 
   216         :return: date (`DateTime`)
   216         :return: date (`DateTime`)
   217         """
   217         """
   218 
   218 
   219 class IGeocodable(Interface):
   219 class IGeocodable(Interface):
   220     """interface required by geocoding views such as gmap-view"""
   220     """interface required by geocoding views such as gmap-view"""
   229 
   229 
   230     def marker_icon(self):
   230     def marker_icon(self):
   231         """returns the icon that should be used as the marker
   231         """returns the icon that should be used as the marker
   232         (returns None for default)
   232         (returns None for default)
   233         """
   233         """
   234         
   234 
   235 class IFeed(Interface):
   235 class IFeed(Interface):
   236     """interface for entities with rss flux"""
   236     """interface for entities with rss flux"""
   237     
   237 
   238     def rss_feed_url(self):
   238     def rss_feed_url(self):
   239         """return an url which layout sub-entities item
   239         """return an url which layout sub-entities item
   240         """
   240         """
       
   241 
   241 class ISiocItem(Interface):
   242 class ISiocItem(Interface):
   242     """interface for entities (which are item
   243     """interface for entities (which are item
   243     in sioc specification) with sioc views"""
   244     in sioc specification) with sioc views"""
   244     
   245 
   245     def isioc_content(self):
   246     def isioc_content(self):
   246         """return content entity"""
   247         """return content entity"""
   247 
   248 
   248     def isioc_container(self):
   249     def isioc_container(self):
   249         """return container entity"""
   250         """return container entity"""
   250 
   251 
   251     def isioc_type(self):
   252     def isioc_type(self):
   252         """return container type (post, BlogPost, MailMessage)"""
   253         """return container type (post, BlogPost, MailMessage)"""
   253 
   254 
   254     def isioc_replies(self):
   255     def isioc_replies(self):
   255         """return replies items"""       
   256         """return replies items"""
   256 
   257 
   257     def isioc_topics(self):
   258     def isioc_topics(self):
   258         """return topics items"""
   259         """return topics items"""
   259             
   260 
   260 class ISiocContainer(Interface):
   261 class ISiocContainer(Interface):
   261     """interface for entities (which are container
   262     """interface for entities (which are container
   262     in sioc specification) with sioc views"""
   263     in sioc specification) with sioc views"""
   263 
   264 
   264     def isioc_type(self):
   265     def isioc_type(self):
   265         """return container type (forum, Weblog, MailingList)"""
   266         """return container type (forum, Weblog, MailingList)"""
   266 
   267 
   267     def isioc_items(self):
   268     def isioc_items(self):
   268         """return contained items"""
   269         """return contained items"""
   269 
   270 
   270    
   271 
   271     
   272