コード例 #1
0
ファイル: schema.py プロジェクト: wsgicabal/wiseguy
    def deserialize(self, node, cstruct):
        # cstruct is app name
        if not cstruct:
            raise colander.Invalid(node, _('Required'))

        try:
            app_factory = self.loader.get_app_factory(cstruct)
            return app_factory
        except Exception, e:
            raise colander.Invalid(
                node,
                _('"${val}" is invalid (${err})',
                  mapping={'val':cstruct, 'err': e})
                )
コード例 #2
0
ファイル: schema.py プロジェクト: wsgicabal/wiseguy
 def serialize(self, node, appstruct):
     if appstruct in (colander.null, None):
         return colander.null
     if isinstance(appstruct, basestring):
         appstruct = urlparse.urlparse(appstruct)
     
     try:
         return appstruct.geturl()
     except Exception:
         raise colander.Invalid(node,
                                _('"${val}" is not a urlparse.ParseResult',
                                  mapping={'val':appstruct}),
                       )
コード例 #3
0
ファイル: schema.py プロジェクト: wsgicabal/wiseguy
    def deserialize(self, node, cstruct):
        if not cstruct:
            return colander.null

        try:
            r = urlparse.urlparse(cstruct)
            # require absolute urls
            if not r.scheme or not r.netloc or not r.hostname:
                raise Exception()
            # poke at stuff to make sure the parts are valid:
            r.port, r.username, r.password
            return r
        except Exception, e:
            raise colander.Invalid(node,
                                   _('"${val}" is not a URL (${err})',
                                     mapping={'val':cstruct, 'err': e})
                                   )