pycom: how to expose Python 2.3 property instance as a VARIANT?

T

The Eternal Squire

Hi everyone,

I am wanting to write a Python COM server with a data member created
by using the new Python 2.3
property() built-in function. When I attempt to access the member
through a client, I get
the ComError message saying that I cannot convert type property into a
VARIANT, so it looks
like the default exposure mechanism in pythoncom.dll is not working
properly.

Do you have any suggestions as to how I can wrap the property
properly? I'd much rather not create a
nonstandard pythoncom.dll to do the conversion unless I absolutely
must.

Thanks:

The Eternal Squire

(see below an example sketch of what I intend. I'm well aware that I
need the CLSID, PROGID, and other attributes in my example, let's
assume I did that and that I also know how to register a COM server).

---- cut here ---

class Friend:
'an object that modifies or uses the object which owns it'
def __init__ (self, top):
self.top = top

class SmartValue (Friend):
'an example of a managed attribute of a COM interface'
KEY = 'x'

def __init__ (self, top):
Friend.__init__ (self, top):
self.storage = 0
setattr (self.top, KEY, property (self.get, self.set))
self.top._public_attrs_ += [ self.KEY ]

def get (self):
return self.storage

def set (self, value):
self.storage = value


class COMInterface:
' an example COM interface template'

ELEMENTS = [ ]

def __init__ (self):
[ e (self) for e in self.ELEMENTS ]


class MyInterface (COMInterface):
' an example specific COM interface'

ELEMENTS = [ SmartValue ]

if __name__ == '__main__':
'code to register MyInterface would follow here'

--- cut here ---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top