<file_sep>Spyne
Lxml
py-money
<file_sep>import logging

from spyne import Application, rpc, ServiceBase, \
	Integer, Decimal, Unicode
from spyne import Iterable
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication

from money.money import Money
from money.currency import Currency

logging.basicConfig(level=logging.DEBUG)


class ShippingService(ServiceBase):
	@rpc(Decimal, Decimal, _returns=Decimal)
	def compute_shipping_cost(self, distance, total_weight):
		cost = Money('5', Currency.EUR) + \
			(Money('0.01', Currency.EUR) + Money('0.05', Currency.EUR) * total_weight) * \
			distance

		return cost.amount


application = Application(
	[ShippingService],
	tns='info802.soap.shipping',
	in_protocol=Soap11(validator='lxml'),
	out_protocol=Soap11()
)

wsgi_app = WsgiApplication(application)
<file_sep>from server import wsgi_app


# App Engine by default looks for a main.py file at the root of the app
# directory with a WSGI-compatible object called app.
# This file imports the WSGI-compatible object of your Django app,
# application from mysite/wsgi.py and renames it app so it is discoverable by
# App Engine without additional configuration.
# Alternatively, you can add a custom entrypoint field in your app.yaml:
# entrypoint: gunicorn -b :$PORT mysite.wsgi
app = wsgi_app

if __name__ == '__main__':
    from wsgiref.simple_server import make_server

    server = make_server('127.0.0.1', 8080, wsgi_app)

    print("listening to http://127.0.0.1:8080")
    print("wsdl is at: http://localhost:8080/?wsdl")

    server.serve_forever()
