[spyne] python exec function doesn't work in module spyne

hou zhehao zhehao.hou at outlook.com
Thu Aug 2 08:33:02 UTC 2018

Dear list:
       I tried to set up a web service, via which the user give a block of python code, and the service feed something back, but it seems the python function exec doesn't work in spyne, here is my code:

#!/usr/bin/env`` python

# encoding: utf8

import logging


from spyne.decorator import srpc

from spyne import Application, rpc, ServiceBase, \

    Integer, Unicode

from spyne import Iterable

from spyne.protocol.http import HttpRpc

from spyne.protocol.json import JsonDocument

from spyne.server.wsgi import WsgiApplication

class Test(ServiceBase):

    @rpc(Integer, _returns=Iterable(Unicode))

    def say_hello(self, times):

        for i in range(times):

            yield "say hello."


    @rpc(Unicode, _returns=Unicode)

    def execcodes(ctx, codes):




if __name__ == '__main__':

    from wsgiref.simple_server import make_server


    application = Application([Test], 'spyne.examples.hello.http',




    wsgi_application = WsgiApplication(application)

    server = make_server('', 22346, wsgi_application)

    logging.info("listening to")

    logging.info("wsdl is at: http://localhost:22346/?wsdl")


I trigger the function execcodes by'a=1\nb=2\nprint(a+b)\n',  there was no error about exec raised, but there was also no print in logging, and I can't find a and b in both locals and globals, so i'm confused whether my codes executed? if it is executed, where can I find the variables?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.spyne.io/archives/people/attachments/20180802/c3cb4b8c/attachment.html>

More information about the people mailing list