예제 #1
0
파일: binary.py 프로젝트: liaolifeng/spyne
    def from_urlsafe_base64(cls, value):
        #FIXME: Find out why we need to do this.
        if isinstance(value, six.text_type):
            value = value.encode('utf8')
        try:
            return (urlsafe_b64decode(_bytes_join(value)), )

        except TypeError as e:
            logger.exception(e)

            if len(value) > 100:
                raise ValidationError(value)
            else:
                raise ValidationError(value[:100] + "(...)")
예제 #2
0
파일: binary.py 프로젝트: plq/spyne
    def from_urlsafe_base64(cls, value):
        #FIXME: Find out why we need to do this.
        if isinstance(value, six.text_type):
            value = value.encode('utf8')
        try:
            return (urlsafe_b64decode(_bytes_join(value)),)

        except TypeError as e:
            logger.exception(e)

            if len(value) > 100:
                raise ValidationError(value)
            else:
                raise ValidationError(value[:100] + "(...)")
예제 #3
0
파일: _base.py 프로젝트: norox/spyne
    def create_in_document(self, ctx, charset=None):
        """Uses the iterable of string fragments in ``ctx.in_string`` to set
        ``ctx.in_document``."""

        string = _bytes_join(ctx.in_string)
        try:
            try:
                ctx.in_document = etree.fromstring(string, self.parser)

            except XMLSyntaxError, e:
                logger.error(string)
                raise Fault("Client.XMLSyntaxError", str(e))

        except ValueError:
            try:
                ctx.in_document = etree.fromstring(string.decode(charset), self.parser)
            except XMLSyntaxError, e:
                logger.error(string)
                raise Fault("Client.XMLSyntaxError", str(e))
예제 #4
0
파일: _base.py 프로젝트: dmugtasimov/spyne
    def create_in_document(self, ctx, charset=None):
        """Uses the iterable of string fragments in ``ctx.in_string`` to set
        ``ctx.in_document``."""

        string = _bytes_join(ctx.in_string)
        try:
            try:
                ctx.in_document = etree.fromstring(string,
                                        parser=XMLParser(**self.parser_kwargs))

            except ValueError:
                logger.debug('ValueError: Deserializing from unicode strings '
                             'with encoding declaration is not supported by '
                             'lxml.')
                ctx.in_document = etree.fromstring(string.decode(charset),
                                                                    self.parser)
        except XMLSyntaxError, e:
            logger_invalid.error(string)
            raise Fault('Client.XMLSyntaxError', str(e))
예제 #5
0
파일: xml.py 프로젝트: iceteahh/spyne
    def create_in_document(self, ctx, charset=None):
        """Uses the iterable of string fragments in ``ctx.in_string`` to set
        ``ctx.in_document``."""

        string = _bytes_join(ctx.in_string)
        try:
            try:
                ctx.in_document = etree.fromstring(
                    string, parser=XMLParser(**self.parser_kwargs))

            except ValueError:
                logger.debug('ValueError: Deserializing from unicode strings '
                             'with encoding declaration is not supported by '
                             'lxml.')
                ctx.in_document = etree.fromstring(string.decode(charset),
                                                   self.parser)
        except XMLSyntaxError as e:
            logger_invalid.error(string)
            raise Fault('Client.XMLSyntaxError', str(e))
예제 #6
0
파일: _base.py 프로젝트: mfkaptan/spyne
    def create_in_document(self, ctx, charset=None):
        """Uses the iterable of string fragments in ``ctx.in_string`` to set
        ``ctx.in_document``."""

        string = _bytes_join(ctx.in_string)
        try:
            try:
                ctx.in_document = etree.fromstring(string, self.parser)

            except XMLSyntaxError, e:
                logger.error(string)
                raise Fault('Client.XMLSyntaxError', str(e))

        except ValueError:
            try:
                ctx.in_document = etree.fromstring(string.decode(charset),
                                                   self.parser)
            except XMLSyntaxError, e:
                logger.error(string)
                raise Fault('Client.XMLSyntaxError', str(e))
예제 #7
0
파일: binary.py 프로젝트: amgibson/spyne
 def from_base64(cls, value):
     return [base64.b64decode(_bytes_join(value))]
예제 #8
0
파일: binary.py 프로젝트: jpunwin/spyne
 def from_base64(cls, value):
     try:
         return [b64decode(_bytes_join(value))]
     except TypeError as e:
         raise ValidationError(value)
예제 #9
0
파일: binary.py 프로젝트: jpunwin/spyne
 def to_base64(cls, value):
     return b64encode(_bytes_join(value))
예제 #10
0
파일: binary.py 프로젝트: jpunwin/spyne
 def from_hex(cls, value):
     return [unhexlify(_bytes_join(value))]
예제 #11
0
파일: binary.py 프로젝트: jpunwin/spyne
 def to_hex(cls, value):
     return hexlify(_bytes_join(value))
예제 #12
0
 def from_base64(cls, value):
     return [base64.b64decode(_bytes_join(value))]
예제 #13
0
 def set_response(self, retval, response):
     retval.content = _bytes_join(response, b"")
예제 #14
0
파일: binary.py 프로젝트: iceteahh/spyne
 def to_hex(cls, value):
     return hexlify(_bytes_join(value))
예제 #15
0
파일: binary.py 프로젝트: trecouvr/spyne
 def from_base64(cls, value):
     try:
         return [b64decode(_bytes_join(value))]
     except TypeError as e:
         raise ValidationError(value)
예제 #16
0
파일: binary.py 프로젝트: trecouvr/spyne
 def to_base64(cls, value):
     return b64encode(_bytes_join(value))
예제 #17
0
파일: binary.py 프로젝트: fmezas/spyne
 def from_urlsafe_base64(cls, value):
     return [urlsafe_b64decode(_bytes_join(value))]
예제 #18
0
파일: binary.py 프로젝트: iceteahh/spyne
 def to_urlsafe_base64(cls, value):
     return urlsafe_b64encode(_bytes_join(value))
예제 #19
0
파일: binary.py 프로젝트: jpunwin/spyne
 def from_urlsafe_base64(cls, value):
     #FIXME: Find out why we need to do this.
     if isinstance(value, unicode):
         value = value.encode('utf8')
     return [urlsafe_b64decode(_bytes_join(value))]
예제 #20
0
파일: binary.py 프로젝트: iceteahh/spyne
 def from_urlsafe_base64(cls, value):
     #FIXME: Find out why we need to do this.
     if isinstance(value, six.text_type):
         value = value.encode('utf8')
     return [urlsafe_b64decode(_bytes_join(value))]
예제 #21
0
 def set_response(self, retval, response):
     retval.content = _bytes_join(response, b"")
예제 #22
0
파일: binary.py 프로젝트: iceteahh/spyne
 def from_hex(cls, value):
     return [unhexlify(_bytes_join(value))]
예제 #23
0
파일: binary.py 프로젝트: jpunwin/spyne
 def to_urlsafe_base64(cls, value):
     return urlsafe_b64encode(_bytes_join(value))