__getattr__ and extend COM object

tiddlerdeja at my-deja.com tiddlerdeja at my-deja.com
Wed May 10 14:53:47 CEST 2000


Thanks for that, but I still have some questions.

I makepy.py -i and select "OSAComClient 1.0 Type Library (1.0)"
Which generates:
bash-2.02$ python makepy.py  -i
OSAuctionCOMClient 1.0 Type Library
 {C51A6141-884F-11D2-92D2-0010A4F29F27}, lcid=0, major=1, minor=0
 >>> # Use these commands in Python code to auto generate .py support
 >>> from win32com.client import gencache
 >>> gencache.EnsureModule('{C51A6141-884F-11D2-92D2-0010A4F29F27}', 0,
1, 0)

So, should I be doing:
mod = gencache.EnsureModule('{C51A6141-884F-11D2-92D2-0010A4F29F27}',
0, 1, 0)

??

If my GUID for my COM object changes, I need to change my python script?
Can I not just use some string to represent my COM object? So that if
my GUID changes I don't have to change my python script?

Also, what would:
mod._WhateverMakePySaysItIs

by in this example?

Sorry if I'm being lame here.

In article <a74S4.16386$v85.103279 at news-server.bigpond.net.au>,
  "Mark Hammond" <mhammond at skippinet.com.au> wrote:
> * Use win32com.client.genncache.EnsureModule to get the module object
you
> makpy'd.  eg:
> mod = gencache.EnsureModule(...)
>
> * Implement you class as normal - something like:
>
> class MyWibble( mod._WhateverMakePySaysItIs ):
>   def __getattr__(self, attr):
>     if attr == "WIBBLE":
>       return self.DynamicProperty(attr)
>     else:
>       return mod._WhateverMakePySaysItIs.__getattr(self, attr)
>
> Then use your class, instead of Dispatch("whatever") to create the COM
> object.  Should work like a charm.  After all, it is all just Python
code
> :-)
>
> Mark.
> <tiddlerdeja at my-deja.com> wrote in message
> news:8fa4p1$8jf$1 at nnrp1.deja.com...
> > I have a COM object that I have makepy'd.
> >
> > The COM object has a func DynamicProperty("WIBBLE") which gets
WIBBLE
> > from the DB (acolumn on a table)
> >
> > I'd like to extend my COM object using __getattr__ so that I could
do
> > myobj.WIBBLE
> > instead of
> > myobj.DynamicProperty("WIBBLE")
> >
> > Any suggestions as to how I can do this?
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list