def set_validate ( self ):
        self.is_mapped  = False
        self.has_items  = False
        self.reversable = True
        post_setattrs   = []
        mapped_handlers = []
        validates       = []
        fast_validates  = []
        slow_validates  = []

        for handler in self.handlers:
            fv = getattr( handler, 'fast_validate', None )
            if fv is not None:
                validates.append( handler.validate )
                if fv[0] == 7:
                    # If this is a nested complex fast validator, expand its
                    # contents and adds its list to our list:
                    fast_validates.extend( fv[1] )
                else:
                    # Else just add the entire validator to the list:
                    fast_validates.append( fv )
            else:
                slow_validates.append( handler.validate )

            post_setattr = getattr( handler, 'post_setattr', None )
            if post_setattr is not None:
                post_setattrs.append( post_setattr )

            if handler.is_mapped:
                self.is_mapped = True
                mapped_handlers.append( handler )
            else:
                self.reversable = False

            if handler.has_items:
                self.has_items = True

        self.validates      = validates
        self.slow_validates = slow_validates

        if self.is_mapped:
            self.mapped_handlers = mapped_handlers
        elif hasattr( self, 'mapped_handlers' ):
            del self.mapped_handlers

        # If there are any fast validators, then we create a 'complex' fast
        # validator that composites them:
        if len( fast_validates ) > 0:
            # If there are any 'slow' validators, add a special handler at
            # the end of the fast validator list to handle them:
            if len( slow_validates ) > 0:
                fast_validates.append( ( 8, self ) )
            # Create the 'complex' fast validator:
            self.fast_validate = ( 7, tuple( fast_validates ) )
        elif hasattr( self, 'fast_validate' ):
            del self.fast_validate

        if len( post_setattrs ) > 0:
            self.post_setattrs = post_setattrs
            self.post_setattr  = self._post_setattr
        elif hasattr( self, 'post_setattr' ):
            del self.post_setattr
dataset/ETHPy150Open enthought/traits/traits/trait_handlers.py/TraitCompound.set_validate/original