Ejemplo n.º 1
0
        ('', '0000-00-00') else _prot.date_from_unicode(Date, s.strip()),
        unicode:
        lambda s: None if s.strip() in
        (u'', u'0000-00-00') else _prot.date_from_unicode(Date, s.strip()),
    }),
    DateTime:
    cdict({
        date:
        lambda _: datetime(date.year, date.month, date.day),
        datetime:
        lambda _: _,
        object:
        lambda _: _,
        bytes:
        lambda s: None if s.strip() in
        ('', '0000-00-00 00:00:00') else _prot.datetime_from_unicode(
            DateTime, s.strip()),
        unicode:
        lambda s: None if s.strip() in
        (u'', u'0000-00-00 00:00:00') else _prot.datetime_from_unicode(
            DateTime, s.strip()),
    }),
    IpAddress:
    cdict({
        object: lambda _: _,
        bytes: lambda s: None if s.strip() == '' else s.strip(),
        unicode: lambda s: None if s.strip() == u'' else s.strip(),
    })
})


def dynamic_init(cls, **kwargs):
Ejemplo n.º 2
0
    Date: cdict({
        date: lambda _: _,
        datetime: lambda _: _.date(),
        object: lambda _:_,
        bytes: lambda s: None if s.strip() in ('', '0000-00-00')
                                  else _prot.date_from_unicode(Date, s.strip()),
        unicode: lambda s: None if s.strip() in (u'', u'0000-00-00')
                                  else _prot.date_from_unicode(Date, s.strip()),
    }),

    DateTime: cdict({
        date: lambda _: datetime(date.year, date.month, date.day),
        datetime: lambda _: _,
        object: lambda _:_,
        bytes: lambda s: None if s.strip() in ('', '0000-00-00 00:00:00')
                          else _prot.datetime_from_unicode(DateTime, s.strip()),
        unicode: lambda s: None if s.strip() in (u'', u'0000-00-00 00:00:00')
                          else _prot.datetime_from_unicode(DateTime, s.strip()),
    }),

    IpAddress: cdict({
        object: lambda _: _,
        bytes: lambda s: None if s.strip() == '' else s.strip(),
        unicode: lambda s: None if s.strip() == u'' else s.strip(),
    })
})


def dynamic_init(cls, **kwargs):
    fti = cls.get_flat_type_info(cls)
    retval = cls()
Ejemplo n.º 3
0
Archivo: dyninit.py Proyecto: plq/spyne
    Date: cdict({
        date: lambda _: _,
        datetime: lambda _: _.date(),
        object: lambda _:_,
        bytes: lambda s: None if s.strip() in ('', '0000-00-00')
                                   else _prot.date_from_unicode(Date, s.strip()),
        unicode: lambda s: None if s.strip() in (u'', u'0000-00-00')
                                   else _prot.date_from_unicode(Date, s.strip()),
    }),

    DateTime: cdict({
        date: lambda _: datetime(date.year, date.month, date.day),
        datetime: lambda _: _,
        object: lambda _:_,
        bytes: lambda s: None if s.strip() in ('', '0000-00-00 00:00:00')
                          else _prot.datetime_from_unicode(DateTime, s.strip()),
        unicode: lambda s: None if s.strip() in (u'', u'0000-00-00 00:00:00')
                          else _prot.datetime_from_unicode(DateTime, s.strip()),
    }),

    IpAddress: cdict({
        object: lambda _: _,
        bytes: lambda s: None if s.strip() == '' else s.strip(),
        unicode: lambda s: None if s.strip() == u'' else s.strip(),
    })
})


def dynamic_init(cls, **kwargs):
    fti = cls.get_flat_type_info(cls)
    retval = cls()