當前位置: 首頁>>代碼示例>>Python>>正文


Python db.BadValueError方法代碼示例

本文整理匯總了Python中google.appengine.ext.db.BadValueError方法的典型用法代碼示例。如果您正苦於以下問題:Python db.BadValueError方法的具體用法?Python db.BadValueError怎麽用?Python db.BadValueError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在google.appengine.ext.db的用法示例。


在下文中一共展示了db.BadValueError方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update_test_keys

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def update_test_keys(key, test_keys):
  """Deferred task handler for ensuring TestMeta stays in sync.
  Args:
    key: Test key.
    test_keys: A list of strings, the test_key values for each test.
  """
  test = Test.get_mem(key)
  dirty = False
  for test_key in test_keys:
    if not test_key in test.test_keys:
      test.test_keys.append(test_key)
      dirty = True
  if dirty:
    try:
      test.save_memcache()
    except db.BadValueError:
      logging.info('db.BadValueError - bail.') 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:19,代碼來源:user_test.py

示例2: _validate_filters_ndb

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def _validate_filters_ndb(cls, filters, model_class):
    """Validate ndb.Model filters."""
    if not filters:
      return

    properties = model_class._properties

    for f in filters:
      prop, _, val = f
      if prop not in properties:
        raise errors.BadReaderParamsError(
            "Property %s is not defined for entity type %s",
            prop, model_class._get_kind())

      # Validate the value of each filter. We need to know filters have
      # valid value to carry out splits.
      try:
        properties[prop]._do_validate(val)
      except db.BadValueError, e:
        raise errors.BadReaderParamsError(e) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:22,代碼來源:input_readers.py

示例3: property_clean

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def property_clean(prop, value):
  """Apply Property level validation to value.

  Calls .make_value_from_form() and .validate() on the property and catches
  exceptions generated by either.  The exceptions are converted to
  forms.ValidationError exceptions.

  Args:
    prop: The property to validate against.
    value: The value to validate.

  Raises:
    forms.ValidationError if the value cannot be validated.
  """
  if value is not None:
    try:



      prop.validate(prop.make_value_from_form(value))
    except (db.BadValueError, ValueError), e:
      raise forms.ValidationError(unicode(e)) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:24,代碼來源:djangoforms.py

示例4: _validate_filters_ndb

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def _validate_filters_ndb(cls, filters, model_class):
    """Validate ndb.Model filters."""
    if not filters:
      return

    properties = model_class._properties

    for f in filters:
      prop, _, val = f
      if prop not in properties:
        raise errors.BadReaderParamsError(
            "Property %s is not defined for entity type %s",
            prop, model_class._get_kind())



      try:
        properties[prop]._do_validate(val)
      except db.BadValueError, e:
        raise errors.BadReaderParamsError(e) 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:22,代碼來源:model_datastore_input_reader.py

示例5: _validate_filters

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def _validate_filters(cls, filters, model_class):
    """Validate user supplied filters.

    Validate filters are on existing properties and filter values
    have valid semantics.

    Args:
      filters: user supplied filters. Each filter should be a list or tuple of
        format (<property_name_as_str>, <query_operator_as_str>,
        <value_of_certain_type>). Value type is up to the property's type.
      model_class: the db.Model class for the entity type to apply filters on.

    Raises:
      BadReaderParamsError: if any filter is invalid in any way.
    """
    if not filters:
      return

    properties = model_class.properties()

    for f in filters:
      prop, _, val = f
      if prop not in properties:
        raise errors.BadReaderParamsError(
            "Property %s is not defined for entity type %s",
            prop, model_class.kind())

      # Validate the value of each filter. We need to know filters have
      # valid value to carry out splits.
      try:
        properties[prop].validate(val)
      except db.BadValueError, e:
        raise errors.BadReaderParamsError(e) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:35,代碼來源:input_readers.py

示例6: validate

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def validate(self, value):
    if value is not None and not isinstance(value, Flow):
      raise db.BadValueError('Property %s must be convertible '
                          'to a FlowThreeLegged instance (%s)' %
                          (self.name, value))
    return super(FlowProperty, self).validate(value) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:8,代碼來源:appengine.py

示例7: validate

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def validate(self, value):
        if value is not None and not isinstance(value, Flow):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a FlowThreeLegged instance (%s)' %
                                   (self.name, value))
        return super(FlowProperty, self).validate(value) 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:8,代碼來源:appengine.py

示例8: validate

# 需要導入模塊: from google.appengine.ext import db [as 別名]
# 或者: from google.appengine.ext.db import BadValueError [as 別名]
def validate(self, value):
        if value is not None and not isinstance(value, client.Flow):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a FlowThreeLegged instance ({1})'.format(self.name, value))
        return super(FlowProperty, self).validate(value) 
開發者ID:fniephaus,項目名稱:alfred-gmail,代碼行數:8,代碼來源:appengine.py


注:本文中的google.appengine.ext.db.BadValueError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。