__getattr__ and extend COM object

Mark Hammond mhammond at skippinet.com.au
Tue May 9 22:49:42 EDT 2000


* 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.





More information about the Python-list mailing list