Dictionary returns in ZSI

For my day job, I am developing a SOAP server in python. I have been using ZSI as a framework, and it is very good. It will, with mod_python, allow you to build a complete application in python (and even without mod_python you can have it as a standalone process). One of the touted features is easy return of lists and dictionaries, without having to declare ComplexTypes classes.

However, it doesn’t quite work. And the not-working-bit is really odd.

If you return a dict, such as the following:

1   return {"uid":23,"gid":993,"cid":333}

Then ZSI creates a SOAP response like:

1     <uid id="1234" xsi:type="xsd:int">23</uid>  
2     <gid id="5678" xsi:type="xsd:int">993</gid>  
3     <cid id="0987" xsi:type="xsd:int">333</cid>

But, if you return a dictionary with values that happen to be the same, as I did with my boilerplate code:

1     return {"uid":"xsd__string",
2             "gid":"xsd__string",
3             "cid":"xsd__string"}

Then it fails. The second and any other instance of any dict key where the value has already been used by another key is empty, and the wrong type:

1     <uid id="1234" xsi:type="xsd:string">xsd__string</uid>  
2     <gid href="#5678"></gid>  
3     <cid href="#0987"></cid>

This can be overcome with liberal use of classes (or subclasses, since most of the time I am returning dicts or lists). It is a bit of a pain in the arse, though. I’ve filed a bug report. And stopped using ZSI. If I found this bug this fast, then I don’t want to know how many more there are. It’s just easier to convert the XML to python objects and back again, and package it up to look like a SOAP request. Which is kind of what SOAP does anyway.

4 GB RAM

Well, the 4GB of PC2-5300 SO-DIMM RAM I ordered arrived today. I got it very cheap on eBay, and was pretty worried about it. But it all seems pretty stable so far - Rember tells me it is all okay, and it seems to be running smoothly.

Upgrading the RAM in a MacBook Pro is a piece of cake - took less than 5 minutes, including waiting for the machine to shut down and then start up after replacing the sticks. Had three small philips head screws to remove, after taking off the battery. Then the RAM came out fairly easy, and the new sticks were in.

I used the 2x 1G sticks from the laptop to upgrade my Media Centre - the Mac Mini (jens) seems to like the doubling of RAM she got too. Having said that, opening the case up was a bit trickier, but took less than 30 minutes anyway. The longest time was spent trying to figure out why the external HDD wouldn’t mount (because I had turned it off), then why it wouldn’t turn on (apparently it needs to be connected to a firewire port first).

The extra RAM in my laptop means I can finally run a VMWare machine without having to set aside 15 minutes for the machine to respond enough to be usable. I know this isn’t just a problem with the particular VM file, since this is a brand new VM. The old one was even worse! Having said that, I’m not about to use it all of the time. Although once it is running, it goes okay, it still consumes a fair chunk of the RAM.

Speaking of RAM use, I’m running a few Dashboard widgets, a couple of which use up 15MB of RAM each. DoBeDo and iStat widget seem to be the culprits. I think I’ll kill DoBeDo - I use Anxiety as my main ToDo viewer, which uses half of the RAM of DoBeDo. It’s just nice that whenever I go into Dashboard it’s there to remind me. I often use iStat widget just to keep a track on stuff, so that can stay too.