[python-win32] Exception setting a string using COM
Aleksandr VLADIMIRSKIY
aleksandrv at berkeley.edu
Mon Jun 2 18:42:27 CEST 2008
Hello Tim,
Thank you for your reply. I tried to use the setPath method and no luck:
In [26]: item.setPath('')
---------------------------------------------------------------------------
exceptions.AttributeError Traceback (most recent call last)
C:\coe\<ipython console>
c:\python24\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr)
452 args=self._prop_map_get_.get(attr)
453 if args is None:
--> 454 raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
455 return self._ApplyTypes_(*args)
456
AttributeError: '<win32com.gen_py.Expression Media 1.0 Type Library.IMediaItem instance at 0x20535736>' object has no attribute 'setPath'
I did dir(item) and there were no set/get methods, just the ones provided by the application's COM. The item.Path attribute appears to just be a unicode string.
Aleksandr
-----Original Message-----
From: python-win32-bounces+aleksandrv=berkeley.edu at python.org [mailto:python-win32-bounces+aleksandrv=berkeley.edu at python.org] On Behalf Of Tim Roberts
Sent: Friday, May 30, 2008 5:31 PM
To: Python-Win32 List
Subject: Re: [python-win32] Exception setting a string using COM
Aleksandr VLADIMIRSKIY wrote:
> I'm attempting to set a string value using a COM interface to an application. I get the following traceback. Could anyone help me understand the nature of the error or how I might begin to discover it?
> ...
>
> In [11]: item.Path = ""
> ---------------------------------------------------------------------------
> pywintypes.com_error Traceback (most recent call last)
>
> C:\<ipython console>
>
> c:\python24\lib\site-packages\win32com\client\__init__.py in __setattr__(self, attr, value)
> 461 except KeyError:
> 462 raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
> --> 463 self._oleobj_.Invoke(*(args + (value,) + defArgs))
> 464 def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None):
> 465 return _get_good_single_object_(obj, obUserName, resultCLSID)
>
> com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
> 0, -2147467259), None)
>
-2147467259 is 80004005, which is the rather unhelpful E_FAIL.
Sometimes, when it is mapping a settable/gettable property, the Python COM mapper creates a separate method for setting. You might try:
item.setPath( "" )
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32
More information about the python-win32
mailing list