开发者

Using Ladon in Python 2.6 on windows

I have been trying to create a web service out some python scripts, and haven't seemed to have had much luck. I am new to web services in general, but would really like to get this figured out. I'm on Windows 7 and use IIS7. The service also needs to be SOAP.

I've read through most posts that have anything to do with python and SOAP and tried out pretty much all the different libraries, but most of them just seem over my head (especially ZSI/SOAPpy). The Ladon Library seems like it would be best (and simplest) for what I need, but the tutorial http://www.youtube.com/watch?v=D_JYjEBedk4&feature=feedlik loses me at 5:10 when he brings it to the server. When I type the ladon2.6ctl in the cmd, it seems like windows gets quite confused. I'm guessing it is a little different because he is running on Linux and using Apache.

With that, any tips on how to get a python web service running on Microsoft 'stuff' would be greatly appreciated, as I have been trying to figure this stuff out for way too long.

One thing to note is the reason things are so specific (and seemingly strange) is because the scripts I have do a lot of geoprocessing with ESRI's "arcpy".

--Addition--

Traceback on localhost:8080/TestService:
Traceback (most recent call last):
  <br>File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\server\wsgi_application.py", line 229, in __call__
    exec("import %s" % ','.join(self.service_list))
  File "<strin开发者_如何学JAVAg>", line 1, in <module>
  File "c:\Users\r\workspace\ladon\src\testspace.py", line 3, in <module>
    class TestService2(object):
  File "c:\Users\r\workspace\ladon\src\testspace.py", line 4, in TestService2
    @ladonize(int,int,rtype=int)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\decorator.py", line 87, in decorator
    ladon_method_info = global_service_collection().add_service_method(f,*def_args,**def_kw)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 119, in add_service_method
    sinfo = self.source_info(src_fname)
  File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 79, in source_info
    a = ast.parse(src)
  File "c:\Python26\ArcGIS10.0\lib\ast.py", line 37, in parse
    return compile(expr, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
     from ladon.ladonizer import ladonize

^
 SyntaxError: invalid syntax

sample code:

from ladon.ladonizer import ladonize

class TestService2(object):
    @ladonize(int,int,rtype=int)
    def sum(self,a,b):
        '''add two numbers<br>
        param a: number 1
        param b: number 2
        rtype: sum of result
        '''
        return a+b


I must admit I normally use Linux for almost everything and I haven't tried Ladon on Windows for a while. I will spin up my windows installation later today and see if there is any trouble.

You wrote that ladon2.6ctl get's confused. Do you have an exception Traceback?


To summarize the fix for anyone else interested, delete the "syslog import" from these 3 ladon modules:
ladon/interfaces/jsonwsp.py - line 6
ladon/dispatcher/dispatcher.py - line 7
ladon/server/wsgi_application.py - line 37

Then, you need to change the linefeed from window's default of /r/n to /n. In Eclipse, go to Window -> Preferences -> General, then select (not drop down) the Workspace tab. On the bottom right, select "other" under New text file line delimiter and change it to Unix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜