@gen.coroutine
def AllocateIds(client, obj_store, user_id, device_id, request):
  """Allocates an asset id for the current device.  The request should include the asset id prefix
  for the requested type.  Currently, only comment, activity and operation ids are supported.
  """
  prefixes = request['asset_types']
  timestamp = util.GetCurrentTimestamp()

  def ValidateId(prefix):
    """Validate a single requested Id"""
    if not IdPrefix.IsValid(prefix):
      raise InvalidRequestError(UNSUPPORTED_ASSET_TYPE, asset_type=prefix)

    # Among valid prefixes, only Activity, Comment and Operation are supported.
    if not 'acop' in prefix:
      raise InvalidRequestError(UNSUPPORTED_ASSET_TYPE, asset_type=IdPrefix.GetAssetName(prefix))

  def ConstructId(prefix, uniquifier):
    if prefix == 'a':
      asset_id = Activity.ConstructActivityId(timestamp, device_id, uniquifier)
    elif prefix == 'c':
      asset_id = Comment.ConstructCommentId(timestamp, device_id, uniquifier)
    elif prefix == 'p':
      asset_id = Photo.ConstructPhotoId(timestamp, device_id, uniquifier)
    else:
      asset_id = Operation.ConstructOperationId(device_id, uniquifier)

    return asset_id

  for prefix in prefixes:
    ValidateId(prefix)

  # AllocateAssetIds returns a unique, increasing number which can be used as a unique component of asset ids.
  unique_start = yield gen.Task(User.AllocateAssetIds, client, user_id, len(prefixes))

  asset_ids = [ConstructId(p, u) for p, u in zip(prefixes, range(unique_start, unique_start + len(prefixes)))]
  raise gen.Return({'asset_ids': asset_ids, 'timestamp': timestamp})
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/service.py/AllocateIds/swapped operands of `in`