Re: [comtypes-users] pypy and the comtypes module

2009-02-19 Thread Thomas Heller
[I added comtypes-users to the list of recipients, in case any existing
comtypes users is interested in this]

Amaury Forgeot d'Arc schrieb:
> Hello Thomas, hello to all pypy-ers,
> 
> I'm sure you will be interested to know that the ctypes implementation of pypy
> has matured enough to be able to run the comtypes module,
> at least some of the examples I found on the web site:
> http://starship.python.net/crew/theller/comtypes/
> See the copy of a pypy session below.

Really cool to hear this.  I must say that I sometimes look over the commit 
messages
in the pypy.cvs mailing list (via gmane) and I'm fascinated by the work with 
ctypes
that is done there!

What I fear is that the day is not far where you know much more than myself 
about ctypes ;-)

> Not everything works, though.
> For example, the COMError exception does not give any message,
> some errors are caused by the alternate garbage collector of pypy
> (opposed to the determinism of reference counting),
> and I'm sure that I missed many important details...
> At least it is now possible to run the comtypes test suite: some tests
> even pass ;-)
> 
> Hey, I did not know that ctypes and comtypes where so intricate:
> ctypes obviously has features designed for comtypes only (OUT parameters...)
> and ctypes/__init__.py even tries to import comtypes.server.inprocserver!
> 
> But this was all fun, and I learned a lot about ffi and COM from
> reading the code.
> Thanks for these wonderful modules!
> 
> 
> 
> Python 2.5.2 (61966, Feb 17 2009, 13:39:17)
> [PyPy 1.0.0] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> And now for something completely different: ``who am I and if yes, how many?''
> from comtypes.client import CreateObject
> xl = CreateObject("Excel.Application")
> # Generating comtypes.gen._00020813___C000_0046_0_1_3
> # Generating comtypes.gen._00020430___C000_0046_0_2_0
> # Generating comtypes.gen.stdole
> # Generating comtypes.gen._2DF8D04C_5BFA_101B_BDE5_00AA0044DE52_0_2_1
> # Generating comtypes.gen.Office
> # Generating comtypes.gen._0002E157___C000_0046_0_5_3
> # Generating comtypes.gen.VBIDE
> # Generating comtypes.gen.Excel
> xl.Workbooks.Add()
> 
> xl.Range("E1").Formula = "=SUM(A1:D1)"
> print xl.Range("E1").Value
> 0.0
> xl.Range("A1", "D1").Value = ("Data", 10, 20, 30)
> print xl.Range("E1").Value
> 60.0
> xl.Visible = True
>
> 
> Cheers,
> 

Fantastic!  I wish I had time to use pypy or even participate, but
there is no chance, unfortunately.

-- 
Thanks,
Thomas

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] custom vs. dispatch vs. dynamic=True

2009-02-19 Thread Thomas Heller
Barton schrieb:
> Let me first say that I am having great fun and success with comtypes!

Cool!

> A recent project required a connection to an MS Jet database, so I 
> downloaded adodbapi.  Those guy have their reasons (I suppose) for 
> choosing pywin32 - and providing IronPython (yuck) support.
> 
> Here's what I've been up to:
> Just for fun I replaced adodbapi's pythoncom dispatch with 
> CreateObject("ADODB.Connection") - custom.
> Things went along just fine until I tried to fetch many columns from 
> the db:
> The custom interface returned the expected length list fo rows, but 
> the rows (tuples) were of lenght = 1 containing the corect data for 
> the first column.
> 
> After some time poking around in comtypes and reading the mail list, I 
> tried CreateObject("ADODB.Connection", dynamic=True) .
> Success!! All rows are fetched properly!

> I then decided to re-organize and rename the module - maybe someday 
> breath new life into one of the earlier, sleeping projects -
> adodbapi turns out to be very cumbersome to type and I trying to find 
> a way to work "comtypes" into the name - but I digress...
Let me try to make sure I understand you correctly (being no native english
speaker): you don't like to type the word 'adodapi' ;-) ?
> 
> Once I could see the mechanics of the module, I began to look at the 
> inner workings:
> It seems that comtyps is doing all the type conversion of individual 
> fields of the query result (something that the original module worked 
> very hard at) before the data (list of tuples) arrives.
> 
> So, I'm trying to understand if a "custom" interface should have 
> behaved differently, if this "dynamic" behavior can be explained in a 
> few word, if there are any pitfalls that I may be headed for, and if 
> pythoncom lacks this kind type conversion.

Well. comtypes is very young, compared to pywin32, and 'dynamic=True' is
even much younger.  We have still to understand all the differences
between the three ways that comtypes provides: custom interface,
dynamic dispatch (using the comtypes.client.dynamic module), and
'dynamic=True' (which is using the new comtypes.client.lazybind module).
Ideally they should all behave the same...

I cannot answer your third question 'if pythoncom lacks this kind of type
conversion' since I don't use it any more.

If you can provide a script that exercises some adodb commands, I will
try to convert that into a comtypes unittest and may be able to look
into differences of the three ways.

> I appreciate any thoughts on this.
> Thank you,
> Barton 
> 

-- 
Thanks,
Thomas


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users