當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。