469,323 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

win32com and vb

i have a python module that i've registered as a com server. i also have
a vbscript that i use to test the com server. i have a loop that creates
an instance of the com server on each iteration. but each time it creates
an object it returns the original (cached object), with all the attribute
values intact.

how do i make the python module into a com server that generates a unique
object instance everytime i call CreateObject("python.myPythonModule) in
my vbscript?

psuedocode below:

vbscript:

for i = 1 to len(array)
Set myform = CreateObject("python.Template")
myform.id = array(i)
myform.addtext(lines(i))
end
python:

class POTemplate(BaseDocTemplate):

_reg_clsid_ = "{A1955F6C-09B8-47DD-9809-2D804E430C84}"
_reg_progid_ = "POFAX.POTemplate"
_reg_desc_ = "Generate a PDF of a Purchase Order Form"

_public_methods_ = ['addText']
_public_attrs_ = ['po_no','po_wh','po_dte']

....

import win32com.server.register
win32com.server.register.UseCommandLine(POTemplate )
thanks for all help.

allan
Jul 18 '05 #1
3 1760
allanc <al****************@nospamyahoo.com> writes:
i have a python module that i've registered as a com server. i also
have a vbscript that i use to test the com server. i have a loop
that creates an instance of the com server on each iteration. but
each time it creates an object it returns the original (cached
object), with all the attribute values intact.

how do i make the python module into a com server that generates a
unique object instance everytime i call
CreateObject("python.myPythonModule) in my vbscript?

psuedocode below:

vbscript:

for i = 1 to len(array)
Set myform = CreateObject("python.Template") myform.id =
array(i) myform.addtext(lines(i))
end

[...]
This is really more a vbscript thing that a python thing. Try
explictly deleting the com object in your vbscript.

Set myform = Nothing

"The Set statement assigns the object reference to a variable or
property. The keyword Nothing is used to unassign the object reference
from the variable or property. Good programming techniques require
that you unassign all objects before you exit the program. "

http://www.devguru.com/Technologies/...createobj.html
<{{{*>

Jul 18 '05 #2
[posted and mailed]

On 16 Jun 2004, you wrote in comp.lang.python:
allanc <al****************@nospamyahoo.com> writes:
i have a python module that i've registered as a com server. i also
have a vbscript that i use to test the com server. i have a loop
that creates an instance of the com server on each iteration. but
each time it creates an object it returns the original (cached
object), with all the attribute values intact.

how do i make the python module into a com server that generates a
unique object instance everytime i call
CreateObject("python.myPythonModule) in my vbscript?

psuedocode below:

vbscript:

for i = 1 to len(array)
Set myform = CreateObject("python.Template") myform.id =
array(i) myform.addtext(lines(i))
end


[...]
This is really more a vbscript thing that a python thing. Try
explictly deleting the com object in your vbscript.

Set myform = Nothing

"The Set statement assigns the object reference to a variable or
property. The keyword Nothing is used to unassign the object reference
from the variable or property. Good programming techniques require
that you unassign all objects before you exit the program. "

http://www.devguru.com/Technologies/...createobj.html
<{{{*>


i did try deleting the object as above. to no avail. i'm assuming that the
com server created from my python class can be instantiated by several
processes (or multiple users) and each will have a separate and unique
instance without having to make "special arrangements" in my python class.

i'm planning to use the python class as an activex component in an asp
script. i'm trying to make sure each user will be able to create their own
unique object. i read somewhere that the class attributes need to be
modified in some way (made private? with get/set methods?) so that these
don't get shared across several instances of the object created.
Jul 18 '05 #3
Hi !
python class as an activex component

if you to succeed this, I would be very interested.

For your problem, I obtain a similar behavior. I use a COM-server in
Python, from Paradox. Each call (open) at the COM-server, I obtain the same
object.
If I want another (a different) instance, I must exit and re-run my
application.

But I adapted to that.

* sorry for my bad english *
@-salutations
--
Michel Claveau

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Justin Stockton | last post: by
3 posts views Thread by RJ | last post: by
reply views Thread by Paul McGuire | last post: by
2 posts views Thread by Sibylle Koczian | last post: by
12 posts views Thread by vithi | last post: by
2 posts views Thread by Ray | last post: by
11 posts views Thread by Bill Davy | last post: by
4 posts views Thread by sterling | last post: by
2 posts views Thread by RyanN | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.