spyne.server.twisted.internet - python examples

Here are the examples of the python api spyne.server.twisted.internet taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 View Complete Implementation : tabulate_model_performance.py
Copyright MIT License
Author : se4u
def server_method(args):
    import spyne, twisted
    from twisted.internet import reactor
    from twisted import web
    import urllib
    from spyne.protocol import http
    from spyne.protocol import csv
    from spyne.server import twisted

    clast HelloWorldService(spyne.service.ServiceBase):
        @spyne.decorator.srpc(
            spyne.model.primitive.Unicode,
            _returns=spyne.model.complex.Iterable(
                spyne.model.primitive.Unicode))
        def my_method(path):
            path = urllib.unquote(path)
            model_run_to_total_epochs_map = map_task_to_epochs()
            yield the_printing_method(path, args, model_run_to_total_epochs_map)[1]

    application = spyne.application.Application(
        [HelloWorldService],
        tns='spyne.examples.hello',
        in_protocol=spyne.protocol.http.HttpRpc(validator='soft'),
        out_protocol=spyne.protocol.csv.Csv())

    reactor.listenTCP(
        8729,
        web.server.Site(
            spyne.server.twisted.TwistedWebResource(
                application)),
        interface='0.0.0.0')

    #------------------------------#
    # Where it all comes together. #
    #------------------------------#
    reactor.run()
    return