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


Python colander.null方法代码示例

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


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

示例1: contact_invariant

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def contact_invariant(self, appstruct):
        appstruct_copy = appstruct.copy()
        appstruct_copy.pop('surtax')
        if 'title' in appstruct_copy:
            appstruct_copy.pop('title')

        if not any(v != "" and v != colander.null
                   for v in list(appstruct_copy.values())):
            raise colander.Invalid(self,
                                   _('One value must be entered.'))

        if 'phone' in appstruct and appstruct['phone'] and \
            ('surtax' not in appstruct or \
             'surtax' in appstruct and not appstruct['surtax']):
            raise colander.Invalid(self,
                                   _('Surcharge field must be filled in.')) 
开发者ID:ecreall,项目名称:nova-ideo,代码行数:18,代码来源:core_schema.py

示例2: convert_type

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def convert_type(self, schema_node):

        converted = {
            'type': self.type
        }

        if schema_node.title:
            converted['title'] = schema_node.title
        if schema_node.description:
            converted['description'] = schema_node.description
        if schema_node.default is not colander.null:
            converted['default'] = schema_node.default
        if 'example' in schema_node.__dict__:
            converted['example'] = schema_node.example

        return converted 
开发者ID:Cornices,项目名称:cornice.ext.swagger,代码行数:18,代码来源:schema.py

示例3: serialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def serialize(self, node, appstruct):
        if appstruct is colander.null:
            return colander.null
        if not isinstance(appstruct, User):
            raise colander.Invalid(node, '%r is not a instance of User' % appstruct)

        return appstruct.name 
开发者ID:Akagi201,项目名称:learning-python,代码行数:9,代码来源:views.py

示例4: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, node, cstruct):
        if cstruct is colander.null:
            return colander.null
        if not isinstance(cstruct, basestring):
            raise colander.Invalid(node, '%r is not a valid username' % cstruct)
        user = DBSession.query(User).filter_by(name=cstruct).first()
        if not user:
            raise colander.Invalid(node, 'User with name %r does not exist' % cstruct)

        return user 
开发者ID:Akagi201,项目名称:learning-python,代码行数:12,代码来源:views.py

示例5: prepare_name

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def prepare_name(name):
    """ Convert a given value to a name. """
    if name is None or name is null:
        return ''
    return unicode(name).strip() 
开发者ID:openspending,项目名称:spendb,代码行数:7,代码来源:common.py

示例6: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, node, cstruct):
        if cstruct is null:
            return null
        value = self.decode(cstruct)
        if value is None:
            raise Invalid(node, 'Missing')
        return value 
开发者ID:openspending,项目名称:spendb,代码行数:9,代码来源:common.py

示例7: serialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def serialize(self, node, appstruct):
        if appstruct is colander.null:
            return colander.null
        impl = colander.Mapping()
        if isinstance(appstruct, str):
            impl = StringSchema()
        return impl.serialize(node, appstruct) 
开发者ID:eosnewyork,项目名称:eospy,代码行数:9,代码来源:schema.py

示例8: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, node, cstruct):
        if not cstruct:
            return colander.null
        try:
            result = parse_date(cstruct)
        except:
            raise colander.Invalid(
                node,
                _(
                    self.err_template,
                    mapping={'val': cstruct}
                )
            )
        return result 
开发者ID:mazvv,项目名称:travelcrm,代码行数:16,代码来源:__init__.py

示例9: serialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def serialize(self, node, appstruct):
        if appstruct is colander.null:
            return colander.null
        return appstruct 
开发者ID:mazvv,项目名称:travelcrm,代码行数:6,代码来源:__init__.py

示例10: contact_invariant

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def contact_invariant(self, appstruct):
        can_add_keywords = appstruct.get('can_add_keywords', 'false')
        can_add_keywords = False if can_add_keywords == 'false' else True
        keywords = appstruct.get('keywords', colander.null)
        if not can_add_keywords and keywords is colander.null:
            raise colander.Invalid(
                self, _('You must enter at least one keyword.')) 
开发者ID:ecreall,项目名称:nova-ideo,代码行数:9,代码来源:site_configuration.py

示例11: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, field, pstruct):
        result = super(FilesWidget, self).deserialize(field, pstruct)
        return [f for f in result if f is not null] 
开发者ID:ecreall,项目名称:nova-ideo,代码行数:5,代码来源:widget.py

示例12: serialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def serialize(self, field, cstruct, **kw):
        if cstruct is null:
            cstruct = ''
        elif isinstance(cstruct, dict):
            cstruct = cstruct.get('icon_class')+','+cstruct.get('icon')
        return super(BootstrapIconInputWidget, self).serialize(
                                                  field, cstruct, **kw) 
开发者ID:ecreall,项目名称:nova-ideo,代码行数:9,代码来源:widget.py

示例13: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, cstruct=colander.null):
        return cstruct 
开发者ID:Cornices,项目名称:cornice.ext.swagger,代码行数:4,代码来源:support.py

示例14: deserialize

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def deserialize(self, node, cstruct):
        if cstruct is col.null:
            return col.null
        cat = M.TroveCategory.query.get(fullpath=cstruct)
        if not cat:
            cat = M.TroveCategory.query.get(fullname=cstruct)
        if not cat:
            raise col.Invalid(node,
                              '"%s" is not a valid trove category.' % cstruct)
        if not cat.fullpath.startswith(self.root_type):
            raise col.Invalid(node,
                              '"%s" is not a valid "%s" trove category.' %
                              (cstruct, self.root_type))
        return cat 
开发者ID:apache,项目名称:allura,代码行数:16,代码来源:project-import.py

示例15: start

# 需要导入模块: import colander [as 别名]
# 或者: from colander import null [as 别名]
def start(self, context, request, appstruct, **kw):
        data = context.get_data(PersonSchema())
        annotations = getattr(context, 'annotations', {}).get(PROCESS_HISTORY_KEY, [])
        data.update({'password': appstruct['password']})
        data = {key: value for key, value in data.items()
                if value is not colander.null}
        data.pop('title')
        root = getSite()
        locale = my_locale_negotiator(request)
        data['locale'] = locale
        person = Person(**data)
        principals = find_service(root, 'principals')
        name = person.first_name + ' ' + person.last_name
        users = principals['users']
        name = name_chooser(users, name=name)
        users[name] = person
        grant_roles(person, roles=('Member',))
        grant_roles(person, (('Owner', person),))
        person.state.append('active')
        oid = str(get_oid(context))
        get_socket().send_pyobj(('stop', 'persistent_' + oid))
        organization = context.organization
        if organization:
            person.setproperty('organization', organization)

        root.delfromproperty('preregistrations', context)
        person.init_annotations()
        person.annotations.setdefault(
            PROCESS_HISTORY_KEY, PersistentList()).extend(annotations)
        person.reindex()
        request.registry.notify(ActivityExecuted(self, [person], person))
        root.addtoproperty('news_letter_members', person)
        newsletters = root.get_newsletters_automatic_registration()
        email = getattr(person, 'email', '')
        if newsletters and email:
            for newsletter in newsletters:
                newsletter.subscribe(
                    person.first_name, person.last_name, email)

        transaction.commit()
        if email:
            mail_template = root.get_mail_template(
                'registration_confiramtion', person.user_locale)
            subject = mail_template['subject'].format(
                novaideo_title=root.title)
            recipientdata = get_user_data(person, 'recipient', request)
            message = mail_template['template'].format(
                login_url=request.resource_url(root, '@@login'),
                novaideo_title=root.title,
                **recipientdata)
            alert('email', [root.get_site_sender()], [email],
                  subject=subject, body=message)

        return {'person': person} 
开发者ID:ecreall,项目名称:nova-ideo,代码行数:56,代码来源:behaviors.py


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