--- a/schema.py Mon Jun 29 14:12:18 2009 +0200
+++ b/schema.py Thu Jul 02 10:35:03 2009 +0200
@@ -14,6 +14,7 @@
from warnings import warn
from logilab.common.decorators import cached, clear_cache, monkeypatch
+from logilab.common.deprecation import obsolete
from logilab.common.compat import any
from yams import BadSchemaDefinition, buildobjs as ybo
@@ -97,6 +98,16 @@
yams_add_relation(relations, format_attrdef, name+'_format', insertidx)
yams_add_relation(relations, rdef, name, insertidx)
+
+yams_EntityType_add_relation = ybo.EntityType.add_relation
+@monkeypatch(ybo.EntityType)
+def add_relation(self, rdef, name=None):
+ yams_EntityType_add_relation(self, rdef, name)
+ if isinstance(rdef, RichString) and not rdef in self._defined:
+ format_attr_name = (name or rdef.name) + '_format'
+ rdef = self.get_relations(format_attr_name).next()
+ self._ensure_relation_type(rdef)
+
def display_name(req, key, form=''):
"""return a internationalized string for the key (schema entity or relation
name) in a given form
@@ -109,7 +120,7 @@
# ensure unicode
# added .lower() in case no translation are available
return unicode(req._(key)).lower()
-__builtins__['display_name'] = display_name
+__builtins__['display_name'] = obsolete('display_name should be imported from cubicweb.schema')(display_name)
def ERSchema_display_name(self, req, form=''):
"""return a internationalized string for the entity/relation type name in