By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

pywin32 com server "cash" question

P: n/a
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



Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sorry: "Cache", not "Cash"

Philippe C. Martin wrote:
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


Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.