ZSI Notes
Revision as of 10:27, 23 May 2008 by PeterHarding (talk | contribs)
Some Notes from Pywebsvcs-talk@lists.sourceforge.net List
My scrapbook of notes and extracts from the Pywebsvcs mailing list...
alphabetical order of 'self.attribute_typecode_dict'
This should be irrelevant, although order is important for canonicalization for an entirely different matter.
I think you could retain your ordering by replacing the underlying dict with your own dict subclass that maintains a list too.
Topic._attrs = OrderDict()
Something like Collection, although obviously this is a bit old.
from ZSI.wstools.Utility import Collection class Collection(UserDict): """Helper class for maintaining ordered named collections.""" default = lambda self,k: k.name def __init__(self, parent, key=None): UserDict.__init__(self) self.parent = weakref.ref(parent) self.list = [] self._func = key or self.default def __getitem__(self, key): if type(key) is type(1): return self.list[key] return self.data[key] def __setitem__(self, key, item): item.parent = weakref.ref(self) self.list.append(item) self.data[key] = item def keys(self): return map(lambda i: self._func(i), self.list) def items(self): return map(lambda i: (self._func(i), i), self.list) def values(self): return self.list
Newbie Stuff
Upgrade to ZSI-2.1a and this package is no longer required. -josh On May 14, 2008, at 4:02 PM, freeav8r wrote: > Hi all: > > I’m new to ZSI and apache and I’m having > difficulty getting my first ZSI web service up and > running. > > I installed apache with no problems and also installed > mod_python. I ran the mod_python “hello world” > test by changing the httpd.conf file with the > following entry: > > <Directory "C:/Program Files/Apache Software > Foundation/Apache2.2/htdocs/test"> > AddHandler mod_python .py > PythonHandler mptest > PythonDebug On > </Directory> > > The “Hello world” worked fine. > > I tried the mod_python example (2.1.3) found here: > http://pywebsvcs.sourceforge.net/zsi.html > > Because of the apache config entry above, I created > the following to files with the below names: > > ========== mptest.py ========= > from ZSI import dispatch > from mod_python import apache > > import MyHandler > mod = __import__('encodings.utf_8', globals(), > locals(), '*') > mod = __import__('encodings.utf_16_be', globals(), > locals(), '*') > > def handler(req): > dispatch.AsHandler(modules=(MyHandler,), > request=req) > return apache.OK > ========== end mptest.py ======= > > =========MyHandler.py ======== > def hello(): > return "Hello, world" > > def echo(*args): > return args > > def average(*args): > sum = 0 > for i in args: sum += i > return sum / len(args) > ========= end MyHandler.py ======== > > When I request the mptest.py file I get the following > error: > > > File "C:\Program > Files\Python25\Lib\site-packages\ZSI\parse.py", line > 54, in __init__ > from xml.dom.ext.reader import PyExpat > > ImportError: No module named ext.reader > > I'm running python 2.5 and the lastest stable versions > of apache, mod_python, and ZSI. > > > Any ideas? > > -freeav8r
http persistent connection
I think you can do this by using your own transport. Here is the relevant code from client.py: self.h = transport(netloc, None, **self.transdict) self.h.connect() self.SendSOAPData(soapdata, url, soapaction, **kw) So basically you'd need something like a Singleton that delegates to actual transports, so you can maintain these instances between soap calls and reuse the same transport when appropriate. But I'm not sure about the rest, you'll need a transport that implements HTTP persistent connections. Maybe twisted is a better bet than the python httplib. -josh On May 17, 2008, at 2:52 PM, Kleber Carriello de Oliveira wrote: > Sirs, > > I'm trying to use ZSI with http persistent connection, does anyone > know if it's possible? If yes can you send me one example? > > My problem is that I need to call one API about 500 times per > second... I believe that using persistent connection I can reach > this number instead of open and close one tcp connection each time I > do a call. > > Thanks in advance, > > Kleber Carriello > > > Abra sua conta no Yahoo! Mail, o único sem limite de espaço > para armazenamento! > http://br.mail.yahoo.com/
ServiceProxy
> server = ServiceProxy(w, pyclass=True, tracefile=sys.stdout) ZSI 2.0.0 as a whole supports complex type, but there's a serious bug in ServiceProxy in 2.0.0 which prevents using it with asdict=False (ServiceProxy in 2.0.0 doesn't have the pyclass keyword) [1]. I suggest upgrading to 2.1a1 where the broken part of ServiceProxy has been rewritten and now works. [1] Specifically ServiceProxy._call always passes args or kwargs through to binding.Send regardless of what asdict is set to, so that with complex types calls to proxy methods complain that binding.Send is getting tuples (i.e. args) or dicts (i.e. kwargs) instead of the expected complex types.