[python-win32] Shell extension debugging

Mark Hammond skippy.hammond at gmail.com
Sun Jul 5 02:06:40 CEST 2009


On 4/07/2009 8:48 PM, Gertjan Klein wrote:
> Mark Hammond wrote:
>
>> I haven't caught up with the rest of the thread yet, but in my
>> experience, the shell keeps objects alive for as shorter time as
>> possible.  So you may find a completely new instance is requested for
>> each context menu request (or for each different item selected, or
>> something), so arranging to 'reload' your implementation module may well
>> work.  I've even used the 'Python.Server' object to reload via Exec() calls.
>
> Another quick test confirms that the following works:
>
>      def __del__(self):
>          try:
>              print "Deleting", self.__module__, "module."
>              del sys.modules[self.__module__]
>          except Exception, e:
>              print "Failed:"
>              print e
>
> Now every change I make to the module immediately gets picked up by the
> shell extension. No more killing Explorer! Can you (or anyone) see any
> problems with this?

I'd be inclined to explicitly 'reload(mod)' rather than simply deleting 
it, but yeah, that is the general idea.

Cheers,

Mark


More information about the python-win32 mailing list