473,378 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Python COM server

I have been trying an example from the Python Programming on Win32 book on the lastest versions of python (2.3.3) and win32all (build 163). I create the COM object and try to call it from VB but i can't seem to create the child.

debugging = 1
if debugging:
from win32com.server.dispatcher import DefaultDebugDispatcher
useDispatcher = DefaultDebugDispatcher
else:
useDispatcher = None

class Parent:
_public_methods_ = ['CreateChild', 'KissChild']
_reg_clsid_= "{E8F7F001-DB69-11D2-8531-204C4F4F5020}"
_reg_progid_ = "PythonDemos.Parent"

def CreateChild(self):
child = Child()
print "Our Python child is", child
wrapped = wrap( child, useDispatcher=useDispatcher )
print "Returning wrapped", wrapped
return wrapped

def KissChild(self, child):
print "KissChild called with child", child
dispatch = win32com.client.Dispatch(child)
print "KissChild called with child named", dispatch.Name

child = umwrap(child)
print "The Python child is", child

class Child:
_public_methods_ = []
_public_attrs_ = ['Name']
def __init__(self):
self.name = "Unnamed"

if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine (Parent, debug=debugging)
This is the error in the Python Trace Collector:

Object with win32trace dispatcher created (object=None)
in <ParentChild.Parent instance at 0x04609BE8>._QueryInterface_ with unsupported
IID IPersistStreamInit ({7FD52380-4E07-101B-AE2D-08002B2EC713})
in <ParentChild.Parent instance at 0x04609BE8>._QueryInterface_ with unsupported
IID IPersistPropertyBag ({37D84F60-42CB-11CE-8135-00AA004BB851})
in _GetIDsOfNames_ with '('CreateChild',)' and '1033'

in _Invoke_ with 1000 1033 3 ()
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\win32com\server\dispatcher.py", line 40, i
n _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 275, in _
Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 280, in _
invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 541, in _
invokeex_
return func(*args)
File "C:\Python23\ParentChild.py", line 16, in CreateChild
child = Child()
NameError: global name 'Child' is not defined
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\lib\site-packages\win32com\server\dispatcher.py", line 129,
in _Invoke_
return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\lib\site-packages\win32com\server\dispatcher.py", line 42, i
n _Invoke_
self._HandleException_()
File "C:\Python23\lib\site-packages\win32com\server\dispatcher.py", line 107,
in _HandleException_
reraise()
File "C:\Python23\lib\site-packages\win32com\server\dispatcher.py", line 40, i
n _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 275, in _
Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 280, in _
invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\lib\site-packages\win32com\server\policy.py", line 541, in _
invokeex_
return func(*args)
File "C:\Python23\ParentChild.py", line 16, in CreateChild
child = Child()
exceptions.NameError: global name 'Child' is not defined
The COM object always seems to fail whenever I call a subclass saying that its not defined. I'm not to sure what the problem is. Any help would be appreciated.

Thanks

David
Jul 18 '05 #1
0 1816

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DeepBleu | last post by:
When one is using an HTML form via a web broswer, the user submits the form contents and these are passed to a CGI Python script on the web server. I need to write a client script that connects to...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
0
by: Phillip J. Eby | last post by:
PEP: 333 Title: Python Web Server Gateway Interface v1.0 Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/27 17:30:09 $ Author: Phillip J. Eby <pje at telecommunity.com> Discussions-To:...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
47
by: Kenneth McDonald | last post by:
Is there any emerging consensus on the "best" UI for toolkit. Tk never quite made it but from what I can see, both qt and wxWin are both doing fairly well in general. I'm already aware of the...
13
by: John Salerno | last post by:
I'm hoping someone can give me the basics for how to do very simple things with Python scripts from within my HTML. For example, I know that I can do this in PHP: <h1>Here is a header</h1>...
28
by: H J van Rooyen | last post by:
Hi, I want to write a small system that is transaction based. I want to split the GUI front end data entry away from the file handling and record keeping. Now it seems almost trivially easy...
15
by: John Nagle | last post by:
I've been installing Python and its supporting packages on a dedicated server with Fedora Core 6 for about a day now. This is a standard dedicated rackmount server in a colocation facility,...
5
by: walterbyrd | last post by:
I don't know much php either, but running a php app seems straight forward enough. Python seems to always use some sort of development environment vs production environment scheme. For...
0
by: GeicoGecko | last post by:
Hey guys, There was no python section in the "Web Development" forum so I'm hoping I can pose my question in here. Our system We currently have a python webserver using SimpleHTTPServer,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.