[selectors] avoid spurious warning when using implements by design
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 05 Jul 2010 19:06:17 +0200
changeset 5895 6a3f776292a5
parent 5894 7510cc3bbdbb
child 5896 67683b7e591a
[selectors] avoid spurious warning when using implements by design
entities/adapters.py
hooks/test/unittest_hooks.py
mixins.py
selectors.py
web/views/calendar.py
web/views/embedding.py
web/views/igeocodable.py
web/views/isioc.py
web/views/navigation.py
web/views/old_calendar.py
--- a/entities/adapters.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/entities/adapters.py	Mon Jul 05 19:06:17 2010 +0200
@@ -156,7 +156,7 @@
 class IDownloadableAdapter(EntityAdapter):
     """interface for downloadable entities"""
     __regid__ = 'IDownloadable'
-    __select__ = implements(IDownloadable) # XXX for bw compat, else should be abstract
+    __select__ = implements(IDownloadable, warn=False) # XXX for bw compat, else should be abstract
 
     @implements_adapter_compat('IDownloadable')
     def download_url(self): # XXX not really part of this interface
@@ -186,7 +186,7 @@
     benefit from this default implementation
     """
     __regid__ = 'ITree'
-    __select__ = implements(ITree) # XXX for bw compat, else should be abstract
+    __select__ = implements(ITree, warn=False) # XXX for bw compat, else should be abstract
 
     child_role = 'subject'
     parent_role = 'object'
@@ -343,7 +343,7 @@
     implementations.
     """
     __regid__ = 'IProgress'
-    __select__ = implements(IProgress) # XXX for bw compat, should be abstract
+    __select__ = implements(IProgress, warn=False) # XXX for bw compat, should be abstract
 
     @property
     @implements_adapter_compat('IProgress')
@@ -411,7 +411,7 @@
 
 class IMileStoneAdapter(IProgressAdapter):
     __regid__ = 'IMileStone'
-    __select__ = implements(IMileStone) # XXX for bw compat, should be abstract
+    __select__ = implements(IMileStone, warn=False) # XXX for bw compat, should be abstract
 
     parent_type = None # specify main task's type
 
--- a/hooks/test/unittest_hooks.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/hooks/test/unittest_hooks.py	Mon Jul 05 19:06:17 2010 +0200
@@ -114,13 +114,10 @@
         self.assertEquals(rset.get_entity(0, 0).reverse_parts[0].messageid, '<2345>')
 
     def test_unsatisfied_constraints(self):
-        releid = self.execute('INSERT CWRelation X: X from_entity FE, X relation_type RT, X to_entity TE '
-                              'WHERE FE name "CWUser", RT name "in_group", TE name "String"')[0][0]
-        self.execute('SET X read_permission Y WHERE X eid %(x)s, Y name "managers"',
-                     {'x': releid}, 'x')
+        releid = self.execute('SET U in_group G WHERE G name "owners", U login "admin"')[0][0]
         ex = self.assertRaises(ValidationError, self.commit)
         self.assertEquals(ex.errors,
-                          {'to_entity-object': 'RQLConstraint O final FALSE failed'})
+                          {'in_group-object': u'RQLConstraint NOT O name "owners" failed'})
 
     def test_html_tidy_hook(self):
         req = self.request()
--- a/mixins.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/mixins.py	Mon Jul 05 19:06:17 2010 +0200
@@ -208,7 +208,7 @@
     __deprecation_warning__ = '[3.9] TreeViewMixIn is deprecated, use/override BaseTreeView instead'
 
     __regid__ = 'tree'
-    __select__ = implements(ITree)
+    __select__ = implements(ITree, warn=False)
     item_vid = 'treeitem'
 
     def call(self, done=None, **kwargs):
--- a/selectors.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/selectors.py	Mon Jul 05 19:06:17 2010 +0200
@@ -675,10 +675,12 @@
     """
 
     def __init__(self, *expected_ifaces, **kwargs):
+        emit_warn = kwargs.pop('warn', True)
         super(implements, self).__init__(**kwargs)
         self.expected_ifaces = expected_ifaces
-        warn('[3.9] implements selector is deprecated, use either is_instance '
-             'or adaptable', DeprecationWarning, stacklevel=2)
+        if emit_warn:
+            warn('[3.9] implements selector is deprecated, use either '
+                 'is_instance or adaptable', DeprecationWarning, stacklevel=2)
 
     def __str__(self):
         return '%s(%s)' % (self.__class__.__name__,
--- a/web/views/calendar.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/calendar.py	Mon Jul 05 19:06:17 2010 +0200
@@ -32,7 +32,7 @@
 
 class ICalendarableAdapter(EntityAdapter):
     __regid__ = 'ICalendarable'
-    __select__ = implements(ICalendarable) # XXX for bw compat, should be abstract
+    __select__ = implements(ICalendarable, warn=False) # XXX for bw compat, should be abstract
 
     @property
     @implements_adapter_compat('ICalendarable')
--- a/web/views/embedding.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/embedding.py	Mon Jul 05 19:06:17 2010 +0200
@@ -41,7 +41,7 @@
 class IEmbedableAdapter(EntityAdapter):
     """interface for embedable entities"""
     __regid__ = 'IEmbedable'
-    __select__ = implements(IEmbedable) # XXX for bw compat, should be abstract
+    __select__ = implements(IEmbedable, warn=False) # XXX for bw compat, should be abstract
 
     @implements_adapter_compat('IEmbedable')
     def embeded_url(self):
--- a/web/views/igeocodable.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/igeocodable.py	Mon Jul 05 19:06:17 2010 +0200
@@ -27,7 +27,7 @@
 class IGeocodableAdapter(EntityAdapter):
     """interface required by geocoding views such as gmap-view"""
     __regid__ = 'IGeocodable'
-    __select__ = implements(IGeocodable) # XXX for bw compat, should be abstract
+    __select__ = implements(IGeocodable, warn=False) # XXX for bw compat, should be abstract
 
     @property
     @implements_adapter_compat('IGeocodable')
--- a/web/views/isioc.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/isioc.py	Mon Jul 05 19:06:17 2010 +0200
@@ -32,7 +32,7 @@
 class ISIOCItemAdapter(EntityAdapter):
     """interface for entities which may be represented as an ISIOC items"""
     __regid__ = 'ISIOCItem'
-    __select__ = implements(ISiocItem) # XXX for bw compat, should be abstract
+    __select__ = implements(ISiocItem, warn=False) # XXX for bw compat, should be abstract
 
     @implements_adapter_compat('ISIOCItem')
     def isioc_content(self):
@@ -63,7 +63,7 @@
 class ISIOCContainerAdapter(EntityAdapter):
     """interface for entities which may be represented as an ISIOC container"""
     __regid__ = 'ISIOCContainer'
-    __select__ = implements(ISiocContainer) # XXX for bw compat, should be abstract
+    __select__ = implements(ISiocContainer, warn=False) # XXX for bw compat, should be abstract
 
     @implements_adapter_compat('ISIOCContainer')
     def isioc_type(self):
--- a/web/views/navigation.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/navigation.py	Mon Jul 05 19:06:17 2010 +0200
@@ -188,7 +188,7 @@
     entity
     """
     __regid__ = 'IPrevNext'
-    __select__ = implements(IPrevNext) # XXX for bw compat, else should be abstract
+    __select__ = implements(IPrevNext, warn=False) # XXX for bw compat, else should be abstract
 
     @implements_adapter_compat('IPrevNext')
     def next_entity(self):
--- a/web/views/old_calendar.py	Mon Jul 05 19:05:56 2010 +0200
+++ b/web/views/old_calendar.py	Mon Jul 05 19:06:17 2010 +0200
@@ -30,7 +30,7 @@
 class ICalendarViewsAdapter(EntityAdapter):
     """calendar views interface"""
     __regid__ = 'ICalendarViews'
-    __select__ = implements(ICalendarViews) # XXX for bw compat, should be abstract
+    __select__ = implements(ICalendarViews, warn=False) # XXX for bw compat, should be abstract
 
     @implements_adapter_compat('ICalendarViews')
     def matching_dates(self, begin, end):