vregistry.py
changeset 615 38bc11ac845b
parent 355 89ad20af9e4c
child 623 9dc7b3fa59f1
child 630 66ff0b2f7d03
child 1592 80e0ef472ec3
equal deleted inserted replaced
614:b1ea90dc7408 615:38bc11ac845b
    18   a vobject class has been found, an instance of this class is
    18   a vobject class has been found, an instance of this class is
    19   returned. The selector is instantiated at vobject registration
    19   returned. The selector is instantiated at vobject registration
    20 
    20 
    21 
    21 
    22 :organization: Logilab
    22 :organization: Logilab
    23 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
    23 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
    24 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
    24 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
    25 """
    25 """
    26 __docformat__ = "restructuredtext en"
    26 __docformat__ = "restructuredtext en"
    27 
    27 
    28 import sys
    28 import sys
   103         if '__select__' in classdict and '__selectors__' in classdict:
   103         if '__select__' in classdict and '__selectors__' in classdict:
   104             raise TypeError("__select__ and __selectors__ "
   104             raise TypeError("__select__ and __selectors__ "
   105                             "can't be used together")
   105                             "can't be used together")
   106         if '__select__' not in classdict and '__selectors__' in classdict:
   106         if '__select__' not in classdict and '__selectors__' in classdict:
   107             selectors = classdict['__selectors__']
   107             selectors = classdict['__selectors__']
   108             classdict['__select__'] = classmethod(chainall(*selectors))
   108             if len(selectors) > 1:
       
   109                 classdict['__select__'] = classmethod(chainall(*selectors))
       
   110             else:
       
   111                 classdict['__select__'] = classmethod(selectors[0])
   109         return super(autoselectors, mcs).__new__(mcs, name, bases, classdict)
   112         return super(autoselectors, mcs).__new__(mcs, name, bases, classdict)
   110 
   113 
   111     def __setattr__(self, attr, value):
   114     def __setattr__(self, attr, value):
   112         if attr == '__selectors__':
   115         if attr == '__selectors__':
   113             self.__select__ = classmethod(chainall(*value))
   116             self.__select__ = classmethod(chainall(*value))