[python-win32] updating a registered com server

Tim Roberts timr at probo.com
Thu Apr 26 22:30:20 CEST 2007


Francesco Guerrieri wrote:
>
> On 4/26/07, *Tim Roberts* <timr at probo.com <mailto:timr at probo.com>> wrote:
>
>>
>>     Now, THIS problem may be solvable.  Remember that Python supports
>>     the "reload" function that forces it to reload a new version of
>>     an imported module.  It can't change any objects that have
>>     already been created, but it may be able to help you with this
>>     specific problem.  You would have to write your main server in
>>     such a way that you could signal it to reload modules, but that's
>>     a solvable problem.
>
>  
> yes I think that this is the same suggestion which Niki Spahiev gave
> me, and in fact is the setup which I am trying to realize. I still
> have to find a nice way to do it. For instance I planned to make use
> of reflection (getattr....) to obtain the reference but this would
> make it awkward to call the server:
> In vba I would like to call something like that
>  
> set server = CreateObject(myPythonServer)
> server.myPyFunct(my arguments)
>  
> but if I use getattr, I would find myself calling
>  
> server.wrapper(myPyFunct my arguments)
>  
> because in the server my idea would be to have something like
>  
> try:
>     getattr(myPyFunct)(my arguments)
> except:
>     raise COMException("You don't know how to program properly under
> Win!")

You don't have to expose the fact that your server is forwarding on to
another object.  You can still call server.myPyFunct, and have that
function check to see whether the module has changed, and then call the
real handler.

However, NONE of this will allow to you change the behavior of an object
that already exists.  That's simply impossible.  Once Excel has created
a server object, you're locked in until you free the object.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list