Python google.appengine.ext.db 模块,BadValueError() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用google.appengine.ext.db.BadValueError()

项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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))
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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)
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
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)
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
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)
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:Tinychat-Bot--Discontinued    作者:Tinychat    | 项目源码 | 文件源码
def test_behaviour(self):
        """
        Test the behaviour of the Google SDK not handling ints gracefully
        """
        with self.assertRaises(db.BadValueError):
            setattr(self.f, 'f', 3)

        self.f.f = 3.0

        self.assertEqual(self.f.f, 3.0)
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
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)
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, client.Credentials):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a Credentials instance ({1})'.format(self.name, value))
        return value
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
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)
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
def test_validate(self):
        appengine.FlowProperty().validate(None)
        with self.assertRaises(db.BadValueError):
            appengine.FlowProperty().validate(42)
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
def test_validate(self):
        appengine.CredentialsProperty().validate(self.credentials)
        appengine.CredentialsProperty().validate(None)
        with self.assertRaises(db.BadValueError):
            appengine.CredentialsProperty().validate(42)
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
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)
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, client.Credentials):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a Credentials instance ({1})'.format(self.name, value))
        return value
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
def validate(self, value):
            value = super(GAEDecimalProperty, self).validate(value)
            if value is None or isinstance(value, decimal.Decimal):
                return value
            elif isinstance(value, basestring):
                return decimal.Decimal(value)
            raise gae.BadValueError("Property %s must be a Decimal or string."\
                                        % self.name)

###################################################################################
# class that handles connection pooling (all adapters are derived from this one)
###################################################################################
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def test_validate(self):
        appengine.FlowProperty().validate(None)
        with self.assertRaises(db.BadValueError):
            appengine.FlowProperty().validate(42)
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def test_validate(self):
        appengine.CredentialsProperty().validate(self.credentials)
        appengine.CredentialsProperty().validate(None)
        with self.assertRaises(db.BadValueError):
            appengine.CredentialsProperty().validate(42)
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
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)
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, client.Credentials):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a Credentials instance ({1})'.format(self.name, value))
        return value
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
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)
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def validate(self, value):
        if isinstance(value, basestring):
            value = self.make_value_from_datastore(value)
        if not isinstance(value, self.model):
            raise db.BadValueError('Value must be of type %s' %
                                   self.model.__name__)
        if self.validator is not None:
            self.validator(value)
        return value
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def validate(self, value):
        new_value = []
        for item in value:
            if isinstance(item, basestring):
                item = self.make_value_from_datastore([item])[0]
            if not isinstance(item, self.model):
                raise db.BadValueError('Value must be of type %s' %
                                       self.model.__name__)
            new_value.append(item)
        if self.validator is not None:
            self.validator(new_value)
        return new_value
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def validate(self, value):
        new_value = []
        for item in value:
            if isinstance(item, basestring):
                item = db.Key(item)
            if isinstance(item, self.reference_class):
                item = item.key()
            if not isinstance(item, db.Key):
                raise db.BadValueError('Value must be a key or of type %s' %
                                       self.reference_class.__name__)
            new_value.append(item)
        return super(KeyListProperty, self).validate(new_value)
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
        if value is not None and not isinstance(value, Flow):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a FlowThreeLegged instance ({1})'.format(self.name, value))
        return super(FlowProperty, self).validate(value)
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a Credentials instance ({1})'.format(self.name, value))
        return value
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
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)
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
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)
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:aqua-monitor    作者:Deltares    | 项目源码 | 文件源码
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)
项目:aqua-monitor    作者:Deltares    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
        if value is not None and not isinstance(value, Flow):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a FlowThreeLegged instance ({1})'.format(self.name, value))
        return super(FlowProperty, self).validate(value)
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError(
                'Property {0} must be convertible '
                'to a Credentials instance ({1})'.format(self.name, value))
        return value
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
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)
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:Chromium_DepotTools    作者:p07r0457    | 项目源码 | 文件源码
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)
项目:Chromium_DepotTools    作者:p07r0457    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
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)
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
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)
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:alfredToday    作者:jeeftor    | 项目源码 | 文件源码
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)
项目:alfredToday    作者:jeeftor    | 项目源码 | 文件源码
def validate(self, value):
        value = super(CredentialsProperty, self).validate(value)
        logger.info("validate: Got type " + str(type(value)))
        if value is not None and not isinstance(value, Credentials):
            raise db.BadValueError('Property %s must be convertible '
                                   'to a Credentials instance (%s)' %
                                   (self.name, value))
        return value
项目:node-gn    作者:Shouqun    | 项目源码 | 文件源码
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)
项目:node-gn    作者:Shouqun    | 项目源码 | 文件源码
def validate(self, value):
    value = super(CredentialsProperty, self).validate(value)
    logger.info("validate: Got type " + str(type(value)))
    if value is not None and not isinstance(value, Credentials):
      raise db.BadValueError('Property %s must be convertible '
                          'to a Credentials instance (%s)' %
                            (self.name, value))
    #if value is not None and not isinstance(value, Credentials):
    #  return None
    return value
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def clean(self, value):
    """Override Field.clean() to do reference-specific value cleaning.

    This turns a non-empty value into a model instance.
    """

    value = super(ModelChoiceField, self).clean(value)
    if not value:
      return None
    instance = db.get(value)
    if instance is None:
      raise db.BadValueError(self.error_messages['invalid_choice'])
    return instance
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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())



      try:
        properties[prop].validate(val)
      except db.BadValueError, e:
        raise errors.BadReaderParamsError(e)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
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)