[schema] fix yams' add_relation monkeypatching
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 15 Jul 2009 09:45:13 +0200
changeset 2374 ea1a44e4ad62
parent 2322 85a3350e8e4d
child 2381 caad2367d940
[schema] fix yams' add_relation monkeypatching
schema.py
--- a/schema.py	Wed Jul 08 07:46:33 2009 +0200
+++ b/schema.py	Wed Jul 15 09:45:13 2009 +0200
@@ -100,14 +100,14 @@
     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:
+@monkeypatch(ybo.EntityType, methodname='add_relation')
+@classmethod
+def add_relation(cls, rdef, name=None):
+    ybo.add_relation_function(cls, rdef, name)
+    if isinstance(rdef, RichString) and not rdef in cls._defined:
         format_attr_name = (name or rdef.name) + '_format'
-        rdef = self.get_relations(format_attr_name).next()
-        self._ensure_relation_type(rdef)
+        rdef = cls.get_relations(format_attr_name).next()
+        cls._ensure_relation_type(rdef)
 
 def display_name(req, key, form=''):
     """return a internationalized string for the key (schema entity or relation