pywin32 com server "cash" question

Philippe C. Martin philippe at philippecmartin.com
Tue Jul 12 13:34:19 EDT 2005


Hi,

I just got the pywin32 "hello world" COM server to install and I did manage
to use it from VB 6.0.

However, there are some glitches I do not comprehend:

1) at one point I got a python runtime error telling me the "testcomserver"
was not found - I got rid of that problem by deleteting the appropriate (I
hope) registry and reregistering the server

2) If I change the source of the server 
from:
return "Hello" + ....
to:
return "Hello my friend " + ....


I still get "Hello BINGO" only in my VB message box. this even if I try to
re-register (which does not seem necessary) the server.


Q.1) What could that error have meant ?
Q.2) is there a way to "flush" whatever so my new code "Hello my friend"
shows up ?




The VB looks like this:

Private Sub Command1_Click()
  Dim shdemo = CreateObject("Python.TestServer")
  MsgBox (shdemo.Hello("BINGO"))
End Sub

The Python server :

class HelloWorld:
    
    _reg_clsid_ = "{7CC9F362-486D-11D1-BB48-0000E838A65F}"
    _reg_desc_ = "Python Test COM Server"
    _reg_progid_ = "Python.TestServer"
    _public_methods_ = ['Hello']
    _public_attrs_ = ['softspace', 'noCalls']
    _readonly_attrs_ = ['noCalls']
    #_reg_class_spec_ = "testcomserver.HelloWorld"
    
    def __init__(self):

        self.softspace = 1
        
        self.noCalls = 0
    
    def Hello(self, who):

        self.noCalls = self.noCalls + 1

        # insert "softspace" number of spaces

        return "Hello My Friend " + " " * self.softspace + str(who)

if __name__=='__main__':
    # ni only for 1.4!
    import  win32com.server.register 
    win32com.server.register.UseCommandLine(HelloWorld)
    import pythoncom
    print pythoncom.CreateGuid()



Regards,

Philippe










More information about the Python-list mailing list