Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; '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; '"real"': 0.16; '(24,': 0.16; '(8,': 0.16; 'bitbucket': 0.16; 'code?': 0.16; 'from:addr:mhammond': 0.16; 'from:addr:skippinet.com.au': 0.16; 'from:name:mark hammond': 0.16; 'hopeful': 0.16; 'invoking': 0.16; 'makepy': 0.16; 'mark,': 0.16; 'message-id:@skippinet.com.au': 0.16; 'param': 0.16; 'received:internode.on.net': 0.16; 'received:on.net': 0.16; 'subject: \n ': 0.16; 'subject:accessing': 0.16; 'subject:which': 0.16; 'url:html)': 0.16; 'url:oreilly': 0.16; 'void,': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'appears': 0.18; 'subject:) ': 0.20; 'object.': 0.22; 'void': 0.22; 'help.': 0.22; 'cc:2**0': 0.23; 'programming': 0.23; 'work.': 0.23; 'monday,': 0.23; 'to:2**1': 0.23; 'cc:no real name:2**0': 0.24; '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; 'am,': 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; 'thanks': 0.34; 'server': 0.35; 'list': 0.35; 'received:192.168.0': 0.35; 'but': 0.36; 'received:au': 0.36; 'email addr:python.org': 0.36; 'should': 0.36; 'subject: (': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'object': 0.38; 'description': 0.39; 'instead': 0.39; 'takes': 0.39; 'received:192': 0.39; 'little': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'matter': 0.61; 'different': 0.63; 'of:': 0.65; 'received:net.au': 0.65; 'below.': 0.68; 'pain': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAMuqx1B4lJFd/2dsb2JhbAANOL5mgxEBAQEEODYKARALGAkWBAsJAwIBAgFFBgEMAQUCAQGIGadtk3GMSgGEQgOXI5IzgVk Date: Wed, 12 Dec 2012 08:55:06 +1100 From: Mark Hammond User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20121129 Thunderbird/19.0a2 MIME-Version: 1.0 To: bitbucket , comp.lang.python@googlegroups.com Subject: Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params" References: <38a14001-82b6-4a91-b3ad-2cb5c8ee580d@googlegroups.com> <5b228557-2788-4243-b840-5c8aa03d5423@googlegroups.com> In-Reply-To: <5b228557-2788-4243-b840-5c8aa03d5423@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355262914 news.xs4all.nl 6959 [2001:888:2000:d::a6]:34235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34651 On 12/12/2012 2:48 AM, bitbucket wrote: > 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? Seeing the "real" return value is void, it should just be a matter of: settingValue = ob.GetSettingValue("settingName") Mark >