win32com and vb

allanc allan_NOSPAMcuenca at nospamyahoo.com
Wed Jun 16 19:59:17 EDT 2004


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



More information about the Python-list mailing list