entities/adapters.py
branchstable
changeset 6864 ea95004494a2
parent 6752 7351806cd485
child 6974 6f23b2baf99b
equal deleted inserted replaced
6863:2e52db5cdbde 6864:ea95004494a2
    66         return dict( (attr, getattr(self.entity, attr))
    66         return dict( (attr, getattr(self.entity, attr))
    67                      for attr in self.allowed_massmail_keys() )
    67                      for attr in self.allowed_massmail_keys() )
    68 
    68 
    69 
    69 
    70 class INotifiableAdapter(EntityAdapter):
    70 class INotifiableAdapter(EntityAdapter):
       
    71     __needs_bw_compat__ = True
    71     __regid__ = 'INotifiable'
    72     __regid__ = 'INotifiable'
    72     __select__ = is_instance('Any')
    73     __select__ = is_instance('Any')
    73 
    74 
    74     @implements_adapter_compat('INotifiableAdapter')
    75     @implements_adapter_compat('INotifiableAdapter')
    75     def notification_references(self, view):
    76     def notification_references(self, view):
   155     for weight, words in newdict.iteritems():
   156     for weight, words in newdict.iteritems():
   156         maindict.setdefault(weight, []).extend(words)
   157         maindict.setdefault(weight, []).extend(words)
   157 
   158 
   158 class IDownloadableAdapter(EntityAdapter):
   159 class IDownloadableAdapter(EntityAdapter):
   159     """interface for downloadable entities"""
   160     """interface for downloadable entities"""
       
   161     __needs_bw_compat__ = True
   160     __regid__ = 'IDownloadable'
   162     __regid__ = 'IDownloadable'
   161     __select__ = implements(IDownloadable, warn=False) # XXX for bw compat, else should be abstract
   163     __select__ = implements(IDownloadable, warn=False) # XXX for bw compat, else should be abstract
   162 
   164 
   163     @implements_adapter_compat('IDownloadable')
   165     @implements_adapter_compat('IDownloadable')
   164     def download_url(self, **kwargs): # XXX not really part of this interface
   166     def download_url(self, **kwargs): # XXX not really part of this interface
   206     .. automethod: different_type_children
   208     .. automethod: different_type_children
   207     .. automethod: same_type_children
   209     .. automethod: same_type_children
   208     .. automethod: children_rql
   210     .. automethod: children_rql
   209     .. automethod: path
   211     .. automethod: path
   210     """
   212     """
       
   213     __needs_bw_compat__ = True
   211     __regid__ = 'ITree'
   214     __regid__ = 'ITree'
   212     __select__ = implements(ITree, warn=False) # XXX for bw compat, else should be abstract
   215     __select__ = implements(ITree, warn=False) # XXX for bw compat, else should be abstract
   213 
   216 
   214     child_role = 'subject'
   217     child_role = 'subject'
   215     parent_role = 'object'
   218     parent_role = 'object'
   333         yield self.entity
   336         yield self.entity
   334         for child in self.same_type_children():
   337         for child in self.same_type_children():
   335             for entity in child.cw_adapt_to('ITree').prefixiter(_done):
   338             for entity in child.cw_adapt_to('ITree').prefixiter(_done):
   336                 yield entity
   339                 yield entity
   337 
   340 
       
   341     @implements_adapter_compat('ITree')
   338     @cached
   342     @cached
   339     @implements_adapter_compat('ITree')
       
   340     def path(self):
   343     def path(self):
   341         """Returns the list of eids from the root object to this object."""
   344         """Returns the list of eids from the root object to this object."""
   342         path = []
   345         path = []
   343         adapter = self
   346         adapter = self
   344         entity = adapter.entity
   347         entity = adapter.entity
   364     """something that has a cost, a state and a progression.
   367     """something that has a cost, a state and a progression.
   365 
   368 
   366     You should at least override progress_info an in_progress methods on concret
   369     You should at least override progress_info an in_progress methods on concret
   367     implementations.
   370     implementations.
   368     """
   371     """
       
   372     __needs_bw_compat__ = True
   369     __regid__ = 'IProgress'
   373     __regid__ = 'IProgress'
   370     __select__ = implements(IProgress, warn=False) # XXX for bw compat, should be abstract
   374     __select__ = implements(IProgress, warn=False) # XXX for bw compat, should be abstract
   371 
   375 
   372     @property
   376     @property
   373     @implements_adapter_compat('IProgress')
   377     @implements_adapter_compat('IProgress')
   432     def progress_class(self):
   436     def progress_class(self):
   433         return ''
   437         return ''
   434 
   438 
   435 
   439 
   436 class IMileStoneAdapter(IProgressAdapter):
   440 class IMileStoneAdapter(IProgressAdapter):
       
   441     __needs_bw_compat__ = True
   437     __regid__ = 'IMileStone'
   442     __regid__ = 'IMileStone'
   438     __select__ = implements(IMileStone, warn=False) # XXX for bw compat, should be abstract
   443     __select__ = implements(IMileStone, warn=False) # XXX for bw compat, should be abstract
   439 
   444 
   440     parent_type = None # specify main task's type
   445     parent_type = None # specify main task's type
   441 
   446