[python-win32] PythonCOM produces errors in WSC script
Peteris_Martinsons@exigengroup.lv
Peteris_Martinsons@exigengroup.lv
Fri, 7 Feb 2003 10:17:44 +0200
This is a multipart message in MIME format.
--=_alternative 002D91E7C2256CC6_=
Content-Type: text/plain; charset="us-ascii"
Hey all!
Trying to move away from VBScript to Python. Still I have a problem:
PythonCOM raises "Not implemented" error if the python code is inside
*.wsc script.
The same code in *.pys file works fine, and the same code from interactive
interpreter also without errors.
If the same is written in VBscript, it works without problems.
The *.wsc script is used as a COM object that takes part in a distributed
transaction, involving MSDTC.
Below are the debug output (DebugView from www.sysinternals.com) and the
contents of the *.wsc file.
Using win32all 152 on Python 2.2.1, win2000 SP2.
Seems that the difference is in some COM interface that gets used in
distributed transactions.
-----------------------------------------------Debug output started
-----------------------------------------------------
[2020] DoEvent started
[2020] Next line fails
[2020] pythoncom error: Python error invoking COM method.
[2020] Traceback (most recent call last):
[2020] File "C:\Python22\lib\site-packages\win32com\server\policy.py",
line 322, in _InvokeEx_
[2020] return self._invokeex_(dispid, lcid, wFlags, args, kwargs,
serviceProvider)
[2020] File "C:\Python22\lib\site-packages\win32com\server\policy.py",
line 652, in _invokeex_
[2020] return self._obj_._dynamic_(name, lcid, wFlags, args)
[2020] File
"C:\Python22\lib\site-packages\win32comext\axscript\client\scriptdispatch.py",
line 46, in _dynamic_
[2020] return self.engine.ApplyInScriptedSection(None, func,
tuple(realArgs))
[2020] File
"C:\Python22\lib\site-packages\win32comext\axscript\client\framework.py",
line 838, in ApplyInScriptedSection
[2020] self.HandleException(codeBlock)
[2020] File
"C:\Python22\lib\site-packages\win32comext\axscript\client\framework.py",
line 925, in HandleException
[2020] self.scriptSite.OnScriptTerminate(None, result_exception)
[2020] pywintypes.com_error: (-2147467263, 'Not implemented', None, None)
--------------------------------------------Debug output
end-------------------------------------------------------------
-------------------------------------------WSC script
start---------------------------------------------------------------
<?xml version="1.0"?>
<component>
<?component error="true" debug="true"?>
<registration
description="VisiFLOW.EventHandler.Legacy.501"
progid="VisiFLOW.EventHandler.Legacy.501"
version="1.00"
classid="{175A8C1F-6617-4c89-BCC7-80C2F7ACFE26}"
>
</registration>
<public>
<method name="DoEvent" dispid="1">
<PARAMETER name="clump"/>
</method>
</public>
<script language="Python">
<![CDATA[
import win32com.client
import string
def DoEvent(clump):
#-- object for printing to debug output
dbg = win32com.client.Dispatch("Scrutil.Debug")
dbg.Print ("DoEvent started")
#-- clump is a com object that stores key-value pairs, written in C++
#-- extract keyword parameters from it
WflID = clump.Value("WORKFLOW_ID")
PrjID = clump.Value("PROJECT_ID")
NodeID = clump.Value("NODE_ID")
ParcelID = clump.Value("PARCEL_ID")
#-- create another container for parameters
clumpParams = win32com.client.Dispatch("VisiFLOW.VO.Clump")
#-- parse unnamed args and store them in com object
ParamsArray = string.split(clump.Value("PARAMETER"), ",")
clumpParams.Put("TARGET_MAILBOX", ParamsArray[1])
clumpParams.Put("TARGET_NODE", ParamsArray[0])
clumpParams.Put ("ADHOC_TARGET")
#-- create another com object written in C++
nameParcel = win32com.client.Dispatch("VisiFLOW.VO.Cognomen")
#-- string operations
strpcog = "//'WORKFLOW/%s/'PARCELS/%s//%s" % (WflID, NodeID, ParcelID)
#-- pass the string to com method
nameParcel.ParseDisplayName (strpcog)
#-- get another com object using a method call
wfRO = nameParcel.BindToObject("WorkflowRouter")
dbg.Print ("Next line fails")
#-- This call fails. Maybe because it receives as parameter another
com object?
#-- It has 4 arguments, only the first is not optional.
narepl = wfRO.PreRouteParcel(nameParcel)
dbg.Print ("Success")
]]>
</script>
</component>
------------------------------------wsc script
end--------------------------------------------------------
-------------------- And this goes to debug output some 10-20 minutes
after last erraneous wsc processing:
[1396] In DllGetClassObject
[1396] CShellExtClassFactory::CShellExtClassFactory()
[1396] CShellExtClassFactory::QueryInterface()
[1396] CShellExtClassFactory::CreateInstance()
[1396] CShellExt::CShellExt()
[1396] CShellExt::QueryInterface()==>IID_IShellExtInit
[1396] CShellExt::AddRef()
[1396] CShellExt::Initialize()
[1396] CShellExt::QueryInterface()==>Unknown Interface!
[1396] CShellExt::QueryInterface()==>Unknown Interface!
[1396] CShellExt::QueryInterface()==>IID_IContextMenu
[1396] CShellExt::AddRef()
[1396] CShellExt::QueryContextMenu()
[1396] CMF_EXPLORE...
[1396] CShellExt::AddRef()
[1396] CShellExt::Release()
[1396] CShellExt::Release()
[1396] CShellExt::QueryInterface()==>Unknown Interface!
[1396] CShellExt::QueryInterface()==>Unknown Interface!
[1396] CShellExt::Release()
---------------------------------------end of debug
output-------------------------------------------------
Regards,
Peteris underscore Martinsons at exigengroup dot lv
--=_alternative 002D91E7C2256CC6_=
Content-Type: text/html; charset="us-ascii"
<br><font size=2 face="sans-serif">Hey all!</font>
<br>
<br><font size=2 face="sans-serif">Trying to move away from VBScript to Python. Still I have a problem: PythonCOM raises "Not implemented" error if the python code is inside *.wsc script.</font>
<br><font size=2 face="sans-serif">The same code in *.pys file works fine, and the same code from interactive interpreter also without errors.</font>
<br><font size=2 face="sans-serif">If the same is written in VBscript, it works without problems.</font>
<br>
<br><font size=2 face="sans-serif">The *.wsc script is used as a COM object that takes part in a distributed transaction, involving MSDTC.</font>
<br><font size=2 face="sans-serif">Below are the debug output (DebugView from www.sysinternals.com) and the contents of the *.wsc file.</font>
<br>
<br><font size=2 face="sans-serif">Using win32all 152 on Python 2.2.1, win2000 SP2.</font>
<br>
<br><font size=2 face="sans-serif">Seems that the difference is in some COM interface that gets used in distributed transactions. </font>
<br>
<br><font size=2 face="sans-serif">-----------------------------------------------Debug output started -----------------------------------------------------</font>
<br><font size=2 face="sans-serif">[2020] DoEvent started</font>
<br><font size=2 face="sans-serif">[2020] Next line fails</font>
<br><font size=2 face="sans-serif">[2020] pythoncom error: Python error invoking COM method.</font>
<br><font size=2 face="sans-serif">[2020] Traceback (most recent call last):</font>
<br><font size=2 face="sans-serif">[2020] File "C:\Python22\lib\site-packages\win32com\server\policy.py", line 322, in _InvokeEx_</font>
<br><font size=2 face="sans-serif">[2020] return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider)</font>
<br><font size=2 face="sans-serif">[2020] File "C:\Python22\lib\site-packages\win32com\server\policy.py", line 652, in _invokeex_</font>
<br><font size=2 face="sans-serif">[2020] return self._obj_._dynamic_(name, lcid, wFlags, args)</font>
<br><font size=2 face="sans-serif">[2020] File "C:\Python22\lib\site-packages\win32comext\axscript\client\scriptdispatch.py", line 46, in _dynamic_</font>
<br><font size=2 face="sans-serif">[2020] return self.engine.ApplyInScriptedSection(None, func, tuple(realArgs))</font>
<br><font size=2 face="sans-serif">[2020] File "C:\Python22\lib\site-packages\win32comext\axscript\client\framework.py", line 838, in ApplyInScriptedSection</font>
<br><font size=2 face="sans-serif">[2020] self.HandleException(codeBlock)</font>
<br><font size=2 face="sans-serif">[2020] File "C:\Python22\lib\site-packages\win32comext\axscript\client\framework.py", line 925, in HandleException</font>
<br><font size=2 face="sans-serif">[2020] self.scriptSite.OnScriptTerminate(None, result_exception)</font>
<br><font size=2 face="sans-serif">[2020] pywintypes.com_error: (-2147467263, 'Not implemented', None, None)</font>
<br><font size=2 face="sans-serif">--------------------------------------------Debug output end-------------------------------------------------------------</font>
<br>
<br><font size=2 face="sans-serif">-------------------------------------------WSC script start---------------------------------------------------------------</font>
<br><font size=2 face="sans-serif"><?xml version="1.0"?></font>
<br><font size=2 face="sans-serif"><component></font>
<br><font size=2 face="sans-serif"><?component error="true" debug="true"?></font>
<br><font size=2 face="sans-serif"><registration</font>
<br><font size=2 face="sans-serif"> description="VisiFLOW.EventHandler.Legacy.501"</font>
<br><font size=2 face="sans-serif"> progid="VisiFLOW.EventHandler.Legacy.501"</font>
<br><font size=2 face="sans-serif"> version="1.00"</font>
<br><font size=2 face="sans-serif"> classid="{175A8C1F-6617-4c89-BCC7-80C2F7ACFE26}"</font>
<br><font size=2 face="sans-serif">></font>
<br><font size=2 face="sans-serif"></registration></font>
<br>
<br><font size=2 face="sans-serif"><public></font>
<br><font size=2 face="sans-serif"> <method name="DoEvent" dispid="1"></font>
<br><font size=2 face="sans-serif"> <PARAMETER name="clump"/></font>
<br><font size=2 face="sans-serif"> </method></font>
<br><font size=2 face="sans-serif"></public></font>
<br>
<br><font size=2 face="sans-serif"><script language="Python"></font>
<br><font size=2 face="sans-serif"><![CDATA[</font>
<br><font size=2 face="sans-serif">import win32com.client</font>
<br><font size=2 face="sans-serif">import string</font>
<br>
<br>
<br><font size=2 face="sans-serif">def DoEvent(clump):</font>
<br><font size=2 face="sans-serif"> #-- object for printing to debug output</font>
<br><font size=2 face="sans-serif"> dbg = win32com.client.Dispatch("Scrutil.Debug")</font>
<br><font size=2 face="sans-serif"> dbg.Print ("DoEvent started")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- clump is a com object that stores key-value pairs, written in C++</font>
<br><font size=2 face="sans-serif"> #-- extract keyword parameters from it</font>
<br><font size=2 face="sans-serif"> WflID = clump.Value("WORKFLOW_ID")</font>
<br><font size=2 face="sans-serif"> PrjID = clump.Value("PROJECT_ID")</font>
<br><font size=2 face="sans-serif"> NodeID = clump.Value("NODE_ID")</font>
<br><font size=2 face="sans-serif"> ParcelID = clump.Value("PARCEL_ID")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- create another container for parameters</font>
<br><font size=2 face="sans-serif"> clumpParams = win32com.client.Dispatch("VisiFLOW.VO.Clump")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- parse unnamed args and store them in com object</font>
<br><font size=2 face="sans-serif"> ParamsArray = string.split(clump.Value("PARAMETER"), ",")</font>
<br><font size=2 face="sans-serif"> clumpParams.Put("TARGET_MAILBOX", ParamsArray[1])</font>
<br><font size=2 face="sans-serif"> clumpParams.Put("TARGET_NODE", ParamsArray[0])</font>
<br><font size=2 face="sans-serif"> clumpParams.Put ("ADHOC_TARGET")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- create another com object written in C++</font>
<br><font size=2 face="sans-serif"> nameParcel = win32com.client.Dispatch("VisiFLOW.VO.Cognomen")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- string operations</font>
<br><font size=2 face="sans-serif"> strpcog = "//'WORKFLOW/%s/'PARCELS/%s//%s" % (WflID, NodeID, ParcelID)</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- pass the string to com method</font>
<br><font size=2 face="sans-serif"> nameParcel.ParseDisplayName (strpcog)</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #-- get another com object using a method call</font>
<br><font size=2 face="sans-serif"> wfRO = nameParcel.BindToObject("WorkflowRouter")</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> dbg.Print ("Next line fails")</font>
<br><font size=2 face="sans-serif"> #-- This call fails. Maybe because it receives as parameter another com object?</font>
<br><font size=2 face="sans-serif"> #-- It has 4 arguments, only the first is not optional.</font>
<br><font size=2 face="sans-serif"> narepl = wfRO.PreRouteParcel(nameParcel)</font>
<br><font size=2 face="sans-serif"> dbg.Print ("Success")</font>
<br><font size=2 face="sans-serif">]]></font>
<br><font size=2 face="sans-serif"></script></font>
<br>
<br><font size=2 face="sans-serif"></component></font>
<br><font size=2 face="sans-serif">------------------------------------wsc script end--------------------------------------------------------</font>
<br>
<br><font size=2 face="sans-serif">-------------------- And this goes to debug output some 10-20 minutes after last erraneous wsc processing:</font>
<br>
<br><font size=2 face="sans-serif">[1396] In DllGetClassObject </font>
<br><font size=2 face="sans-serif">[1396] CShellExtClassFactory::CShellExtClassFactory() </font>
<br><font size=2 face="sans-serif">[1396] CShellExtClassFactory::QueryInterface() </font>
<br><font size=2 face="sans-serif">[1396] CShellExtClassFactory::CreateInstance() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::CShellExt() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>IID_IShellExtInit </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::AddRef() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::Initialize() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>Unknown Interface! </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>Unknown Interface! </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>IID_IContextMenu </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::AddRef() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryContextMenu() </font>
<br><font size=2 face="sans-serif">[1396] CMF_EXPLORE... </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::AddRef() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::Release() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::Release() </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>Unknown Interface! </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::QueryInterface()==>Unknown Interface! </font>
<br><font size=2 face="sans-serif">[1396] CShellExt::Release() </font>
<br>
<br><font size=2 face="sans-serif">---------------------------------------end of debug output-------------------------------------------------</font>
<br>
<br><font size=2 face="sans-serif">Regards,</font>
<br><font size=2 face="sans-serif">Peteris underscore Martinsons at exigengroup dot lv</font>
--=_alternative 002D91E7C2256CC6_=--