473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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 ---
Jul 18 '05 #1
1 2031
Make your class derived from object, such as
class D(object):
def __init__

et***********@comcast.net (The Eternal Squire) wrote in message news:<90**************************@posting.google. com>...
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 ---

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Marco Aschwanden | last post by:
Hi I don't have to talk about the beauty of Python and its clear and readable syntax... but there are a few things that striked me while learning Python. I have collected those thoughts. I am...
3
by: Annie | last post by:
I am trying to call a COM object which expects a variant datatype to be passed in to the COM API object. However, I get "<COMObject <unknown>>" and the program fails. Below is my code in Python,...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
4
by: Vedanta Barooah | last post by:
greetings.... in a python nested class is it possible to change the value of the parent class's variable without actually creating an instance of the parent class, consider this code: class...
7
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of...
0
by: Andrew Ayre | last post by:
Hi, I can't seem to get the library built, and any help is greatly appreciated. Here is the info: Windows XP Borland C++ Builder 5 Latest Boost source code (downloaded at the weekend) Windows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.