Win32 COM and Collections

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Sun Aug 27 11:54:53 EDT 2000


I'm trying to crack serving up collections through COM with Python as the
Server.

After an earlier question someone pointed me at the promissing module
win32com.server.util, which appears to contain exactly what I'm looking for.

However, after some experimentation, I cannot make it create a simple
collection.

My code follows below and I'd be very grateful for any suggestions as to
what I'm doing wrong.

The 'Test' method works so all the basic COM stuff is OK. The
'CollectionTest' method, however, doesn't seem to return a collection - just
an object - at least that's what VBScript and JScript tell me.

As you can see, I've also tried just returning a simple collection of
strings but with no more success.

Thanks very much.


import win32com.server.util

class Testing:
    _reg_clsid_ = "{771AC26D-3937-4C82-899A-DABFE8661C7F}"
    _reg_desc_ = "Testing Collection"
    _reg_progid_ = "Testing.Collection"
    _public_methods_ = ['Test', 'CollectionTest']

    def Test(self):
        return "The Testing Collection COM server is running."

    def CollectionTest(self):
        data = [ClnTest('a'), ClnTest('b'), ClnTest('c')]
        #data = ['a', 'b', 'c']
        cln = win32com.server.util.NewCollection(data)
        return cln

class ClnTest:
    def __init__(self, data):
        self.val = data

if __name__ == "__main__" :
    print "Registering Testing Collection COM Server..."
    import win32com.server.register
    win32com.server.register.UseCommandLine(Testing)



--
Dale Strickland-Clark
Out-Think Ltd, UK
Business Technology Consultants






More information about the Python-list mailing list