本文整理汇总了Python中spyne.util.cdict.cdict函数的典型用法代码示例。如果您正苦于以下问题:Python cdict函数的具体用法?Python cdict怎么用?Python cdict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cdict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, app=None, validator=None, xml_declaration=True,
cleanup_namespaces=False):
ProtocolBase.__init__(self, app, validator)
self.xml_declaration = xml_declaration
self.cleanup_namespaces = cleanup_namespaces
self.serialization_handlers = cdict({
AnyXml: xml_to_parent_element,
Alias: alias_to_parent_element,
Fault: fault_to_parent_element,
AnyDict: dict_to_parent_element,
EnumBase: enum_to_parent_element,
ModelBase: base_to_parent_element,
ByteArray: binary_to_parent_element,
Attachment: binary_to_parent_element,
ComplexModelBase: complex_to_parent_element,
})
self.deserialization_handlers = cdict({
AnyXml: xml_from_element,
Fault: fault_from_element,
AnyDict: dict_from_element,
EnumBase: enum_from_element,
ModelBase: base_from_element,
Unicode: unicode_from_element,
ByteArray: binary_from_element,
Attachment: binary_from_element,
ComplexModelBase: complex_from_element,
Iterable: iterable_from_element,
Array: array_from_element,
})
self.log_messages = (logger.level == logging.DEBUG)
开发者ID:shaung,项目名称:spyne,代码行数:34,代码来源:_base.py
示例2: __init__
def __init__(self, app=None, validator=None, mime_type=None,
ignore_uncap=False):
self.__app = None
self.validator = None
self.set_app(app)
self.event_manager = EventManager(self)
self.set_validator(validator)
self.ignore_uncap = ignore_uncap
if mime_type is not None:
self.mime_type = mime_type
self._to_string_handlers = cdict({
ModelBase: lambda cls, value: cls.to_string(value),
Time: time_to_string,
Uuid: uuid_to_string,
Null: null_to_string,
Double: double_to_string,
AnyXml: any_xml_to_string,
Unicode: unicode_to_string,
Boolean: boolean_to_string,
Decimal: decimal_to_string,
Integer: integer_to_string,
AnyHtml: any_html_to_string,
DateTime: datetime_to_string,
Duration: duration_to_string,
ByteArray: byte_array_to_string,
Attachment: attachment_to_string,
ComplexModelBase: complex_model_base_to_string,
})
self._to_string_iterable_handlers = cdict({
File: file_to_string_iterable,
ByteArray: byte_array_to_string_iterable,
ModelBase: lambda prot, cls, value: cls.to_string_iterable(value),
SimpleModel: simple_model_to_string_iterable,
ComplexModelBase: complex_model_to_string_iterable,
})
self._from_string_handlers = cdict({
Null: null_from_string,
Time: time_from_string,
Date: date_from_string,
Uuid: uuid_from_string,
File: file_from_string,
Double: double_from_string,
String: string_from_string,
AnyXml: any_xml_from_string,
Boolean: boolean_from_string,
Integer: integer_from_string,
Unicode: unicode_from_string,
Decimal: decimal_from_string,
AnyHtml: any_html_from_string,
DateTime: datetime_from_string,
Duration: duration_from_string,
ByteArray: byte_array_from_string,
Attachment: attachment_from_string,
ComplexModelBase: complex_model_base_from_string
})
开发者ID:esauro,项目名称:spyne,代码行数:59,代码来源:_base.py
示例3: __init__
def __init__(self, app=None, validator=None, mime_type=None,
ignore_wrappers=False, binary_encoding=None):
self.validator = None
super(InProtocolBase, self).__init__(app=app, mime_type=mime_type,
ignore_wrappers=ignore_wrappers, binary_encoding=binary_encoding)
self.message = None
self.validator = None
self.set_validator(validator)
if self.binary_encoding is None:
self.binary_encoding = self.default_binary_encoding
if mime_type is not None:
self.mime_type = mime_type
fsh = {
Null: self.null_from_string,
Time: self.time_from_string,
Date: self.date_from_string,
Uuid: self.uuid_from_string,
File: self.file_from_string,
Array: self.array_from_string,
Double: self.double_from_string,
String: self.string_from_string,
AnyXml: self.any_xml_from_string,
Boolean: self.boolean_from_string,
Integer: self.integer_from_string,
Unicode: self.unicode_from_string,
Decimal: self.decimal_from_string,
AnyHtml: self.any_html_from_string,
DateTime: self.datetime_from_string,
Duration: self.duration_from_string,
ByteArray: self.byte_array_from_string,
EnumBase: self.enum_base_from_string,
ModelBase: self.model_base_from_string,
Attachment: self.attachment_from_string,
XmlAttribute: self.xmlattribute_from_string,
ComplexModelBase: self.complex_model_base_from_string
}
self._from_string_handlers = cdict(fsh)
self._from_unicode_handlers = cdict(fsh)
self._datetime_dsmap = {
None: self._datetime_from_string,
'sec': self._datetime_from_sec,
'sec_float': self._datetime_from_sec_float,
'msec': self._datetime_from_msec,
'msec_float': self._datetime_from_msec_float,
'usec': self._datetime_from_usec,
}
开发者ID:hozn,项目名称:spyne,代码行数:54,代码来源:_inbase.py
示例4: __new__
def __new__(cls, cls_name, cls_bases, cls_dict):
for dkey in ("_to_string_handlers", "_to_string_iterable_handlers",
"_from_string_handlers", '_to_dict_handlers'):
d = cdict()
for b in cls_bases:
d_base = getattr(b, dkey, cdict())
d.update(d_base)
d.update(cdict(cls_dict.get(dkey, {})))
cls_dict[dkey] = d
return type(object).__new__(cls, cls_name, cls_bases, cls_dict)
开发者ID:norox,项目名称:spyne,代码行数:12,代码来源:_base.py
示例5: __init__
def __init__(
self,
app=None,
validator=None,
xml_declaration=True,
cleanup_namespaces=True,
encoding="UTF-8",
pretty_print=False,
):
ProtocolBase.__init__(self, app, validator)
self.xml_declaration = xml_declaration
self.cleanup_namespaces = cleanup_namespaces
self.encoding = encoding
self.pretty_print = pretty_print
self.serialization_handlers = cdict(
{
AnyXml: xml_to_parent_element,
Alias: alias_to_parent_element,
Fault: fault_to_parent_element,
AnyDict: dict_to_parent_element,
AnyHtml: html_to_parent_element,
EnumBase: enum_to_parent_element,
ModelBase: base_to_parent_element,
ByteArray: byte_array_to_parent_element,
Attachment: attachment_to_parent_element,
ComplexModelBase: complex_to_parent_element,
}
)
self.deserialization_handlers = cdict(
{
AnyXml: xml_from_element,
Fault: fault_from_element,
AnyDict: dict_from_element,
EnumBase: enum_from_element,
ModelBase: base_from_element,
Unicode: unicode_from_element,
ByteArray: byte_array_from_element,
Attachment: attachment_from_element,
ComplexModelBase: complex_from_element,
Alias: alias_from_element,
Iterable: iterable_from_element,
Array: array_from_element,
}
)
self.log_messages = logger.level == logging.DEBUG
self.parser = etree.XMLParser(remove_comments=True)
开发者ID:specialunderwear,项目名称:spyne,代码行数:49,代码来源:_base.py
示例6: test_cdict
def test_cdict(self):
from spyne.util.cdict import cdict
class A(object):
pass
class B(A):
pass
class E(B):
pass
class F(E):
pass
class C(object):
pass
class D:
pass
d = cdict({A: "fun", object: "base", F: 'zan'})
assert d[A] == 'fun'
assert d[B] == 'fun'
assert d[C] == 'base'
assert d[F] == 'zan'
try:
d[D]
except KeyError:
pass
else:
raise Exception("Must fail.")
开发者ID:sashka,项目名称:spyne,代码行数:33,代码来源:test_util.py
示例7: __init__
def __init__(self, app=None, validator=None, mime_type=None,
ignore_uncap=False, ignore_wrappers=False, polymorphic=True):
super(ToParentMixin, self).__init__(app=app, validator=validator,
mime_type=mime_type, ignore_uncap=ignore_uncap,
ignore_wrappers=ignore_wrappers)
self.polymorphic = polymorphic
self.use_global_null_handler = True
self.serialization_handlers = cdict({
ModelBase: self.base_to_parent,
AnyXml: self.xml_to_parent,
AnyUri: self.anyuri_to_parent,
ImageUri: self.imageuri_to_parent,
AnyDict: self.dict_to_parent,
AnyHtml: self.html_to_parent,
Any: self.any_to_parent,
Fault: self.fault_to_parent,
EnumBase: self.enum_to_parent,
ByteArray: self.byte_array_to_parent,
ComplexModelBase: self.complex_to_parent,
SchemaValidationError: self.schema_validation_error_to_parent,
})
开发者ID:jstuyck,项目名称:spyne,代码行数:25,代码来源:to_parent.py
示例8: __init__
def __init__(self, app=None, ignore_uncap=False, ignore_wrappers=False,
cloth=None, attr_name='spyne_id', root_attr_name='spyne',
cloth_parser=None, polymorphic=True, hier_delim='.',
asset_paths={}):
super(HtmlForm, self).__init__(app=app,
ignore_uncap=ignore_uncap, ignore_wrappers=ignore_wrappers,
cloth=cloth, attr_name=attr_name, root_attr_name=root_attr_name,
cloth_parser=cloth_parser, polymorphic=polymorphic)
self.serialization_handlers = cdict({
Date: self.date_to_parent,
Time: self.time_to_parent,
Array: self.array_type_to_parent,
Integer: self.integer_to_parent,
Unicode: self.unicode_to_parent,
Decimal: self.decimal_to_parent,
Boolean: self.boolean_to_parent,
Duration: self.duration_to_parent,
DateTime: self.datetime_to_parent,
ComplexModelBase: self.complex_model_to_parent,
})
self.hier_delim = hier_delim
self.asset_paths = {
('jquery',): [_jstag("/assets/jquery/1.11.1/jquery.min.js")],
('jquery-ui',): [_jstag("/assets/jquery-ui/1.11.0/jquery-ui.min.js")],
('jquery-timepicker',): [
_jstag("/assets/jquery-timepicker/jquery-ui-timepicker-addon.js"),
_csstag("/assets/jquery-timepicker/jquery-ui-timepicker-addon.css"),
],
}
self.asset_paths.update(asset_paths)
self.use_global_null_handler = False
开发者ID:payingattention,项目名称:neurons,代码行数:35,代码来源:form.py
示例9: __init__
def __init__(self, text_field=None, id_field=None, type=None,
hidden_fields=None, label=True, null_str='[NULL]'):
"""A widget that renders complex objects as links.
:param text_field: The name of the field containing a human readable
string that represents the object.
:param id_field: The name of the field containing the unique identifier
of the object.
:param type: If not `None`, overrides the object type being rendered.
Useful for e.g. combining multiple fields to one field.
:param hidden_fields: A sequence of field names that will be rendered as
hidden <input> tags.
:param label: If ``True``, a ``<label>`` tag is generated for the
relevant widget id.
"""
super(ComplexRenderWidget, self).__init__(label=label)
self.id_field = id_field
self.text_field = text_field
self.hidden_fields = hidden_fields
self.type = type
self.null_str = null_str
self.serialization_handlers = cdict({
ComplexModelBase: self.complex_model_to_parent,
})
开发者ID:cemrecan,项目名称:neurons,代码行数:27,代码来源:widget.py
示例10: __init__
def __init__(self, label=True, type=None, hidden=False):
super(SimpleReadableNumberWidget, self).__init__(
label=label, type=type, hidden=hidden)
self.serialization_handlers = cdict({
Decimal: self.decimal_to_parent,
Integer: self.integer_to_parent,
})
开发者ID:arskom,项目名称:neurons,代码行数:8,代码来源:widget.py
示例11: __init__
def __init__(self, app=None, ignore_uncap=False, ignore_wrappers=False,
cloth=None, cloth_parser=None, polymorphic=True,
doctype="<!DOCTYPE html>",
root_tag='div', child_tag='div', field_name_attr='class',
field_name_tag=None, field_name_class='field_name',
before_first_root=None):
"""Protocol that returns the response object according to the "html
microformat" specification. See
https://en.wikipedia.org/wiki/Microformats for more info.
The simple flavour is like the XmlDocument protocol, but returns data in
<div> or <span> tags.
:param app: A spyne.application.Application instance.
:param root_tag: The type of the root tag that encapsulates the return
data.
:param child_tag: The type of the tag that encapsulates the fields of
the returned object.
:param field_name_attr: The name of the attribute that will contain the
field names of the complex object children.
"""
super(HtmlMicroFormat, self).__init__(app=app,
ignore_uncap=ignore_uncap, ignore_wrappers=ignore_wrappers,
cloth=cloth, cloth_parser=cloth_parser, polymorphic=polymorphic,
hier_delim=None, doctype=doctype)
if six.PY2:
text_type = basestring
else:
text_type = str
assert isinstance(root_tag, text_type)
assert isinstance(child_tag, text_type)
assert isinstance(field_name_attr, text_type)
assert field_name_tag is None or isinstance(field_name_tag, text_type)
self.root_tag = root_tag
self.child_tag = child_tag
self.field_name_attr = field_name_attr
self.field_name_tag = field_name_tag
if field_name_tag is not None:
self.field_name_tag = E(field_name_tag)
self._field_name_class = field_name_class
if before_first_root is not None:
self.event_manager.add_listener("before_first_root",
before_first_root)
self.serialization_handlers = cdict({
Array: self.array_to_parent,
AnyUri: self.any_uri_to_parent,
AnyHtml: self.any_html_to_parent,
ImageUri: self.imageuri_to_parent,
ByteArray: self.not_supported,
ModelBase: self.model_base_to_parent,
ComplexModelBase: self.complex_model_to_parent,
})
开发者ID:plq,项目名称:spyne,代码行数:57,代码来源:microformat.py
示例12: __init__
def __init__(self, label=True, type=None, hidden=False):
super(SimpleRenderWidget, self).__init__(label=label)
self.type = type
self.hidden = hidden
self.serialization_handlers = cdict({
ModelBase: self.model_base_to_parent,
ComplexModelBase: self.not_supported,
})
开发者ID:tayfundogan,项目名称:neurons,代码行数:9,代码来源:widget.py
示例13: __init__
def __init__(self, *args, **kwargs):
super(HtmlRowTable, self).__init__(*args, **kwargs)
self.serialization_handlers = cdict({
ModelBase: self.model_base_to_parent,
AnyUri: self.anyuri_to_parent,
ImageUri: self.imageuri_to_parent,
ByteArray: self.not_supported,
ComplexModelBase: self.complex_model_to_parent,
Array: self.array_to_parent,
})
开发者ID:mahdi-b,项目名称:spyne,代码行数:11,代码来源:table.py
示例14: __init__
def __init__(self, label=True, type=None, hidden=False):
super(SimpleRenderWidget, self).__init__(label=label)
self.type = type
self.hidden = hidden
self.serialization_handlers = cdict({
ModelBase: self.model_base_to_parent,
AnyHtml: self.any_html_to_parent,
AnyUri: self.any_uri_to_parent,
ComplexModelBase: self.complex_model_to_parent,
})
开发者ID:yilmazalican,项目名称:neurons,代码行数:11,代码来源:widget.py
示例15: test_cdict
def test_cdict(self):
d = cdict({A: "fun", object: "base"})
assert d[A] == 'fun'
assert d[B] == 'fun'
assert d[C] == 'base'
try:
d[D]
except KeyError:
pass
else:
raise Exception("Must fail.")
开发者ID:66ru,项目名称:spyne,代码行数:12,代码来源:test_cdict.py
示例16: __init__
def __init__(self, app=None, validator=None, mime_type=None,
ignore_uncap=False, ignore_wrappers=False):
super(ToClothMixin, self).__init__(app=app, validator=validator,
mime_type=mime_type, ignore_uncap=ignore_uncap,
ignore_wrappers=ignore_wrappers)
self.rendering_handlers = cdict({
ModelBase: self.model_base_to_cloth,
AnyXml: self.element_to_cloth,
AnyHtml: self.element_to_cloth,
ComplexModelBase: self.complex_to_cloth,
})
开发者ID:spaceshipoperator,项目名称:spyne,代码行数:12,代码来源:to_cloth.py
示例17: __init__
def __init__(self, app=None, ignore_uncap=False, ignore_wrappers=False,
cloth=None, attr_name='spyne_id', root_attr_name='spyne',
cloth_parser=None,
root_tag='div', child_tag='div', field_name_attr='class',
field_name_tag=None, field_name_class='field_name'):
"""Protocol that returns the response object according to the "html
microformat" specification. See
https://en.wikipedia.org/wiki/Microformats for more info.
The simple flavour is like the XmlDocument protocol, but returns data in
<div> or <span> tags.
:param app: A spyne.application.Application instance.
:param validator: The validator to use. Ignored.
:param root_tag: The type of the root tag that encapsulates the return
data.
:param child_tag: The type of the tag that encapsulates the fields of
the returned object.
:param field_name_attr: The name of the attribute that will contain the
field names of the complex object children.
"""
super(HtmlMicroFormat, self).__init__(app=app,
ignore_uncap=ignore_uncap, ignore_wrappers=ignore_wrappers,
cloth=cloth, attr_name=attr_name, root_attr_name=root_attr_name,
cloth_parser=cloth_parser)
assert root_tag in ('div', 'span')
assert child_tag in ('div', 'span')
assert field_name_attr in ('class', 'id')
assert field_name_tag in (None, 'span', 'div')
self.root_tag = root_tag
self.child_tag = child_tag
self.field_name_attr = field_name_attr
self.field_name_tag = field_name_tag
if field_name_tag is not None:
self.field_name_tag = E(field_name_tag)
self._field_name_class = field_name_class
self.serialization_handlers = cdict({
ModelBase: self.model_base_to_parent,
AnyUri: self.anyuri_to_parent,
AnyHtml: self.anyhtml_to_parent,
ImageUri: self.imageuri_to_parent,
ByteArray: self.not_supported,
Attachment: self.not_supported,
ComplexModelBase: self.complex_model_to_parent,
Array: self.array_to_parent,
})
开发者ID:DmitriyMoseev,项目名称:spyne,代码行数:50,代码来源:microformat.py
示例18: __init__
def __init__(self, app=None, ignore_uncap=False, ignore_wrappers=False,
cloth=None, attr_name='spyne_id', root_attr_name='spyne',
cloth_parser=None, can_add=True, can_remove=True):
super(HtmlFormTable, self).__init__(app=app,
ignore_uncap=ignore_uncap, ignore_wrappers=ignore_wrappers,
cloth=cloth, attr_name=attr_name, root_attr_name=root_attr_name,
cloth_parser=cloth_parser)
self.serialization_handlers = cdict({
ModelBase: self.model_base_to_parent,
})
self.prot_form = HtmlForm()
self.can_add = can_add
self.can_remove = can_remove
开发者ID:merveunlu,项目名称:neurons,代码行数:16,代码来源:form_table.py
示例19: __init__
def __init__(self, app=None, ignore_uncap=False, ignore_wrappers=False,
cloth=None, cloth_parser=None, polymorphic=True, hier_delim='.',
doctype=None, label=True, asset_paths={}, placeholder=None,
input_class=None, input_div_class=None,
input_wrapper_class=None, label_class=None,
action=None, method='POST', before_form=None):
super(HtmlForm, self).__init__(app=app, doctype=doctype,
ignore_uncap=ignore_uncap, ignore_wrappers=ignore_wrappers,
cloth=cloth, cloth_parser=cloth_parser, polymorphic=polymorphic,
hier_delim=hier_delim, label=label, asset_paths=asset_paths,
placeholder=placeholder, input_class=input_class,
input_div_class=input_div_class,
input_wrapper_class=input_wrapper_class, label_class=label_class,
action=action, method=method, before_form=before_form)
self.serialization_handlers = cdict({
Date: self._check_simple(self.date_to_parent),
Time: self._check_simple(self.time_to_parent),
Uuid: self._check_simple(self.uuid_to_parent),
Fault: self.fault_to_parent,
Array: self.array_type_to_parent,
AnyXml: self._check_simple(self.anyxml_to_parent),
Integer: self._check_simple(self.integer_to_parent),
Unicode: self._check_simple(self.unicode_to_parent),
AnyHtml: self._check_simple(self.anyhtml_to_parent),
Decimal: self._check_simple(self.decimal_to_parent),
Boolean: self._check_simple(self.boolean_to_parent),
Duration: self._check_simple(self.duration_to_parent),
DateTime: self._check_simple(self.datetime_to_parent),
ComplexModelBase: self.complex_model_to_parent,
})
self.hier_delim = hier_delim
self.asset_paths = {
('jquery',): [_jstag("/assets/jquery/1.11.1/jquery.min.js")],
('jquery-ui',): [_jstag("/assets/jquery-ui/1.11.0/jquery-ui.min.js")],
('jquery-timepicker',): [
_jstag("/assets/jquery-timepicker/jquery-ui-timepicker-addon.js"),
_csstag("/assets/jquery-timepicker/jquery-ui-timepicker-addon.css"),
],
}
self.asset_paths.update(asset_paths)
self.use_global_null_handler = False
self.simple = SimpleRenderWidget(label=label)
开发者ID:yilmazalican,项目名称:neurons,代码行数:47,代码来源:form.py
示例20: __init__
def __init__(self, app=None, validator=None, mime_type=None,
ignore_uncap=False, ignore_wrappers=False):
super(ToParentMixin, self).__init__(app=app, validator=validator,
mime_type=mime_type, ignore_uncap=ignore_uncap,
ignore_wrappers=ignore_wrappers)
self.serialization_handlers = cdict({
AnyXml: self.xml_to_parent,
Fault: self.fault_to_parent,
AnyDict: self.dict_to_parent,
AnyHtml: self.html_to_parent,
EnumBase: self.enum_to_parent,
ModelBase: self.base_to_parent,
ByteArray: self.byte_array_to_parent,
ComplexModelBase: self.complex_to_parent,
SchemaValidationError: self.schema_validation_error_to_parent,
})
开发者ID:rtindru,项目名称:spyne,代码行数:17,代码来源:to_parent.py
注:本文中的spyne.util.cdict.cdict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论