vregistry.py
branchtls-sprint
changeset 943 9fdfa8d38359
parent 835 7dcb11dd443e
child 946 a130b5ceeca9
equal deleted inserted replaced
941:7574822b0d03 943:9fdfa8d38359
   124         return '%s.%s' % (cls.__module__, cls.__name__)
   124         return '%s.%s' % (cls.__module__, cls.__name__)
   125 
   125 
   126     # XXX bw compat code
   126     # XXX bw compat code
   127     @classmethod
   127     @classmethod
   128     def build___select__(cls):
   128     def build___select__(cls):
   129         classdict = cls.__dict__
   129         for klass in cls.mro():
   130         if ('__select__' in classdict and '__selectors__' in classdict
   130             if klass.__name__ == 'AppRsetObject':
   131             and not '__selgenerated__' in classdict):
   131                 continue # the bw compat __selector__ is there
   132             raise TypeError("__select__ and __selectors__ can't be used together on class %s" % cls)
   132             klassdict = klass.__dict__
   133         if '__selectors__' in classdict:
   133             if ('__select__' in klassdict and '__selectors__' in klassdict
   134             cls.__selgenerated__ = True
   134                 and '__selgenerated__' not in klassdict):
   135             # case where __selectors__ is defined locally (but __select__
   135                 raise TypeError("__select__ and __selectors__ can't be used together on class %s" % cls)
   136             # is in a parent class)
   136             if '__selectors__' in klassdict and '__selgenerated__' not in klassdict:
   137             selectors = classdict['__selectors__']
   137                 cls.__selgenerated__ = True
   138             if len(selectors) == 1:
   138                 # case where __selectors__ is defined locally (but __select__
   139                 # micro optimization: don't bother with AndSelector if there's
   139                 # is in a parent class)
   140                 # only one selector
   140                 selectors = klassdict['__selectors__']
   141                 select = _instantiate_selector(selectors[0])
   141                 if len(selectors) == 1:
   142             else:
   142                     # micro optimization: don't bother with AndSelector if there's
   143                 select = AndSelector(*selectors)
   143                     # only one selector
   144             cls.__select__ = select
   144                     select = _instantiate_selector(selectors[0])
       
   145                 else:
       
   146                     select = AndSelector(*selectors)
       
   147                 cls.__select__ = select
   145 
   148 
   146 
   149 
   147 class VRegistry(object):
   150 class VRegistry(object):
   148     """class responsible to register, propose and select the various
   151     """class responsible to register, propose and select the various
   149     elements used to build the web interface. Currently, we have templates,
   152     elements used to build the web interface. Currently, we have templates,