win32com and vb

allanc kawenksNO123SPAM at NOSPAMyahoo.ca
Thu Jun 17 06:14:58 EDT 2004


[posted and mailed]

On 16 Jun 2004, you wrote in comp.lang.python:

> allanc <allan_NOSPAMcuenca at 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/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.



More information about the Python-list mailing list