Interoperability between VB and Python under ASP

bigdog msurel at comshare.com
Wed Sep 3 14:55:27 EDT 2003


Max Ischenko <max at ucmg.com.ua> wrote in message news:<bj46f2$kk2$1 at voodoo.volia.net>...
> Hi,
> 
> I've started to develop under Microsoft ASP framework, which allows 
> different lang. used in a ActiveX page. I wonder about possible 
> strategies to use Python modules from VBScript <%%> includes.
> 
> Right now I'm thinking about this approaches:
> - create a COM server in Python to be able to call it from VB.
>    Drawbacks: cumbersome and (probably) slow.
> - pure data exchange. Python code sets some data in global env. that is
>    afterwards read by VB. Drawbacks: very limited in nature.
> - convert all VB pieces that need access to Python modules into Python.
> 
> Have I missed something or could anyone comment on this?
> Discussion is wellcomed.

I've mostly done option 3, converting what I needed to Python. It
results in a lot cleaner code (you can't mix html elements and code
very well, for example, in vb you can put a for loop around a section
of HTML, whereas in Python you can't) and the time it took to convert
the code (not much, really, it's a pretty clean port in most cases)
has been more than paid back in maintainability.

Another thing I've done, rather than just port all the code in a given
piece, is to find things I can modularize and then move only the
pieces to Python that I think make sense. For example, I've got a page
set up that you can dynamically add content to, kind of like a wiki,
but much more structured. The only part that is in Python is the
script that edits the HTML file, as file access and manipulation is so
much easier in Python than in an VBScript. All of the user elements
are either in straight html pages or in asp with vbscript. I post my
results to the Python page, update the file, then Response.Redirect to
the page I'm interested in viewing after the file is updated.

I think your next best bet is creating COM servers, or perhaps using
Python within a CGI app for particular pieces of logic. I would avoid
the data exchange route.

I don't know if this will help, but it might be worth a shot.
http://vb2py.sourceforge.net/ I've never used it myself, I only point
it out as a curiosity I've heard of




More information about the Python-list mailing list