--- a/mixins.py Thu May 20 20:47:13 2010 +0200
+++ b/mixins.py Thu May 20 20:47:55 2010 +0200
@@ -21,9 +21,10 @@
from itertools import chain
from logilab.common.decorators import cached
+from logilab.common.deprecation import deprecated, class_deprecated
from cubicweb.selectors import implements
-from cubicweb.interfaces import IEmailable, ITree
+from cubicweb.interfaces import ITree
class TreeMixIn(object):
@@ -33,6 +34,9 @@
tree_attribute, parent_target and children_target class attribute to
benefit from this default implementation
"""
+ __metaclass__ = class_deprecated
+ __deprecation_warning__ = '[3.9] TreeMixIn is deprecated, use/override ITreeAdapter instead'
+
tree_attribute = None
# XXX misnamed
parent_target = 'subject'
@@ -117,16 +121,6 @@
return chain([self], _uptoroot(self))
return _uptoroot(self)
- def notification_references(self, view):
- """used to control References field of email send on notification
- for this entity. `view` is the notification view.
-
- Should return a list of eids which can be used to generate message ids
- of previously sent email
- """
- return self.path()[:-1]
-
-
## ITree interface ########################################################
def parent(self):
"""return the parent entity if any, else None (e.g. if we are on the
@@ -171,8 +165,7 @@
NOTE: The default implementation is based on the
primary_email / use_email scheme
"""
- __implements__ = (IEmailable,)
-
+ @deprecated("[3.9] use entity.cw_adapt_to('IEmailable').get_email()")
def get_email(self):
if getattr(self, 'primary_email', None):
return self.primary_email[0].address
@@ -180,28 +173,6 @@
return self.use_email[0].address
return None
- @classmethod
- def allowed_massmail_keys(cls):
- """returns a set of allowed email substitution keys
-
- The default is to return the entity's attribute list but an
- entity class might override this method to allow extra keys.
- For instance, the Person class might want to return a `companyname`
- key.
- """
- return set(rschema.type
- for rschema, attrtype in cls.e_schema.attribute_definitions()
- if attrtype.type not in ('Password', 'Bytes'))
-
- def as_email_context(self):
- """returns the dictionary as used by the sendmail controller to
- build email bodies.
-
- NOTE: the dictionary keys should match the list returned by the
- `allowed_massmail_keys` method.
- """
- return dict( (attr, getattr(self, attr)) for attr in self.allowed_massmail_keys() )
-
"""pluggable mixins system: plug classes registered in MI_REL_TRIGGERS on entity
classes which have the relation described by the dict's key.
@@ -216,26 +187,14 @@
-def _done_init(done, view, row, col):
- """handle an infinite recursion safety belt"""
- if done is None:
- done = set()
- entity = view.cw_rset.get_entity(row, col)
- if entity.eid in done:
- msg = entity._cw._('loop in %(rel)s relation (%(eid)s)') % {
- 'rel': entity.tree_attribute,
- 'eid': entity.eid
- }
- return None, msg
- done.add(entity.eid)
- return done, entity
-
-
class TreeViewMixIn(object):
"""a recursive tree view"""
+ __metaclass__ = class_deprecated
+ __deprecation_warning__ = '[3.9] TreeViewMixIn is deprecated, use/override BaseTreeView instead'
+
__regid__ = 'tree'
+ __select__ = implements(ITree)
item_vid = 'treeitem'
- __select__ = implements(ITree)
def call(self, done=None, **kwargs):
if done is None:
@@ -262,6 +221,8 @@
class TreePathMixIn(object):
"""a recursive path view"""
+ __metaclass__ = class_deprecated
+ __deprecation_warning__ = '[3.9] TreePathMixIn is deprecated, use/override TreePathView instead'
__regid__ = 'path'
item_vid = 'oneline'
separator = u' > '
@@ -286,6 +247,8 @@
class ProgressMixIn(object):
"""provide a default implementations for IProgress interface methods"""
+ __metaclass__ = class_deprecated
+ __deprecation_warning__ = '[3.9] ProgressMixIn is deprecated, use/override IProgressAdapter instead'
@property
def cost(self):