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


Python db.Property方法代码示例

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


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

示例1: property_clean

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [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

示例2: convert

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [as 别名]
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) 
开发者ID:jpush,项目名称:jbox,代码行数:34,代码来源:db.py

示例3: validate

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [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

示例4: _validate

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [as 别名]
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)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:15,代码来源:appengine.py

示例5: validate

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [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

示例6: validate

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [as 别名]
def validate(self, value):
    if value is not None and not isinstance(value, OAuthCredentials):
      raise BadValueError('Property %s must be convertible '
                          'to an OAuthCredentials instance (%s)' %
                          (self.name, value))
    return super(OAuthCredentialsProperty, self).validate(value) 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:8,代码来源:appengine.py

示例7: validate

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import Property [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.Property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。