Giter Site home page Giter Site logo

arskom / spyne Goto Github PK

View Code? Open in Web Editor NEW
1.1K 41.0 309.0 12.06 MB

A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.

Home Page: http://spyne.io

License: Other

Python 99.62% Shell 0.36% Ruby 0.03%
python twisted soap http msgpack rpc rpc-framework json api api-rest

spyne's People

Contributors

allexveldman avatar antonagestam avatar ashcrow avatar belasin avatar benasocj avatar beppler avatar bernie avatar caustin avatar dnet avatar dxist avatar ffreckle avatar galuszkak avatar giz avatar luckyluke avatar mvantellingen avatar norox avatar ohj8odah avatar plq avatar pygudev avatar ralienpp avatar rbarrois avatar ropez avatar satyrius avatar specialunderwear avatar trecouvr avatar tseaver avatar ugurcan377 avatar warvariuc avatar xavfernandez avatar zbyte64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spyne's Issues

Avoid python circular imports

When you look through the code you can see lots of: "import rpclib". IMHO This should be avoided at all costs. Many of these imports are actually only for namespace inclusion. This can be changed by:

  1. Moving all namespace variables (ns_*) from "rpclib" to "rpclib.namespace" (or since they are all soap related, to "rpclib.namespace.soap")
  2. Replace all: "import rpclib" with "from rpclib import namespace"
  3. Replace all other "import rpclib" from within the lib

This may not be an issue now, but it came up whilst playing with rpclib 1.1

I'll try to make a patch and create pull request if I have the time.

Unable to import soapmethod in soaplib-0.9.2-alpha2

Hi

I am getting the following error while trying to import soapmethod in soaplib-0.9.2-alpha2.

from SoapService import SoapFolder, soapmethod, String, Integer, Array
ImportError: cannot import name soapmethod

unglobalize soaplib.nsmap and friends

when defining multiple soap applications, inside the same python process, the soaplib.nsmap and friends get crowded fast. it's best for every soap application to have its own nsmap and prefmap.

double and float precision

In the library, conversion of double (float is the same in fact) to xml is not exact. If you send a double and than receive the same double back the result is not exactly the same.

The problem is that str() function is used for float serialization. Python does not guaranty that float(str(x)) == x. One has to use repr() insted, which is guarantied to be roundtrip invariant for IEEE 754.

Consider the following example:
float(str(1./3.)) == (1./3.)
And:
float(repr(1./3.)) == (1./3.)

Make XmlObject serializer work

The XmlObject serializer is the basis for SOAP serializer. But the serializer itself is not working. It can be used to serialize to xml without the soap cruft.

Wrong max_occurs handling for inherited classes

The following code would fail:

class X(ClassSerializer):
    x = Integer(max_occurs="unbounded")

class Y(X):
    y = String

class Service(DefinitionBase):
    @rpc(Y)
    def test(self, Y):
        #  whatsoever

The problem in in ClassSerializer.from_xml. At the moment this is handled as follows:
if mo == 'unbounded' or mo > 1:
value = getattr(inst, key, None)
if value is None:
value = []

But for derived classes the x (in my example) is set to Integer and not to None. You could for example check if:
not(isinstance(value, types.TypeType)) and hasattr(value, "class")
The last "hasattr" check is only necessary for old style classes.

Documentation needs some updating.

I've noticed that the documentation is written around soaplib v0.8.1dev.

I've already begun work on this. But, since soaplib no longer includes a client should the client/calling the service portion of the examples be included? If we need a client is everybody ok with suds being used since it is relatively simple and quick to use.

Fault must have default namespace='http://schemas.xmlsoap.org/soap/envelope/'

I can mistake, but I concluded that:

By default wsgi.Application uses target namespace as namespace for Fault:
s0:Faults0:faultcodeClient/s0:faultcodes0:faultstringpatients_patient.last_name may not be NULL/s0:faultstrings0:detail/s0:detail/s0:Fault

But Fault declared in http://schemas.xmlsoap.org/soap/envelope/ and SOAP must be:
"senv:Fault< faultcode>Client< /faultcode>< faultstring>patients_patient.last_name may not be NULL< /faultstring>< detail>< /detail>/senv:Fault"

Adding method name to faultcode is wrong too (wsgi.py, Application.__handle_soap_request, line 565):
except Exception, e:
if method_name:
fault_code = '%sFault' % method_name
else:
fault_code = 'Server'

See http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383507,
and next paragraph: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383510

is it possible to exclude stacktrace in the fault message?

the problem is in impossible to return isolated fault soap-response. as i can see the every call 'make_soap_fault' with the 'detail' parameter contains the stacktrace data. could it be configurable for suppress the debug info (that is partially private, i think)?

Test suite needs some more love

There are failing tests in the test suite, mostly due to lagging behind api changes.

there are also a few tests failing with "Test something!" exceptions.

currently, 7 out of 49 tests fail.

add option to offer unwrapped (de)serialization

currently, soaplib offers wrapped responses. e.g.

<senv:Body>
    <s6:get_daemon_uuidResponse>
        <s6:get_daemon_uuidResult xsi:type="xs:string">6a3a1506-c9e5-11df-9794-00304892b05a</s6:get_daemon_uuidResult>
    </s6:get_daemon_uuidResponse>
</senv:Body>

it can be desirable to offer unwrapped responses. e.g.

<senv:Body>
    <s6:get_daemon_uuidResult xsi:type="xs:string">6a3a1506-c9e5-11df-9794-00304892b05a</s6:get_daemon_uuidResult>
</senv:Body>

an option can be introduced to control that.

totalDigits restriction

there is no way to create
<xs:simpleType name="mytype">
<xs:restriction base="xs:int">
<xs:totalDigits value="5"/>
/xs:restriction
/xs:simpleType

propagate default namespace

sometimes, it's convenient to have all the objects inside the service's namespace. currently, all objects must have explicit namespace assignments using the __namespace__ class variable.

this was the default behaviour in soaplib-0.8, but in later branches this was changed to automatically inherit module names.

offer a pure python alternative to lxml

some users have expressed concerns towards lxml usage. it's a c module that's not trivial to deploy.

offering a pure-python xml backend support would increase soaplib adoption.

it also must be made clear that this will cause a performance penalty.

Error when running soaplib/examples/classserializer.py

When running this file, I get this assertion error:

Traceback (most recent call last):
  File "tests.py", line 88, in 
    server = make_server('localhost', 7789, Application([UserManager], 'tns'))
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/wsgi.py", line 90, in __init__
    self.build_schema()
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/wsgi.py", line 186, in build_schema
    schema_entries = inst.add_schema(schema_entries)
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/service.py", line 417, in add_schema
    method.in_message.add_to_schema(schema_entries)
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/clazz.py", line 259, in add_to_schema
    v.add_to_schema(schema_entries)
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/clazz.py", line 236, in add_to_schema
    if not schema_entries.has_class(cls):
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/service.py", line 162, in has_class
    ns_prefix = cls.get_namespace_prefix()
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/base.py", line 72, in get_namespace_prefix
    retval = soaplib.get_namespace_prefix(ns)
  File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/__init__.py", line 58, in get_namespace_prefix
    assert ns != "__main__"
AssertionError

Visual Studio code generator (from "soaplib" WSDL) use type String instead of Int

It is because of naming class "Integer".
I add new serializer "Int" in clazz.py (copy of Integer) and use it in @rpc decorator - it works better.
Integer derived from Decimal, and VS code generator use String type to store it.
In http://www.w3.org/2001/XMLSchema "int" and "integer" is different types, so both must present in soaplib, isn't it?

Also .NET XmlSerializer can't parse compound types in SOAP from soaplib.
Do you know reason of this behaviour?

possible enhancement for anyType

It can be helpful to have a kind of anyType that would try to transform to known types. This is not difficult after all, but you have to now the internals of soaplib. For a trivial use it may be to involved to write it yourself. Here is a small example how it could look like:
def fromAny(self, element):
"""
Converts anyType from etree to known types.

        Parameters
        ----------
        element : etree instance (lxml class)
    """
    # if no children => empty
    if len(element) == 0:
        return None

    res = None

    #first see if we have type info in the element
    givenType = element.get(xsi_qname, '')
    givenType = givenType.split(':')[-1]
    if givenType in globals() and .... (check that it inherits ClassSerializer):
        clazz = globals()[givenType]
        try:
            return clazz.from_xml(element)
        except Exception:
            return None

Add support for upper limits

As a general precaution against dos attacks, support for various upper limits should be added.

The two that come to mind is:

  1. maximum number of requests per unit of time per ip address
  2. maximum request size

Fix async support

Soaplib 0.8 had support for async soap services with callbacks. Now that the soaplib soap client is reimplemented, it's time to fix it.

spin off the declarative xml schema code

as the declarative schema definition engine would be of interest to the python xml community in general, it'd be interesting to separate that functionality from soaplib.

Date type parsing error

primitives.py, line 197:
match = _date_pattern.match(text)

_date_pattern is string (not a re object)

Fix by adding _date_re = re.compile(_date_pattern)

add chunked output

it's impossible to parse or return HUGE soap responses with soaplib, as the etree and string representations of both the request and response must be in memory before returning a response.

it'd be nice to adopt a custom xml (de)serializer that'll yield small chunks of code to the output stream instead of returning one big chunk.

add soap 1.2 / wsdl 2.0 support

how compatible are the 1.1 vs 1.2 / 2.0 versions of the soap/wsdl spec? can they coexist inside the same code base?

does anybody need this?

Warning from suds client when using soaplib server

I've opened a ticket over on the suds trac account https://fedorahosted.org/suds/ticket/339 relating to this issue also, not sure if the problem is with the client or the server but hopefully someone from one of the projects can work it out.

Using soaplib-0.9.2-alpha4 helloworld.py

Using suds-0.4 sudsclient.py (https://fedorahosted.org/suds/attachment/ticket/339/sudsclient.py) https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz

2010-08-14 22:33:49,578 [WARNING] append_attribute() @typed.py:118 attribute (type) type, not-found

Suds ( https://fedorahosted.org/suds/ ) version: 0.4 (beta) build: R685-20100513

Service ( Application ) tns="tns"

Prefixes (1)

ns0 = "tns"

Ports (1):

(Application)

Methods (1):

say_hello(xs:string name, xs:integer times, )

Types (3):

say_hello say_helloResponse stringArray

(stringArray){

_type = "s0:stringArray" string[] =

"Hello, Dave", "Hello, Dave", "Hello, Dave", "Hello, Dave", "Hello, Dave",

}

echo_nested_class interop test fails against suds

Traceback (most recent call last):
File "/usr/lib64/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib64/python2.6/wsgiref/validate.py", line 176, in lint_app
iterator = application(environ, start_response_wrapper)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/wsgi.py", line 88, in call
return self.__handle_soap_request(req_env, start_response)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/wsgi.py", line 157, in __handle_soap_request
result_str = self.serialize_soap(service, result_raw)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/_base.py", line 320, in serialize_soap
result_message, self.get_tns(), soap_body)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 168, in get_members
v.to_xml(subvalue, cls.get_namespace(), parent, k)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 156, in get_members
parent_cls.get_members(inst, parent)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 168, in get_members
v.to_xml(subvalue, cls.get_namespace(), parent, k)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 164, in get_members
for sv in subvalue:
TypeError: 'ClassSerializerMeta' object is not iterable

Convert relative to absolute imports

Hi,

IMHO all imports in soaplib should be converted to absolute. Relative imports are discouraged and are not supported in newer python versions.

Thanks

from_xml and to_xml asymmetry, side effects

If we can still break backward compatibility for the 2.0 release, I think we should reconsider the from_xml and to_xml methods. Their names imply they are the reverse of each other, that they should have some kind of symmetry...but they don't. So maybe they should be renamed.

to_xml should be named something like attach_child, since that is what it does. That name would clearly indicate side effects to the objects in the parameters. (I don't like these kinds of side effects but the effort of changing this to use return values is probably too high).

from_xml seems to be about extracting text values from element objects. Why not rename that to str?

type may not be the best name for the type serializer classes.

Having what was formally the serializer renamed/placed in the type package may cause confusion with the python built-in and is probably not the most descriptive name.

It seems that they are closer to a active record style model. I propose we rename the package to something akin to 'model'

Please comment and let me know what you think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.