当前位置: 首页>>代码示例>>Python>>正文


Python datastore_errors.BadArgumentError方法代码示例

本文整理汇总了Python中google.appengine.api.datastore_errors.BadArgumentError方法的典型用法代码示例。如果您正苦于以下问题:Python datastore_errors.BadArgumentError方法的具体用法?Python datastore_errors.BadArgumentError怎么用?Python datastore_errors.BadArgumentError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.api.datastore_errors的用法示例。


在下文中一共展示了datastore_errors.BadArgumentError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: NormalizeAndTypeCheckKeys

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def NormalizeAndTypeCheckKeys(keys):
  """Normalizes and type checks that the given argument is a valid key or keys.

  A wrapper around NormalizeAndTypeCheck() that accepts strings, Keys, and
  Entities, and normalizes to Keys.

  Args:
    keys: a Key or sequence of Keys

  Returns:
    A (list of Keys, bool) tuple. See NormalizeAndTypeCheck.

  Raises:
    BadArgumentError: arg is not an instance or sequence of one of the given
    types.
  """
  keys, multiple = NormalizeAndTypeCheck(keys, (basestring, Entity, Key))

  keys = [_GetCompleteKeyOrError(key) for key in keys]

  return (keys, multiple) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:23,代码来源:datastore.py

示例2: Ancestor

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def Ancestor(self, ancestor):
    """Sets an ancestor for this query.

    This restricts the query to only return result entities that are descended
    from a given entity. In other words, all of the results will have the
    ancestor as their parent, or parent's parent, or etc.

    Raises BadArgumentError or BadKeyError if parent is not an existing Entity
    or Key in the datastore.

    Args:
      # the key must be complete
      ancestor: Entity or Key

    Returns:
      # this query
      Query
    """
    self.__ancestor_pb = _GetCompleteKeyOrError(ancestor)._ToPb()
    return self 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:22,代码来源:datastore.py

示例3: GetBatcher

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def GetBatcher(self, config=None):
    """Runs this query and returns a datastore_query.Batcher.

    This is not intended to be used by application developers. Use Get()
    instead!

    Args:
      config: Optional Configuration to use for this request.

    Returns:
      # an iterator that provides access to the query results
      Iterator
    """



    query_options = self.GetQueryOptions().merge(config)
    if self.__distinct and query_options.projection != self.__group_by:




      raise datastore_errors.BadArgumentError(
          'cannot override projection when distinct is set')
    return self.GetQuery().run(_GetConnection(), query_options) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:27,代码来源:datastore.py

示例4: AllocateIdsAsync

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def AllocateIdsAsync(model_key, size=None, **kwargs):
  """Asynchronously allocates a range of IDs.

  Identical to datastore.AllocateIds() except returns an asynchronous object.
  Call get_result() on the return value to block on the call and get the
  results.
  """
  max = kwargs.pop('max', None)
  config = _GetConfigFromKwargs(kwargs)
  if getattr(config, 'read_policy', None) == EVENTUAL_CONSISTENCY:
    raise datastore_errors.BadRequestError(
        'read_policy is only supported on read operations.')
  keys, _ = NormalizeAndTypeCheckKeys(model_key)

  if len(keys) > 1:
    raise datastore_errors.BadArgumentError(
        'Cannot allocate IDs for more than one model key at a time')

  rpc = _GetConnection().async_allocate_ids(config, keys[0], size, max)
  return rpc 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:22,代码来源:datastore.py

示例5: __init__

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def __init__(self, bound_queries, orderings):
    if len(bound_queries) > MAX_ALLOWABLE_QUERIES:
      raise datastore_errors.BadArgumentError(
          'Cannot satisfy query -- too many subqueries (max: %d, got %d).'
          ' Probable cause: too many IN/!= filters in query.' %
          (MAX_ALLOWABLE_QUERIES, len(bound_queries)))

    projection = (bound_queries and
                  bound_queries[0].GetQueryOptions().projection)

    for query in bound_queries:
      if projection != query.GetQueryOptions().projection:
        raise datastore_errors.BadQueryError(
            'All queries must have the same projection.')
      if query.IsKeysOnly():
        raise datastore_errors.BadQueryError(
            'MultiQuery does not support keys_only.')

    self.__projection = projection
    self.__bound_queries = bound_queries
    self.__orderings = orderings
    self.__compile = False 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:24,代码来源:datastore.py

示例6: ResolveAppId

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def ResolveAppId(app):
  """Validate app id, providing a default.

  If the argument is None, $APPLICATION_ID is substituted.

  Args:
    app: The app id argument value to be validated.

  Returns:
    The value of app, or the substituted default.  Always a non-empty string.

  Raises:
    BadArgumentError if the value is empty or not a string.
  """
  if app is None:
    app = os.environ.get('APPLICATION_ID', '')
  ValidateString(app, 'app', datastore_errors.BadArgumentError)
  return app 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:datastore_types.py

示例7: ResolveNamespace

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def ResolveNamespace(namespace):
  """Validate app namespace, providing a default.

  If the argument is None, namespace_manager.get_namespace() is substituted.

  Args:
    namespace: The namespace argument value to be validated.

  Returns:
    The value of namespace, or the substituted default. The empty string is used
    to denote the empty namespace.

  Raises:
    BadArgumentError if the value is not a string.
  """
  if namespace is None:
    namespace = namespace_manager.get_namespace()
  else:
    namespace_manager.validate_namespace(
        namespace, datastore_errors.BadArgumentError)
  return namespace 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:23,代码来源:datastore_types.py

示例8: _FromPb

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def _FromPb(pb):
    """Static factory method. Creates a Key from an entity_pb.Reference.

    Not intended to be used by application developers. Enforced by hiding the
    entity_pb classes.

    Args:
      pb: entity_pb.Reference
    """
    if not isinstance(pb, entity_pb.Reference):
      raise datastore_errors.BadArgumentError(
        'Key constructor takes an entity_pb.Reference; received %s (a %s).' %
        (pb, typename(pb)))

    key = Key()
    key.__reference = entity_pb.Reference()
    key.__reference.CopyFrom(pb)
    return key 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:datastore_types.py

示例9: __new__

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def __new__(cls, *configs):
    obj = super(BaseConfiguration, cls).__new__(cls)
    obj._configs = configs


    obj._options = {}
    for config in configs:
      for name, option in config._options.iteritems():
        if name in obj._options:
          if option is not obj._options[name]:
            error = ("merge conflict on '%s' from '%s' and '%s'" %
                     (name, option._cls.__name__,
                      obj._options[name]._cls.__name__))
            raise datastore_errors.BadArgumentError(error)
        obj._options[name] = option

    obj._values = {}
    for config in reversed(configs):
      for name, value in config._values.iteritems():
        obj._values[name] = value

    return obj 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:24,代码来源:datastore_rpc.py

示例10: max_entity_groups_per_rpc

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def max_entity_groups_per_rpc(value):
    """The maximum number of entity groups that can be represented in one rpc.

    For a non-transactional operation that involves more entity groups than the
    maximum, the operation will be performed by executing multiple, asynchronous
    rpcs to the datastore, each of which has no more entity groups represented
    than the maximum.  So, if a put() operation has 8 entity groups and the
    maximum is 3, we will send 3 rpcs, 2 with 3 entity groups and 1 with 2
    entity groups.  This is a performance optimization - in many cases
    multiple, small, concurrent rpcs will finish faster than a single large
    rpc.  The optimal value for this property will be application-specific, so
    experimentation is encouraged.
    """
    if not (isinstance(value, (int, long)) and value > 0):
      raise datastore_errors.BadArgumentError(
          'max_entity_groups_per_rpc should be a positive integer')
    return value 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:19,代码来源:datastore_rpc.py

示例11: propagation

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def propagation(value):
    """How existing transactions should be handled.

    One of NESTED, MANDATORY, ALLOWED, INDEPENDENT. The interpertation of
    these types is up to higher level run-in-transaction implementations.

    WARNING: Using anything other than NESTED for the propagation flag
    can have strange consequences.  When using ALLOWED or MANDATORY, if
    an exception is raised, the transaction is likely not safe to
    commit.  When using INDEPENDENT it is not generally safe to return
    values read to the caller (as they were not read in the caller's
    transaction).

    Raises: datastore_errors.BadArgumentError if value is not reconized.
    """
    if value not in TransactionOptions._PROPAGATION:
      raise datastore_errors.BadArgumentError('Unknown propagation value (%r)' %
                                              (value,))
    return value 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:datastore_rpc.py

示例12: PopulateQueryResult

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def PopulateQueryResult(self, result, count, deprecated_offset,
                          compile=False, first_result=False):
    """Populates a QueryResult with this cursor and the given number of results.

    Args:
      result: datastore_pb.QueryResult
      count: integer of how many results to return, or None if not specified
      deprecated_offset: integer of how many results to skip, deprecated.
      compile: boolean, whether we are compiling this query
      first_result: whether the query result is the first for this query

    Raises:
      datastore_errors.BadArgumentError: if the offset doesn't match the
      original offset from the RunQuery call.
    """
    if count is None:
      count = self.__persisted_count
    if (deprecated_offset is not None
        and self.__persisted_offset != deprecated_offset):
      raise datastore_errors.BadArgumentError(
          'Invalid offset provided. Got %d expected %d.'
          % (deprecated_offset, self.__persisted_offset))
    self._PopulateQueryResult(result, count, self.__persisted_offset,
                              compile, first_result)
    self.__persisted_offset -= result.skipped_results() 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:27,代码来源:datastore_stub_util.py

示例13: ToScatteredId

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def ToScatteredId(v):
  """Map counter value v to the scattered ID space.

  Translate to scattered ID space, then reverse bits.

  Args:
    v: Counter value from which to produce ID.

  Returns:
    Integer ID.

  Raises:
    datastore_errors.BadArgumentError if counter value exceeds the range of
  the scattered ID space.
  """
  if v >= _MAX_SCATTERED_COUNTER:
    raise datastore_errors.BadArgumentError('counter value too large (%d)' % v)
  return _MAX_SEQUENTIAL_ID + 1 + long(ReverseBitsInt64(v << _SCATTER_SHIFT)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:datastore_stub_util.py

示例14: IdToCounter

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def IdToCounter(k):
  """Map ID k to the counter value from which it was generated.

  Determine whether k is sequential or scattered ID.

  Args:
    k: ID from which to infer counter value.

  Returns:
    Tuple of integers (counter_value, id_space).
  """
  if k > _MAX_SCATTERED_ID:
    return 0, SCATTERED
  elif k > _MAX_SEQUENTIAL_ID and k <= _MAX_SCATTERED_ID:
    return long(ReverseBitsInt64(k) >> _SCATTER_SHIFT), SCATTERED
  elif k > 0:
    return long(k), SEQUENTIAL
  else:
    raise datastore_errors.BadArgumentError('invalid id (%d)' % k) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:datastore_stub_util.py

示例15: _to_pb_v1

# 需要导入模块: from google.appengine.api import datastore_errors [as 别名]
# 或者: from google.appengine.api.datastore_errors import BadArgumentError [as 别名]
def _to_pb_v1(self, adapter):
    """Returns a googledatastore.Filter.

    Args:
      adapter: A datastore_rpc.AbstractAdapter
    """
    if not self._filters:
      return None
    if len(self._filters) == 1:
      return self._filters[0]._to_pb_v1(adapter)

    pb = googledatastore.Filter()
    comp_pb = pb.composite_filter
    if self.op == self.AND:
      comp_pb.op = googledatastore.CompositeFilter.AND
    else:
      raise datastore_errors.BadArgumentError(
          'Datastore V4 only supports CompositeFilter with AND operator.')
    for f in self._filters:
      comp_pb.filters.add().CopyFrom(f._to_pb_v1(adapter))
    return pb 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:23,代码来源:datastore_query.py


注:本文中的google.appengine.api.datastore_errors.BadArgumentError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。