server/hook.py
branchstable
changeset 6834 b4befa12bbcc
parent 6831 0801dae5bba2
child 6880 4be32427b2b9
equal deleted inserted replaced
6833:8fe4b003c1bc 6834:b4befa12bbcc
   371             return 0
   371             return 0
   372         return 1
   372         return 1
   373 
   373 
   374 
   374 
   375 class match_rtype_sets(ExpectedValueSelector):
   375 class match_rtype_sets(ExpectedValueSelector):
   376     """accept if parameters specified as initializer arguments are specified
   376     """accept if the relation type is in one of the sets given as initializer
   377     in named arguments given to the selector
   377     argument. The goal of this selector is that it keeps reference to original sets,
       
   378     so modification to thoses sets are considered by the selector. For instance
       
   379 
       
   380     MYSET = set()
       
   381 
       
   382     class Hook1(Hook):
       
   383         __regid__ = 'hook1'
       
   384         __select__ = Hook.__select__ & match_rtype_sets(MYSET)
       
   385         ...
       
   386 
       
   387     class Hook2(Hook):
       
   388         __regid__ = 'hook2'
       
   389         __select__ = Hook.__select__ & match_rtype_sets(MYSET)
       
   390 
       
   391     Client code can now change `MYSET`, this will changes the selection criteria
       
   392     of :class:`Hook1` and :class:`Hook1`.
   378     """
   393     """
   379 
   394 
   380     def __init__(self, *expected):
   395     def __init__(self, *expected):
   381         self.expected = expected
   396         self.expected = expected
   382 
   397