win32com and vb

A

allanc

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
 
D

David Fisher

allanc said:
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/vbscript/quickref/createobj.html
 
A

allanc

[posted and mailed]

allanc said:
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/vbscript/quickref/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.
 
M

Michel Claveau/Hamster

Hi !
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top