How to use the spyne.model.complex.XmlAttribute function in spyne

To help you get started, we’ve selected a few spyne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arskom / spyne / spyne / interface / xml_schema / defn.py View on Github external
('union', Unicode),
    ]


class Attribute(SchemaBase):
     use = XmlAttribute(Unicode)
     ref = XmlAttribute(Unicode)
     name = XmlAttribute(Unicode)
     type = XmlAttribute(Unicode)
     default = XmlAttribute(Unicode)
     simple_type = SimpleType.customize(sub_name='simpleType')


class Restriction(SchemaBase):
    _type_info = [
        ('base', XmlAttribute(Unicode)),
        ('max_length', IntegerAttribute.customize(sub_name="maxLength")),
        ('min_length', IntegerAttribute.customize(sub_name="minLength")),
        ('pattern', StringAttribute),
        ('enumeration', StringAttribute.customize(max_occurs="unbounded")),
        ('attributes', Attribute.customize(max_occurs="unbounded",
                                                        sub_name="attribute")),
    ]

SimpleType.append_field('restriction', Restriction)


class Choice(SchemaBase):
    elements = Element.customize(max_occurs="unbounded", sub_name="element")


class Sequence(SchemaBase):
github arskom / spyne / spyne / interface / xml_schema / defn.py View on Github external
__namespace__ = xml.NS_XSD


class Import(SchemaBase):
    namespace = XmlAttribute(Unicode)


class Element(SchemaBase):
    name = XmlAttribute(Unicode)
    type = XmlAttribute(Unicode)
    ref = XmlAttribute(Unicode)
    # it can be "unbounded", so it should be of type Unicode
    max_occurs = XmlAttribute(Unicode(default="1", sub_name="maxOccurs"))
    # Also Unicode for consistency with max_occurs
    min_occurs = XmlAttribute(Unicode(default="1", sub_name="minOccurs"))
    nillable = XmlAttribute(Boolean(default=False))
    default = XmlAttribute(Unicode)


class IntegerAttribute(SchemaBase):
    value = XmlAttribute(UnsignedInteger)


class StringAttribute(SchemaBase):
    value = XmlAttribute(Unicode)


class List(SchemaBase):
    _type_info = [
        ('item_type', XmlAttribute(Unicode(sub_name='itemType'))),
    ]
github arskom / spyne / spyne / interface / xml_schema / defn.py View on Github external
type = XmlAttribute(Unicode)
    ref = XmlAttribute(Unicode)
    # it can be "unbounded", so it should be of type Unicode
    max_occurs = XmlAttribute(Unicode(default="1", sub_name="maxOccurs"))
    # Also Unicode for consistency with max_occurs
    min_occurs = XmlAttribute(Unicode(default="1", sub_name="minOccurs"))
    nillable = XmlAttribute(Boolean(default=False))
    default = XmlAttribute(Unicode)


class IntegerAttribute(SchemaBase):
    value = XmlAttribute(UnsignedInteger)


class StringAttribute(SchemaBase):
    value = XmlAttribute(Unicode)


class List(SchemaBase):
    _type_info = [
        ('item_type', XmlAttribute(Unicode(sub_name='itemType'))),
    ]


class SimpleType(SchemaBase):
    _type_info = [
        ('name', XmlAttribute(Unicode)),
        ('list', List),
        ('union', Unicode),
    ]
github arskom / spyne / examples / xml / utils.py View on Github external
a = String
    b = Integer
    c = Decimal
    d = DateTime


class Foo(ComplexModel):
    __namespace__ = 'some_other_namespace'

    a = String
    b = Integer
    c = Decimal
    d = DateTime
    e = XmlAttribute(Integer)
    f = XmlAttribute(Unicode, attribute_of='d')


class ProductEdition(ComplexModel):
    __namespace__ = 'kickass_namespace'

    id = XmlAttribute(Uuid)
    name = XmlData(Unicode)


class Product(ComplexModel):
    __namespace__ = 'kickass_namespace'

    id = XmlAttribute(Uuid)
    edition = ProductEdition
github arskom / spyne / spyne / interface / wsdl / defn.py View on Github external
class SoapBinding(Soap11Base):
    style = XmlAttribute(Unicode)
    transport = XmlAttribute(Unicode)


class Binding(Wsdl11Base):
    name = XmlAttribute(Unicode)
    type = XmlAttribute(Unicode)
    location = XmlAttribute(Unicode)
    soap_binding = SoapBinding.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                                           sub_name="binding")


class PortAddress(Soap11Base):
    location = XmlAttribute(Unicode)


class ServicePort(Wsdl11Base):
    name = XmlAttribute(Unicode)
    binding = XmlAttribute(Unicode)
    address = PortAddress.customize(sub_ns=xml.NS_WSDL11_SOAP)


class Service(Wsdl11Base):
    port = ServicePort
    name = XmlAttribute(Unicode)


class Wsdl11(Wsdl11Base):
    _type_info = [
        ('types', Types),
github arskom / spyne / spyne / model / complex.py View on Github external
def __init__(self, cls_name, cls_bases, cls_dict):
        type_info = cls_dict['_type_info']

        for k,v in type_info.items():
            if issubclass(v, SelfReference):
                type_info[k] = self

            if issubclass(v, XmlAttribute):
                a_of = v.attribute_of
                if a_of is not None:
                    type_info.attributes[k] = type_info[a_of]

            if issubclass(v, Array):
                v2, = v._type_info.values()
                while issubclass(v2, Array):
                    v = v2
                    v2, = v2._type_info.values()

                if issubclass(v2, SelfReference):
                    v._set_serializer(self)

        tn = self.Attributes.table_name
        meta = self.Attributes.sqla_metadata
        t = self.Attributes.sqla_table
github arskom / spyne / spyne / interface / wsdl / defn.py View on Github external
class Types(Wsdl11Base):
    schema = XmlSchema10.customize(max_occurs="unbounded")


class MessagePart(Wsdl11Base):
    element = XmlAttribute(Unicode)
    name = XmlAttribute(Unicode)


class Message(Wsdl11Base):
    part = MessagePart
    name = XmlAttribute(Unicode)


class SoapBodyDefinition(Wsdl11Base):
    use = XmlAttribute(Unicode)


class SoapHeaderDefinition(Wsdl11Base):
    use = XmlAttribute(Unicode)
    message = XmlAttribute(Unicode)
    part = XmlAttribute(Unicode)


class OperationMode(Wsdl11Base):
    name = XmlAttribute(Unicode)
    message = XmlAttribute(Unicode)
    soap_body = SoapBodyDefinition.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                                              sub_name="body")
    soap_header = SoapHeaderDefinition.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                                              sub_name="header")
github arskom / spyne / spyne / interface / xml_schema / defn.py View on Github external
class SimpleType(SchemaBase):
    _type_info = [
        ('name', XmlAttribute(Unicode)),
        ('list', List),
        ('union', Unicode),
    ]


class Attribute(SchemaBase):
     use = XmlAttribute(Unicode)
     ref = XmlAttribute(Unicode)
     name = XmlAttribute(Unicode)
     type = XmlAttribute(Unicode)
     default = XmlAttribute(Unicode)
     simple_type = SimpleType.customize(sub_name='simpleType')


class Restriction(SchemaBase):
    _type_info = [
        ('base', XmlAttribute(Unicode)),
        ('max_length', IntegerAttribute.customize(sub_name="maxLength")),
        ('min_length', IntegerAttribute.customize(sub_name="minLength")),
        ('pattern', StringAttribute),
        ('enumeration', StringAttribute.customize(max_occurs="unbounded")),
        ('attributes', Attribute.customize(max_occurs="unbounded",
                                                        sub_name="attribute")),
    ]

SimpleType.append_field('restriction', Restriction)
github arskom / spyne / spyne / interface / wsdl / defn.py View on Github external
sub_name="body")
    soap_header = SoapHeaderDefinition.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                                              sub_name="header")


class SoapOperation(Wsdl11Base):
    soapAction = XmlAttribute(Unicode)
    style = XmlAttribute(Unicode)


class Operation(Wsdl11Base):
    input = OperationMode
    output = OperationMode
    soap_operation = SoapOperation.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                             sub_name="operation")
    parameterOrder = XmlAttribute(Unicode)

class PortType(Wsdl11Base):
    name = XmlAttribute(Unicode)
    operation = Operation.customize(max_occurs="unbounded")


class SoapBinding(Soap11Base):
    style = XmlAttribute(Unicode)
    transport = XmlAttribute(Unicode)


class Binding(Wsdl11Base):
    name = XmlAttribute(Unicode)
    type = XmlAttribute(Unicode)
    location = XmlAttribute(Unicode)
    soap_binding = SoapBinding.customize(sub_ns=xml.NS_WSDL11_SOAP,
github arskom / spyne / spyne / interface / wsdl / defn.py View on Github external
sub_name="operation")
    parameterOrder = XmlAttribute(Unicode)

class PortType(Wsdl11Base):
    name = XmlAttribute(Unicode)
    operation = Operation.customize(max_occurs="unbounded")


class SoapBinding(Soap11Base):
    style = XmlAttribute(Unicode)
    transport = XmlAttribute(Unicode)


class Binding(Wsdl11Base):
    name = XmlAttribute(Unicode)
    type = XmlAttribute(Unicode)
    location = XmlAttribute(Unicode)
    soap_binding = SoapBinding.customize(sub_ns=xml.NS_WSDL11_SOAP,
                                                           sub_name="binding")


class PortAddress(Soap11Base):
    location = XmlAttribute(Unicode)


class ServicePort(Wsdl11Base):
    name = XmlAttribute(Unicode)
    binding = XmlAttribute(Unicode)
    address = PortAddress.customize(sub_ns=xml.NS_WSDL11_SOAP)


class Service(Wsdl11Base):