(self, callback, method_kw, activate_kw, **kw)
return result_count
This methods is called by the asynchronous engine to index source
    data in sql table

    callback : method to call in activity
    method_kw : callback's parameters
    activate_kw : activity parameters to pass to activate call
    kw : any parameter getAndActivate can required if it calls itself
This methods is called by the asynchronous engine to index source
    data in sql table
This methods is called by the asynchronous engine to index source data in sql table
def getAndIndex(self, callback, method_kw, activate_kw, **kw):
    """
    This methods is called by the asynchronous engine to index source
    data in sql table

    callback : method to call in activity
    method_kw : callback's parameters
    activate_kw : activity parameters to pass to activate call
    kw : any parameter getAndActivate can required if it calls itself
    """
    if kw.has_key("packet_size"):
      search_kw = dict(kw)
      packet_size = search_kw.pop('packet_size', 30)
      limit = packet_size * search_kw.pop('activity_count', 100)
    else:
      # We index everything at once
      limit=None
      packet_size=None
      search_kw={}
    try:
      r_list = self.getDocumentIdList(limit=limit, **search_kw)  # It is assumed that
                                                            # the result is sorted
    except TypeError:
      if not RETRO_COMPATIBLE:
        raise
      else:
        syncml_logger.warning("Script %s does not accept paramaters limit=%s kw=%s",
                              self.getListMethodId(), limit, search_kw)
        r_list = self.getDocumentList()  # It is assumed that
                                    # the result is sorted
    result_count = len(r_list)
    if result_count:
      r = [str(x.path) for x in r_list]
      if not limit:
        # We do not split in activity so call the callback right now
        syncml_logger.info("getAndIndex : got %d result and no limit, calling callback...",
                           result_count)
        callback_method = getattr(self, callback)
        callback_method(path_list=r[:],
                        activate_kw=activate_kw,
                        **method_kw)
      else:
        syncml_logger.info("getAndIndex : got %d, %r result, limit = %r, packet %r",
                           result_count, r, limit, packet_size)
        generated_other_activity = False
        if result_count == limit:
          # Recursive call to prevent too many activity generation
          next_kw = dict(activate_kw, priority=1+activate_kw.get('priority', 1))
          kw["min_id"] = r_list[-1].getId()
          syncml_logger.info("--> calling getAndIndex in activity, min = %s",
                             kw["min_id"])
          self.activate(**next_kw).getAndIndex(
            callback, method_kw, activate_kw, **kw)
          generated_other_activity = True

        activate = self.activate
        callback_method = getattr(activate(**activate_kw), callback)
        if generated_other_activity:
          for i in xrange(0, result_count, packet_size):
            syncml_logger.info("-- getAndIndex : recursive call, generating for %s",
                               r[i:i+packet_size])
            callback_method(path_list=r[i:i+packet_size],
                            activate_kw=activate_kw,
                            **method_kw)
        else:
          if result_count > packet_size and limit:
            for i in xrange(0, result_count-packet_size, packet_size):
              syncml_logger.info("-- getAndIndex : i %s, call, generating for %s : %s",
                                 i, r[i:i+packet_size], activate_kw)
              callback_method(path_list=r[i:i+packet_size],
                              **method_kw)
            final_min = i +  packet_size
          else:
            final_min = 0
          syncml_logger.info("---- getAndIndex : final call for %s %s : %s",
                             final_min, r[final_min:], activate_kw)
          callback_method(path_list=r[final_min:],
                          activate_kw=activate_kw,
                          **method_kw)
    return result_count
def getAndIndex ( self , callback , method_kw , activate_kw , * * kw ) : if kw . has_key ( "packet_size" ) : search_kw = dict ( kw ) packet_size = search_kw . pop ( 'packet_size' , 30 ) limit = packet_size * search_kw . pop ( 'activity_count' , 100 ) else : # We index everything at once limit = None packet_size = None search_kw = { } try : r_list = self . getDocumentIdList ( limit = limit , * * search_kw ) # It is assumed that # the result is sorted except TypeError : if not RETRO_COMPATIBLE : raise else : syncml_logger . warning ( "Script %s does not accept paramaters limit=%s kw=%s" , self . getListMethodId ( ) , limit , search_kw ) r_list = self . getDocumentList ( ) # It is assumed that # the result is sorted result_count = len ( r_list ) if result_count : r = [ str ( x . path ) for x in r_list ] if not limit : # We do not split in activity so call the callback right now syncml_logger . info ( "getAndIndex : got %d result and no limit, calling callback..." , result_count ) callback_method = getattr ( self , callback ) callback_method ( path_list = r [ : ] , activate_kw = activate_kw , * * method_kw ) else : syncml_logger . info ( "getAndIndex : got %d, %r result, limit = %r, packet %r" , result_count , r , limit , packet_size ) generated_other_activity = False if result_count == limit : # Recursive call to prevent too many activity generation next_kw = dict ( activate_kw , priority = 1 + activate_kw . get ( 'priority' , 1 ) ) kw [ "min_id" ] = r_list [ - 1 ] . getId ( ) syncml_logger . info ( "--> calling getAndIndex in activity, min = %s" , kw [ "min_id" ] ) self . activate ( * * next_kw ) . getAndIndex ( callback , method_kw , activate_kw , * * kw ) generated_other_activity = True activate = self . activate callback_method = getattr ( activate ( * * activate_kw ) , callback ) if generated_other_activity : for i in xrange ( 0 , result_count , packet_size ) : syncml_logger . info ( "-- getAndIndex : recursive call, generating for %s" , r [ i : i + packet_size ] ) callback_method ( path_list = r [ i : i + packet_size ] , activate_kw = activate_kw , * * method_kw ) else : if result_count > packet_size and limit : for i in xrange ( 0 , result_count - packet_size , packet_size ) : syncml_logger . info ( "-- getAndIndex : i %s, call, generating for %s : %s" , i , r [ i : i + packet_size ] , activate_kw ) callback_method ( path_list = r [ i : i + packet_size ] , * * method_kw ) final_min = i + packet_size else : final_min = 0 syncml_logger . info ( "---- getAndIndex : final call for %s %s : %s" , final_min , r [ final_min : ] , activate_kw ) callback_method ( path_list = r [ final_min : ] , activate_kw = activate_kw , * * method_kw ) return result_count