port to cw 3.9
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Sun, 01 Aug 2010 22:15:12 +0200
changeset 113 45a0bff67d7e
parent 112 a24428726e54
child 114 0df3c717f5eb
port to cw 3.9
entities.py
sobjects.py
views.py
--- a/entities.py	Mon Jul 05 13:33:55 2010 +0200
+++ b/entities.py	Sun Aug 01 22:15:12 2010 +0200
@@ -11,12 +11,17 @@
 from cubicweb.mixins import MI_REL_TRIGGERS, TreeMixIn
 from cubicweb.entities import AnyEntity, fetch_config
 from cubicweb.interfaces import ITree
-
+from cubicweb.view import EntityAdapter
+from cubicweb.selectors import is_instance
 
 class Classification(AnyEntity):
     __regid__ = 'Classification'
     fetch_attrs, fetch_order = fetch_config(['name'])
-    __implements__ = AnyEntity.__implements__ + (ITree,)
+
+
+class ClassificationITreeAdapter(EntityAdapter):
+    __regid__ = 'ITree'
+    __select__ = is_instance('Classification')
 
     def root(self):
         """returns the root object"""
@@ -32,11 +37,11 @@
 
     def children(self, entities=True):
         """returns the item's children"""
-        return self.related('included_in', 'object', entities=entities)
+        return self.entity.related('included_in', 'object', entities=entities)
 
     def children_rql(self):
         """XXX returns RQL to get children"""
-        return self.related_rql('included_in', 'object')
+        return self.entity.related_rql('included_in', 'object')
 
     def is_leaf(self):
         """returns true if this node as no child"""
--- a/sobjects.py	Mon Jul 05 13:33:55 2010 +0200
+++ b/sobjects.py	Sun Aug 01 22:15:12 2010 +0200
@@ -8,12 +8,12 @@
 
 from logilab.common.decorators import cached
 
-from cubicweb.selectors import implements
+from cubicweb.selectors import is_instance
 from cubicweb.sobjects.notification import NotificationView
 
 
 class KeywordNotificationView(NotificationView):
-    __select__ = implements('Keyword')
+    __select__ = is_instance('Keyword')
     msgid_timestamp = True
 
     def recipients(self):
--- a/views.py	Mon Jul 05 13:33:55 2010 +0200
+++ b/views.py	Sun Aug 01 22:15:12 2010 +0200
@@ -10,7 +10,7 @@
 from logilab.mtconverter import xml_escape
 
 from cubicweb import Unauthorized
-from cubicweb.selectors import implements, rql_condition, relation_possible
+from cubicweb.selectors import is_instance, rql_condition, relation_possible
 from cubicweb.view import EntityView
 from cubicweb.mixins import TreePathMixIn
 from cubicweb.web import stdmsgs, uicfg, component, facet
@@ -32,7 +32,7 @@
 # classification views ########################################################
 
 class ClassificationPrimaryView(primary.PrimaryView):
-    __select__ = implements('Classification')
+    __select__ = is_instance('Classification')
 
     def render_entity_attributes(self, entity):
         pass
@@ -47,7 +47,7 @@
 # keyword views ###############################################################
 
 class KeywordPrimaryView(primary.PrimaryView):
-    __select__ = implements('Keyword')
+    __select__ = is_instance('Keyword')
 
     def cell_call(self, row, col, **kwargs):
         entity = self.cw_rset.get_entity(row, col)
@@ -60,7 +60,7 @@
 class KeywordComboBoxView(TreePathMixIn, EntityView):
     """display keyword in edition's combobox"""
     __regid__ = 'combobox'
-    __select__ = implements('Keyword', 'Classification')
+    __select__ = is_instance('Keyword', 'Classification')
 
     item_vid = 'text'
     separator = u' > '
@@ -83,7 +83,7 @@
     __regid__ = 'skos'
     content_type = 'application/xml'
     templatable = False
-    __select__ = implements('Keyword', 'Classification')
+    __select__ = is_instance('Keyword', 'Classification')
 
     def call(self, **kwargs):
         self.w(SKOS_OPENING_ROOT)
@@ -97,7 +97,7 @@
 class SkosItemView(EntityView):
     __regid__ = 'skositemview'
     content_type = 'application/xml'
-    __select__ = implements('Keyword', 'Classification')
+    __select__ = is_instance('Keyword', 'Classification')
 
     def cell_call(self, row, col, show_parent=True, stop=False):
         w = self.w