Pyro: ActiveState (wind32) to Unix

Tim Golden tim at timgolden.me.uk
Sat Oct 13 05:03:45 EDT 2007


Tim Golden wrote:
> Sells, Fred wrote:
>> I'm using ActiveState python on a windows box to talk to ACtive 
>> Directory.  
>  > I'm running a Pyro Server on the same box.
>>
>> The client is Linux running std Python 2.4.
>>
>> It works just fine until the server codes calls some 
>  > win32com.client api;  then I get
>>

>> ImportError: No module named pywintypes

[followed by private email from Fred containing the
client/server files]

Well it works ok for me running from an XP box to a Ubuntu
VMWare image on the same machine. Since I don't have AD
running on this laptop I made as few changes as possible
to substitute WMI instead which uses the same Python &
Windows tech. infrastructure -- ie you pass a moniker to
win32com.client.GetObject. Obviously there could be something
specific to the AD LDAP: interface here but I seriously doubt
it.

One thing you will have to be aware of -- although I honestly
doubt it's behind the issue here -- is that running a Pyro
server means implictly running in threads. And *that* means
that, since the LDAP: interface is a (D)COM-based interface,
you'll need to call pythoncom.CoInitialize to kick COM into
threading mode. Failing to do that using WMI causes the
mildly bizarre "Syntax error" when you try to do
.GetObject ("wimgmts:..."). It's just possible that the
error you're seeing is the LDAP equivalent. And that
Pyro is trying to pull the error message across the link
to tell you what it is. (Maybe).

In short, then, try adding the line:

   pythoncom.CoInitialize ()

within the proxy's .getProperties method (having imported
pythoncom up to, of course) and then:

   pythoncom.CoUninitialize ()

just before the return in that method.

I've only just realised that this is a thread on the main
python-list. If this goes nowhere here, try copying it
over to the Pyro mailing list; I'm not sure if Irmen
(Mr Pyro) follows this list.

TJG



More information about the Python-list mailing list