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

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

项目: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))
项目: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):
            """Validates a value as a proper Flow object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Flow.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Flow):
                raise TypeError('Property %s must be convertible to a flow '
                                'instance; received: %s.' % (self._name,
                                                             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
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def _validate(self, value):
            """Validates a value as a proper credentials object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Credentials.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Credentials):
                raise TypeError('Property %s must be convertible to a '
                                'credentials instance; received: %s.' %
                                (self._name, 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):
      """Validates a value as a proper Flow object.

      Args:
        value: A value to be set on the property.

      Raises:
        TypeError if the value is not an instance of Flow.
      """
      logger.info('validate: Got type %s', type(value))
      if value is not None and not isinstance(value, Flow):
        raise TypeError('Property %s must be convertible to a flow '
                        'instance; received: %s.' % (self._name, 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
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def _validate(self, value):
      """Validates a value as a proper credentials object.

      Args:
        value: A value to be set on the property.

      Raises:
        TypeError if the value is not an instance of Credentials.
      """
      if value is not None and not isinstance(value, Credentials):
        raise TypeError('Property %s must be convertible to a credentials '
                        'instance; received: %s.' % (self._name, value))
项目: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
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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 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)
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def _validate(self, value):
      """Validates a value as a proper Flow object.

      Args:
        value: A value to be set on the property.

      Raises:
        TypeError if the value is not an instance of Flow.
      """
      logger.info('validate: Got type %s', type(value))
      if value is not None and not isinstance(value, Flow):
        raise TypeError('Property %s must be convertible to a flow '
                        'instance; received: %s.' % (self._name, 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, 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
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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):
      """Validates a value as a proper Flow object.

      Args:
        value: A value to be set on the property.

      Raises:
        TypeError if the value is not an instance of Flow.
      """
      logger.info('validate: Got type %s', type(value))
      if value is not None and not isinstance(value, Flow):
        raise TypeError('Property %s must be convertible to a flow '
                        'instance; received: %s.' % (self._name, 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
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目:start    作者:argeweb    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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):
            """Validates a value as a proper Flow object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Flow.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Flow):
                raise TypeError('Property %s must be convertible to a flow '
                                'instance; received: %s.' % (self._name,
                                                             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
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def _validate(self, value):
            """Validates a value as a proper credentials object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Credentials.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Credentials):
                raise TypeError('Property %s must be convertible to a '
                                'credentials instance; received: %s.' %
                                (self._name, 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):
            """Validates a value as a proper Flow object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Flow.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Flow):
                raise TypeError('Property %s must be convertible to a flow '
                                'instance; received: %s.' % (self._name,
                                                             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
项目:aqua-monitor    作者:Deltares    | 项目源码 | 文件源码
def _validate(self, value):
            """Validates a value as a proper credentials object.

            Args:
                value: A value to be set on the property.

            Raises:
                TypeError if the value is not an instance of Credentials.
            """
            logger.info('validate: Got type %s', type(value))
            if value is not None and not isinstance(value, Credentials):
                raise TypeError('Property %s must be convertible to a '
                                'credentials instance; received: %s.' %
                                (self._name, value))
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def convert(self, model, prop, field_args):
        """
        Returns a form field for a single model property.

        :param model:
            The ``db.Model`` class that contains the property.
        :param prop:
            The model property: a ``db.Property`` instance.
        :param field_args:
            Optional keyword arguments to construct the field.
        """
        prop_type_name = type(prop).__name__
        kwargs = {
            'label': prop.name.replace('_', ' ').title(),
            'default': prop.default_value(),
            'validators': [],
        }
        if field_args:
            kwargs.update(field_args)

        if prop.required and prop_type_name not in self.NO_AUTO_REQUIRED:
            kwargs['validators'].append(validators.required())

        if prop.choices:
            # Use choices in a select field if it was not provided in field_args
            if 'choices' not in kwargs:
                kwargs['choices'] = [(v, v) for v in prop.choices]
            return f.SelectField(**kwargs)
        else:
            converter = self.converters.get(prop_type_name, None)
            if converter is not None:
                return converter(model, prop, kwargs)
项目: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):
      """Validates a value as a proper Flow object.

      Args:
        value: A value to be set on the property.

      Raises:
        TypeError if the value is not an instance of Flow.
      """
      logger.info('validate: Got type %s', type(value))
      if value is not None and not isinstance(value, Flow):
        raise TypeError('Property %s must be convertible to a flow '
                        'instance; received: %s.' % (self._name, value))