improve __selectors__() so that it always return a tuple tls-sprint
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 17 Feb 2009 23:45:51 +0100
branchtls-sprint
changeset 726 88a74f590986
parent 725 2f3e6afabdb5
child 727 30fe8f5afbd8
improve __selectors__() so that it always return a tuple
appobject.py
--- a/appobject.py	Tue Feb 17 23:44:58 2009 +0100
+++ b/appobject.py	Tue Feb 17 23:45:51 2009 +0100
@@ -19,7 +19,7 @@
 from rql.stmts import Union, Select
 
 from cubicweb import Unauthorized
-from cubicweb.vregistry import VObject
+from cubicweb.vregistry import VObject, AndSelector
 from cubicweb.selectors import yes
 from cubicweb.utils import UStringIO, ustrftime
 
@@ -102,9 +102,12 @@
     @classproperty
     @obsolete('use __select__ and & or | operators')
     def __selectors__(cls):
-        if isinstance(self.__select__, AndSelector):
-            return self.__select__.selectors
-        return self.__select__
+        selector = cls.__select__
+        if isinstance(selector, AndSelector):
+            return selector.selectors
+        if not isinstance(selector, tuple):
+            selector = (selector,)
+        return selector
     
     @classmethod
     def __init__(self, req=None, rset=None):