Problems with COM

Roger Upole rupole at compaq.net
Tue Jun 13 22:21:32 EDT 2000


What does the SearchDocuments function look like ?
Couldn't you just create the object in that function, and
then return object.count to the calling function ?

BTW, resultSpace=win32com.client.Dispatch actually
assigns the Dispatch function to resultspace, so you are
passing a function rather than a COM object.

                Roger Upole

"Jean-Louis Couturier" <jean-louis.replacebylastname at ixiasoft.com> wrote in
message news:Wey15.3428$UM2.51434 at weber.videotron.net...
> Problem : I need to access an object created by an OUT variable in a
> function call to a COM object.
> Code example :
>
> import win32com.client
> import pythoncom
>
> _testQueryString="""<?xml version="1.0" encoding="UTF-8"?><query
> VERSION="1.0" RESULTSPACE="R1"><andkey><key
>
NAME="Date"><interval><start><date><year>1996</year><month>January</month><d
>
ay>4</day></date></start><end><date><year>1997</year><month>December</month>
> <day>30</day></date></end></interval></key><key NAME="Full
> Text"><elem>commission</elem></key></andkey></query>"""
>
> def debug(msg):
>     print "[DEBUG]",msg
>
> def get_docbase_service(servername="jeanlouix", docbasename="TEXTML
Demo"):
>     debug("Connecting to COM server")
>     clientService=win32com.client.Dispatch("TextmlServer.ClientServices")
>     debug("Connecting to server "+servername)
>     serverService=clientService.ConnectServer(servername)
>     debug("Connecting to DocBase "+docbasename)
>     docBaseService=serverService.ConnectDocBase(docbasename)
>     return docBaseService
>
> def query_server(docBaseService, queryString):
>     searchService=docBaseService.SearchServices
>     resultSpace=win32com.client.Dispatch
>     debug("Querying... ")
>     searchService.SearchDocuments(queryString,resultSpace)
>     return resultSpace.Count
>
> def main():
>     docBaseService=get_docbase_service()
>     print query_server(docBaseService,_testQueryString)
>
> if __name__=="__main__":
>     print "Testing pyTEXTMLServer"
>     main()
>
> My example above gives the following error on the line "return
> resultSpace.Count":
> AttributeError: Count
> The resultSpace object is a COM object that cannot be created beforehand.
> It has to be placed in a VARIANT that is fed to the function
> SearchDocuments.  How do I do this?  I tried creating a Dispatch object
> without specifying a type but it doesn't seem to work.
>
> Thank you in advance for any solution or direction to relevant
> documentation.
> I will be happy to provide more details if I have not been precise enough.
>
> Jean-Louis Couturier
> Developer
> Ixiasoft
>
>
>
>





More information about the Python-list mailing list