asp classic - How to debug Python inside a WSC -
we're programming classic asp big (legacy) web application. works quite using wsc (windows script components) separate gui business logic; wscs contain business logic, classic asp used displaying returned information. wsc's return stringvalues, ado recordsets , in cases vbscript-objects.
currently we're trying switch using vbscript inside wscs python (pyscript), @ least language used modern , has more modern features available (like soap, orm solutions or memcached).
using python code in classic asp works fine using pywin32 , registering python scripting language, we're experiencing 2 fundamental problems:
in wsc, using "implements" tag should make of iis' standard objects (server, session, request, response, etc.) available code inside wsc. when using python, doesn't seem work. maybe i'm using incorrect syntax, or need definitions in python code, can't seem figure out how these objects. more info on wsc's: http://aspalliance.com/414
when error occurs on asp page, traceback displayed in browser , well. however, if error occurs inside wsc, there little or no feedback browser. when using vbscript, windows allows developer choose debugger, , (in our case) visual studio kicks in , shows error , line contains error. works long you're developing locally (so local development machine runs iis). when using python, nothing happens, vague message in browser, i.e:
error '80020009' exception occurred.
i have tried different ways of working around problem; i've tried importing win32traceutil , opening trace collector window. strange thing capture of print() statements, not python error messages. seems though stdout captured, stderr isn't. if there other ways in python redirect or show error messages i'd try too. i've considered using big try..except, besides being bad style, wsc contains bunch of separate functions, , mean implementing try..except in every function. don't want go there.
if can me these 2 problems (especially nr 2 big showstopper using python in our company) appreciated. if there other way make python traceback visible somehow big step forward.
by way, have posted question different mailing lists already, including pywin32 mailing list, until no-one has been able us.
so, me stackoverflow, you're hope...
thanks all,
erik
i have simple example below, consisting of asp page , python wsc, asp page instantiates wsc , calls functions it. response.write not work, because reason response object can't used (problem nr.1), if there error in python code, browser not show tracebackor clear message (problem nr.2). code needs run under iis ofcourse, , python , pywin32 need installed (or activestate python distribution, include pywin32)
python.wsc:
<?xml version="1.0" encoding="windows-1252" ?> <component> <?component error="true" debug="true"?> <registration description="python" progid="python.wsc" version="1.00" classid="{f236f59e-3f6f-44ea-a374-dbfa9f90ecb3}" </registration> <public> <method name="testmethod"> </method> <method name="hellowho"> <parameter name="who"/> </method> </public> <implements type="asp" id="asp"/> <script language="python"> <![cdata[ def testmethod(): response.write('output of results converted string') def hellowho(who): return "hello "+who+"!" ]]> </script> </component>
asp page:
<%@ language=vbscript %> <% set pythonwsc= getobject("script:"&server.mappath("./python.wsc")) response.write(pythonwsc.hellowho("world")&"<br>") pythonwsc.testmethod() %>
as #2, need catch exceptions in vbscript calls component. wsc com component. ignore moment there python running when invoke wsc. it's com component.
errors may occur when invoking component. it's practice when invoking component may fail, use error handling. in vbscript, means on error resume or whatever.
in javascript, means try..catch clause.
curious: why use python in wsc? why not jscript - more mainstream, quite modern.
Comments
Post a Comment