Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34629

Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

Path csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <coder1024@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'win32': 0.03; 'syntax': 0.03; 'args': 0.04; 'argument': 0.04; 'great.': 0.07; 'params': 0.07; 'supported,': 0.07; 'python': 0.09; '0),': 0.09; 'expected.': 0.09; 'from:name:bitbucket': 0.09; 'to:addr:comp.lang.python': 0.09; 'tuple': 0.09; 'cc:addr:python- list': 0.10; 'def': 0.10; 'subject:python': 0.11; 'library': 0.15; '(24,': 0.16; '(8,': 0.16; 'code?': 0.16; 'hopeful': 0.16; 'invoking': 0.16; 'makepy': 0.16; 'mark,': 0.16; 'param': 0.16; 'subject: \n ': 0.16; 'subject:accessing': 0.16; 'subject:which': 0.16; 'url:html)': 0.16; 'url:oreilly': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'appears': 0.18; 'subject:) ': 0.20; 'object.': 0.22; 'void': 0.22; 'help.': 0.22; 'programming': 0.23; 'work.': 0.23; 'monday,': 0.23; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'appear': 0.26; 'values': 0.26; 'supported': 0.26; 'cc:addr:gmail.com': 0.27; 'cc:2**2': 0.27; 'functions.': 0.27; "doesn't": 0.28; 'noticed': 0.28; 'reply.': 0.28; 'run': 0.28; 'attempted': 0.29; 'python).': 0.29; 'though.': 0.29; 'case,': 0.29; 'convert': 0.29; "i'm": 0.29; 'knows': 0.30; 'function': 0.30; 'december': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'values.': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'server': 0.35; 'list': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'cc:no real name:2**1': 0.36; 'email addr:python.org': 0.36; 'subject: (': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'object': 0.38; 'description': 0.39; 'instead': 0.39; 'received:209.85.214': 0.39; 'takes': 0.39; 'little': 0.39; 'where': 0.40; 'your': 0.60; 'different': 0.63; 'below.': 0.68; 'pain': 0.84; 'received:209.85.214.184': 0.84; 'received:mail- ob0-f184.google.com': 0.84
Newsgroups comp.lang.python
Date Tue, 11 Dec 2012 07:48:53 -0800 (PST)
In-Reply-To <mailman.704.1355188608.29569.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=24.229.66.143; posting-account=_dxy0QoAAAD9TKmsbQw-qXFKhMwXoPgn
References <38a14001-82b6-4a91-b3ad-2cb5c8ee580d@googlegroups.com> <mailman.682.1355173145.29569.python-list@python.org> <ed7dd76c-c1f2-4d33-9e14-41e8be65c29a@googlegroups.com> <mailman.704.1355188608.29569.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 24.229.66.143
MIME-Version 1.0
Subject Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"
From bitbucket <coder1024@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc mhammond@skippinet.com.au, python-list@python.org, bitbucket <coder1024@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.733.1355240942.29569.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355240942 news.xs4all.nl 6883 [2001:888:2000:d::a6]:38635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34629

Show key headers only | View raw


On Monday, December 10, 2012 8:16:43 PM UTC-5, Mark Hammond wrote:
> "out" params are best supported if the object supplied a typelib - then 
> Python knows the params are out and does the right thing automagically. 
>   If out params are detected, the result of the function will be a tuple 
> of (real_result, out_param1, ...)
> 
> Even if no typelib is supported, you can access them with a little pain 
> via the win32com.client.Dispatch() object.  You might like to follow up 
> to the python-win32@python.org mailing list where many people will be 
> able to help.
> 
> HTH,
> 
> Mark

Mark, thanks for the reply.  In this case, I have a type library and attempted to use MakePy but it doesn't seem to be working as expected.

I was reading through CH12 of your Python Programming on Win32 book (http://oreilly.com/catalog/pythonwin32/chapter/ch12.html).  I was hopeful given your description of MakePy that I could get this to work.  It appears that you're saying MakePy will convert "byref" args in a function over to return values.

For example, the IDL in the server includes the following 3 functions.

			[id(1)] void ShowMessage(BSTR msg);
			[id(2)] void GetSettingValue(BSTR settingName, BSTR* settingValue);
			[id(3)] void SetSettingValue(BSTR settingName, BSTR settingValue);

The thorny one is the GetSettingValue since it takes the out param.  When I run MakePy, it generates the below.

	def ShowMessage(self, msg=defaultNamedNotOptArg):
		return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 0),),msg
			)

	def GetSettingValue(self, settingName=defaultNamedNotOptArg, settingValue=defaultNamedNotOptArg):
		return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((8, 0), (16392, 0)),settingName
			, settingValue)

	def SetSettingValue(self, settingName=defaultNamedNotOptArg, settingValue=defaultNamedNotOptArg):
		return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((8, 0), (8, 0)),settingName
			, settingValue)

I noticed that the argument type is different for the out param (16392 instead of 8).  However, it doesn't appear to me that its generating return values instead of args (though I'm not very experienced in python).

I tried invoking these in python.  The ShowMessage and SetSettingValue work great.  I can't get the GetSettingValue to work though.  Perhaps there's a different syntax I need when using the MakePy generated code?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 11:13 -0800
  Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Terry Reedy <tjreedy@udel.edu> - 2012-12-10 15:58 -0500
    Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 13:39 -0800
      Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-10 18:39 -0500
      Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Mark Hammond <skippy.hammond@gmail.com> - 2012-12-11 12:16 +1100
        Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:48 -0800
          Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:54 -0800
          Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:54 -0800
          Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Mark Hammond <mhammond@skippinet.com.au> - 2012-12-12 08:55 +1100
        Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:48 -0800
    Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-10 13:39 -0800
  Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" Paul Kölle <paul@subsignal.org> - 2012-12-11 09:42 +0100
    Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:37 -0800
    Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" bitbucket <coder1024@gmail.com> - 2012-12-11 07:37 -0800

csiph-web