code: def generateUniqueId(context, **kw):
      
  
      # get the config for this portal type from the system setup
      config = get_config(context, **kw)
  
      # get the variables map for later string interpolation
      variables = get_variables(context, **kw)
  
      # The new generate sequence number
      number = 0
  
      # get the sequence type from the global config
      sequence_type = config.get("sequence_type", "generated")
  
      # Sequence Type is "Counter", so we use the length of the backreferences or
      # contained objects of the evaluated "context" defined in the config
      if sequence_type in ["counter"]:
          number = get_counted_number(context, config, variables, **kw)
  
      # Sequence Type is "Generated", so the ID is constructed according to the
      # configured split length
      if sequence_type in ["generated"]:
          number = get_generated_number(context, config, variables, **kw)
  
      # store the new sequence number to the variables map for str interpolation
      if isinstance(number, Alphanumber):
          variables["alpha"] = number
      variables["seq"] = to_int(number)
  
      # The ID formatting template from user config, e.g. {sampleId}-R{seq:02d}
      id_template = config.get("form", "")
  
      # Interpolate the ID template
      try:
          new_id = id_template.format(**variables)
      except KeyError, e:
          logger.error('KeyError: {} not in id_template {}'.format(
              e, id_template))
          raise
      normalized_id = api.normalize_filename(new_id)
      logger.info("generateUniqueId: {}".format(normalized_id))
  
      return normalized_id
docs: Generate pretty content IDs.