parameters: (self, method_id, method_args=(), method_kw={},
                           restricted=False, id_list=None, min_id=None, **kw)
docstring: Run a script by activity on objects found recursively from this folder
  
      This method is configurable (via activate_kw['group_*'] & 'activity_count'
      parameters) so that it can work efficiently with databases of any size.
  
      'activate_kw' may specify an active process to collect results.
  
      In order to activate objects that don't inherit ActiveObject,
      only placeless default activate parameters are taken into account.
docstring_summary: Run a script by activity on objects found recursively from this folder
docstring_tokens: Run a script by activity on objects found recursively from this folder
function: def _recurseCallMethod(self, method_id, method_args=(), method_kw={},
                           restricted=False, id_list=None, min_id=None, **kw):
      """Run a script by activity on objects found recursively from this folder
  
      This method is configurable (via activate_kw['group_*'] & 'activity_count'
      parameters) so that it can work efficiently with databases of any size.
  
      'activate_kw' may specify an active process to collect results.
  
      In order to activate objects that don't inherit ActiveObject,
      only placeless default activate parameters are taken into account.
      """
      hook_raised = ExceptionRaised()
      my_getattr = guarded_getattr if restricted else getattr
      activate = self.getPortalObject().portal_activities.activateObject
      validate = restricted and getSecurityManager().validate
      activity_count = kw.get('activity_count', 1000)
      if activity_count is None:
        check_limit = lambda: None
      else:
        check_limit = iter(xrange(activity_count)).next
      try:
        recurse_stack = kw['_recurse_stack']
      except KeyError:
        recurse_stack = [deque(id_list) if id_list else min_id or '']
        kw['_recurse_stack'] = recurse_stack
        # We are called by user (and not in a subsequent activity).
        # Complete activate_kw, without mutating received value.
        activate_kw = self.getDefaultActivateParameterDict.im_func(None)
        activate_kw.update(kw.get('activate_kw', ()))
        activate_kw.setdefault('active_process', None)
        activate_kw.setdefault('activity', 'SQLQueue')
        cost = activate_kw.setdefault('group_method_cost', .034) # 30 objects
        if cost != 1:
          activate_kw.setdefault('group_method_id', None) # dummy group method
        kw['activate_kw'] = activate_kw
      else:
        activate_kw = kw['activate_kw']
      min_depth = kw.get('min_depth', 0)
      max_depth = kw.get('max_depth', 0)
      get_activate_kw_method_id = kw.get('get_activate_kw_method_id')
      if get_activate_kw_method_id is None:
        getActivateKw = lambda document, activate_kw: activate_kw
        recurse_activate_kw = activate_kw
      else:
        getActivateKw = hook_raised(my_getattr(self, get_activate_kw_method_id))
        # Isolate caller-accessible mutable activate_kw from the on we need to
        # re-invoke ourselves. Doing it once only should be sufficient (and saves a
        # dict copy on each iteration) as all the values we care about (set above
        # in this script) are immutable. Anything else is already under the control
        # of caller, either via arguments or via default activate parameter dict.
        recurse_activate_kw = activate_kw.copy()
      skip_method_id = kw.get('skip_method_id')
      if skip_method_id is None:
        skip = lambda document: False
      else:
        skip = hook_raised(my_getattr(self, skip_method_id))
      def recurse(container, depth):
        if getattr(aq_base(container), 'getPhysicalPath', None) is None or skip(container):
          return
        if (max_depth is None or depth < max_depth) and \
           isinstance(container, ObjectManager) and len(container):
          try:
            next_id = recurse_stack[depth]
          except IndexError:
            next_id = ''
            recurse_stack.append(next_id)
          if isinstance(next_id, basestring):
            folder_handler = isinstance(container, Folder) and \
                            container._folder_handler
            if not folder_handler:
              next_id = deque(x for x in container.objectIds() if x >= next_id)
              recurse_stack[depth] = next_id
            else:
              for id, ob in container.iteritems(next_id):
                if not restricted or validate(container, container, id, ob):
                  recurse_stack[depth] = id
                  recurse(ob, depth + 1)
              recurse_stack[-1] = next_id = None
          while next_id:
            id = next_id[0]
            ob = container._getOb(id)
            if not restricted or validate(container, container, id, ob):
              recurse(ob, depth + 1)
            del next_id[0]
        if min_depth <= depth:
          check_limit()
          getattr(activate(container, **getActivateKw(container, recurse_activate_kw)),
                  method_id)(*method_args, **method_kw)
        del recurse_stack[depth:]
      try:
        recurse(self, 0)
      except StopIteration:
        if hook_raised:
          raise
        reactivate_kw = activate_kw.copy()
        reactivate_kw['group_method_id'] = reactivate_kw['group_id'] = '' # no grouping
        reactivate_kw['activity'] = 'SQLQueue'
        activate(self, **reactivate_kw)._recurseCallMethod(
          method_id, method_args, method_kw, restricted=restricted, **kw)
function_tokens: def _recurseCallMethod ( self , method_id , method_args = ( ) , method_kw = { } , restricted = False , id_list = None , min_id = None , * * kw ) : hook_raised = ExceptionRaised ( ) my_getattr = guarded_getattr if restricted else getattr activate = self . getPortalObject ( ) . portal_activities . activateObject validate = restricted and getSecurityManager ( ) . validate activity_count = kw . get ( 'activity_count' , 1000 ) if activity_count is None : check_limit = lambda : None else : check_limit = iter ( xrange ( activity_count ) ) . next try : recurse_stack = kw [ '_recurse_stack' ] except KeyError : recurse_stack = [ deque ( id_list ) if id_list else min_id or '' ] kw [ '_recurse_stack' ] = recurse_stack # We are called by user (and not in a subsequent activity). # Complete activate_kw, without mutating received value. activate_kw = self . getDefaultActivateParameterDict . im_func ( None ) activate_kw . update ( kw . get ( 'activate_kw' , ( ) ) ) activate_kw . setdefault ( 'active_process' , None ) activate_kw . setdefault ( 'activity' , 'SQLQueue' ) cost = activate_kw . setdefault ( 'group_method_cost' , .034 ) # 30 objects if cost != 1 : activate_kw . setdefault ( 'group_method_id' , None ) # dummy group method kw [ 'activate_kw' ] = activate_kw else : activate_kw = kw [ 'activate_kw' ] min_depth = kw . get ( 'min_depth' , 0 ) max_depth = kw . get ( 'max_depth' , 0 ) get_activate_kw_method_id = kw . get ( 'get_activate_kw_method_id' ) if get_activate_kw_method_id is None : getActivateKw = lambda document , activate_kw : activate_kw recurse_activate_kw = activate_kw else : getActivateKw = hook_raised ( my_getattr ( self , get_activate_kw_method_id ) ) # Isolate caller-accessible mutable activate_kw from the on we need to # re-invoke ourselves. Doing it once only should be sufficient (and saves a # dict copy on each iteration) as all the values we care about (set above # in this script) are immutable. Anything else is already under the control # of caller, either via arguments or via default activate parameter dict. recurse_activate_kw = activate_kw . copy ( ) skip_method_id = kw . get ( 'skip_method_id' ) if skip_method_id is None : skip = lambda document : False else : skip = hook_raised ( my_getattr ( self , skip_method_id ) ) def recurse ( container , depth ) : if getattr ( aq_base ( container ) , 'getPhysicalPath' , None ) is None or skip ( container ) : return if ( max_depth is None or depth < max_depth ) and isinstance ( container , ObjectManager ) and len ( container ) : try : next_id = recurse_stack [ depth ] except IndexError : next_id = '' recurse_stack . append ( next_id ) if isinstance ( next_id , basestring ) : folder_handler = isinstance ( container , Folder ) and container . _folder_handler if not folder_handler : next_id = deque ( x for x in container . objectIds ( ) if x >= next_id ) recurse_stack [ depth ] = next_id else : for id , ob in container . iteritems ( next_id ) : if not restricted or validate ( container , container , id , ob ) : recurse_stack [ depth ] = id recurse ( ob , depth + 1 ) recurse_stack [ - 1 ] = next_id = None while next_id : id = next_id [ 0 ] ob = container . _getOb ( id ) if not restricted or validate ( container , container , id , ob ) : recurse ( ob , depth + 1 ) del next_id [ 0 ] if min_depth <= depth : check_limit ( ) getattr ( activate ( container , * * getActivateKw ( container , recurse_activate_kw ) ) , method_id ) ( * method_args , * * method_kw ) del recurse_stack [ depth : ] try : recurse ( self , 0 ) except StopIteration : if hook_raised : raise reactivate_kw = activate_kw . copy ( ) reactivate_kw [ 'group_method_id' ] = reactivate_kw [ 'group_id' ] = '' # no grouping reactivate_kw [ 'activity' ] = 'SQLQueue' activate ( self , * * reactivate_kw ) . _recurseCallMethod ( method_id , method_args , method_kw , restricted = restricted , * * kw )