本文整理汇总了Python中spyne.model.primitive.NATIVE_MAP.update方法的典型用法代码示例。如果您正苦于以下问题:Python NATIVE_MAP.update方法的具体用法?Python NATIVE_MAP.update怎么用?Python NATIVE_MAP.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyne.model.primitive.NATIVE_MAP
的用法示例。
在下文中一共展示了NATIVE_MAP.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: customize
# 需要导入模块: from spyne.model.primitive import NATIVE_MAP [as 别名]
# 或者: from spyne.model.primitive.NATIVE_MAP import update [as 别名]
to a `ComplexModel` sublass."""
@classmethod
def customize(cls, **kwargs):
"""Duplicates cls and overwrites the values in ``cls.Attributes`` with
``**kwargs`` and returns the new class."""
store_as = apply_pssm(kwargs.get('store_as', None),
{'json': json, 'xml': xml, 'msgpack': msgpack})
if store_as is not None:
kwargs['store_as'] = store_as
return super(AnyDict, cls).customize(**kwargs)
class Boolean(SimpleModel):
"""Life is simple here. Just true or false."""
class Attributes(SimpleModel.Attributes):
store_as = bool
"""Method for serializing to persistent storage. One of `bool` or `int`
builtins. It makes sense to specify this only when this object belongs
to a `ComplexModel` sublass."""
__type_name__ = 'boolean'
NATIVE_MAP.update({
bool: Boolean,
})
示例2: is_default
# 需要导入模块: from spyne.model.primitive import NATIVE_MAP [as 别名]
# 或者: from spyne.model.primitive.NATIVE_MAP import update [as 别名]
pattern = None
"""A regular expression that matches the whole date. See here for more
info: http://www.regular-expressions.info/xml.html"""
@staticmethod
def is_default(cls):
return ( SimpleModel.is_default(cls)
and cls.Attributes.gt == Date.Attributes.gt
and cls.Attributes.ge == Date.Attributes.ge
and cls.Attributes.lt == Date.Attributes.lt
and cls.Attributes.le == Date.Attributes.le
and cls.Attributes.pattern == Date.Attributes.pattern
)
# this object tries to follow ISO 8601 standard.
class Duration(SimpleModel):
"""Native type is :class:`datetime.timedelta`."""
__type_name__ = 'duration'
Value = datetime.timedelta
NATIVE_MAP.update({
datetime.datetime: DateTime,
datetime.time: Time,
datetime.date: Date,
datetime.timedelta: Duration,
})
示例3: Attributes
# 需要导入模块: from spyne.model.primitive import NATIVE_MAP [as 别名]
# 或者: from spyne.model.primitive.NATIVE_MAP import update [as 别名]
class Attributes(Unicode(pattern=UUID_PATTERN).Attributes):
serialize_as = None
@staticmethod
def validate_string(cls, value):
return _uuid_validate[cls.Attributes.serialize_as](cls, value)
@staticmethod
def validate_native(cls, value):
return SimpleModel.validate_native(cls, value)
class Ltree(Unicode(LTREE_OPTIMAL_SIZE, unicode_pattern=LTREE_PATTERN)):
"""A special kind of String type designed to hold the Ltree type from
Postgresql."""
__namespace__ = 'http://spyne.io/schema'
__type_name__ = 'ltreeString'
if not six.PY2:
NATIVE_MAP.update({
str: Unicode,
})
else:
NATIVE_MAP.update({
str: String,
unicode: Unicode,
})
示例4: TBoundedUnsignedInteger
# 需要导入模块: from spyne.model.primitive import NATIVE_MAP [as 别名]
# 或者: from spyne.model.primitive.NATIVE_MAP import update [as 别名]
UnsignedInteger16 = TBoundedUnsignedInteger(16, 'unsignedShort')
"""The 16-bit unsigned integer, also known as ``unsignedShort``."""
UnsignedShort = UnsignedInteger16
"""The 16-bit unsigned integer, alias for :class:`UnsignedInteger16`."""
UnsignedInteger8 = TBoundedUnsignedInteger(8, 'unsignedByte')
"""The 8-bit unsigned integer, also known as ``unsignedByte``."""
UnsignedByte = UnsignedInteger8
"""The 8-bit unsigned integer, alias for :class:`UnsignedInteger8`."""
NATIVE_MAP.update({
float: Double,
decimal.Decimal: Decimal,
})
if six.PY3:
NATIVE_MAP.update({
int: Integer,
})
else:
NATIVE_MAP.update({
long: Integer,
})
if isinstance(0x80000000, long): # 32-bit architecture
NATIVE_MAP[int] = Integer32