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


Python compat.string_types方法代码示例

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


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

示例1: __init__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __init__(self, label=None, validators=None, query_factory=None,
                 get_pk=None, get_label=None, allow_blank=False,
                 blank_text='', **kwargs):
        super(QuerySelectField, self).__init__(label, validators, **kwargs)
        self.query_factory = query_factory

        if get_pk is None:
            if not has_identity_key:
                raise Exception('The sqlalchemy identity_key function could not be imported.')
            self.get_pk = get_pk_from_identity
        else:
            self.get_pk = get_pk

        if get_label is None:
            self.get_label = lambda x: x
        elif isinstance(get_label, string_types):
            self.get_label = operator.attrgetter(get_label)
        else:
            self.get_label = get_label

        self.allow_blank = allow_blank
        self.blank_text = blank_text
        self.query = None
        self._object_list = None 
开发者ID:snverse,项目名称:Sci-Finder,代码行数:26,代码来源:fields.py

示例2: __init__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __init__(self, label=None, validators=None, reference_class=None,
                 get_label=None, allow_blank=False,
                 blank_text='', **kwargs):
        super(ReferencePropertyField, self).__init__(label, validators,
                                                     **kwargs)
        if get_label is None:
            self.get_label = lambda x: x
        elif isinstance(get_label, string_types):
            self.get_label = operator.attrgetter(get_label)
        else:
            self.get_label = get_label

        self.allow_blank = allow_blank
        self.blank_text = blank_text
        self._set_data(None)
        if reference_class is not None:
            self.query = reference_class.all() 
开发者ID:snverse,项目名称:Sci-Finder,代码行数:19,代码来源:fields.py

示例3: __call__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __call__(self, form, field):
        if isinstance(field.data, Model):
            return
        if isinstance(field.data, string_types) and UUID_REGEXP.search(field.data):
            try:
                obj = self.model.get(uuid=field.data)
            except self.model.DoesNotExist:
                raise ValidationError(self.message)
            field.data = obj
            return
        try:
            obj = self.model.get(id=field.data)
        except self.model.DoesNotExist:
            raise ValidationError(self.message)
        field.data = obj
        return 
开发者ID:dracarysX,项目名称:flask_restapi,代码行数:18,代码来源:validators.py

示例4: __init__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __init__(self, label=None, validators=None, reference_class=None,
                 label_attr=None, get_label=None, allow_blank=False,
                 blank_text='', **kwargs):
        super(ReferencePropertyField, self).__init__(label, validators,
                                                     **kwargs)
        if label_attr is not None:
            warnings.warn('label_attr= will be removed in WTForms 1.1, use get_label= instead.', DeprecationWarning)
            self.get_label = operator.attrgetter(label_attr)
        elif get_label is None:
            self.get_label = lambda x: x
        elif isinstance(get_label, string_types):
            self.get_label = operator.attrgetter(get_label)
        else:
            self.get_label = get_label

        self.allow_blank = allow_blank
        self.blank_text = blank_text
        self._set_data(None)
        if reference_class is not None:
            self.query = reference_class.all() 
开发者ID:RoseOu,项目名称:flasky,代码行数:22,代码来源:fields.py

示例5: __call__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __call__(self, form, field):
        empty_form = True

        for formfield in form:
            has_raw_data = hasattr(formfield, 'raw_data')

            is_empty = has_raw_data and len(formfield.raw_data) == 0
            is_blank = has_raw_data and len(formfield.raw_data) >= 1 \
                and isinstance(formfield.raw_data[0], string_types) and not formfield.raw_data[0]

            # By default we'll receive empty arrays for values not posted, so need to allow empty lists
            empty_field = True if is_empty else is_blank

            empty_form &= empty_field

        if empty_form:
            raise validators.StopValidation() 
开发者ID:ONSdigital,项目名称:eq-survey-runner,代码行数:19,代码来源:validators.py

示例6: __call__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __call__(self, form, field):
        if not field.raw_data or isinstance(field.raw_data[0], string_types) and not self.string_check(field.raw_data[0]):
            field.errors[:] = []
            raise StopValidation() 
开发者ID:snverse,项目名称:Sci-Finder,代码行数:6,代码来源:validators.py

示例7: __init__

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def __init__(self, regex, flags=0, message=None):
        if isinstance(regex, string_types):
            regex = re.compile(regex, flags)
        self.regex = regex
        self.message = message 
开发者ID:snverse,项目名称:Sci-Finder,代码行数:7,代码来源:validators.py

示例8: convert_KeyProperty

# 需要导入模块: from wtforms import compat [as 别名]
# 或者: from wtforms.compat import string_types [as 别名]
def convert_KeyProperty(self, model, prop, kwargs):
        """Returns a form field for a ``ndb.KeyProperty``."""
        if 'reference_class' not in kwargs:
            try:
                reference_class = prop._kind
            except AttributeError:
                reference_class = prop._reference_class

            if isinstance(reference_class, string_types):
                # reference class is a string, try to retrieve the model object.
                mod = __import__(model.__module__, None, None, [reference_class], 0)
                reference_class = getattr(mod, reference_class)
            kwargs['reference_class'] = reference_class
        kwargs.setdefault('allow_blank', not prop._required)
        return KeyPropertyField(**kwargs) 
开发者ID:snverse,项目名称:Sci-Finder,代码行数:17,代码来源:ndb.py


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