473,804 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interoperabilit y between VB and Python under ASP



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.

--
Regards, Max.

Jul 18 '05 #1
5 2247
Max Ischenko <ma*@ucmg.com.u a> wrote in message news:<bj******* ***@voodoo.voli a.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.Redire ct 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
Jul 18 '05 #2
bigdog wrote:
Max Ischenko <ma*@ucmg.com.u a> wrote in message news:<bj******* ***@voodoo.voli a.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.


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


Although it isn't (currently) targetted at VBScript, the CVS version of
vb2py might help if you have reasonably sized blocks of VBScript code to
convert. It hasn't been tested on VBScipt specifically but the parser
should work for most things and I'd certainly be interested to hear of
any specific problems with ASP scripts.

Out of the box it won't even recognize code in a .asp page, but I threw
together the following code. I'm not an expert on ASP or VBScript but
even if this is not correct it might point you in the right direction if
you want to try a convert-to-python route ....

test = """
<html>
<%

function factorial(x)
if x = 0 then
factorial = 1
else
factorial = x*factorial(x-1)
end if
end function

%>
</html>
"""

from vb2py.vbparser import parseVB, VBCodeModule
import re

def translateScript (match):
"""Translat e VBScript fragment to Python"""
block = parseVB(match.g roups()[0], container=VBCod eModule())
return "<%%\n%s\n% %>" % block.renderAsC ode()

converter = re.compile(r"\< %(.*?)%\>", re.DOTALL + re.MULTILINE)
print converter.sub(t ranslateScript, test)
.... which should output:

"""
<html>
<%
from vb2py.vbfunctio ns import *

def factorial(x):
if x == 0:
_ret = 1
else:
_ret = x * factorial(x - 1)
return _ret

%>
</html>
"""

You'll need the CVS version to get this to work - the v0.1.1 doesn't
have the full parser and the v0.2 release is a couple of weeks off yet.

If you do decide to try this route, I'd be very interested to hear of
any specific issues that come up with translating ASP/VBScript to Python.
Paul

=============== ==========
Paul Paterson

vb2py :: A Visual Basic to Python Conversion Toolkit
http://vb2py.sourceforge.net

Jul 18 '05 #3

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 .


That's sounds encouraging, thanks. I'd probably go this route.

--
Regards, Max.

Jul 18 '05 #4
Paul Paterson wrote:
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

Although it isn't (currently) targetted at VBScript, the CVS version of
vb2py might help if you have reasonably sized blocks of VBScript code to
convert. It hasn't been tested on VBScipt specifically but the parser
should work for most things and I'd certainly be interested to hear of
any specific problems with ASP scripts.


That's seems like an interesting idea!
While I doubt that the conversion could (or, more appopriately, should)
be done automatically, I'll check out your project, thanks.
If you do decide to try this route, I'd be very interested to hear of
any specific issues that come up with translating ASP/VBScript to Python.


OK.
--
Regards, Max.

Jul 18 '05 #5
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.Redire ct to
the page I'm interested in viewing after the file is updated.


I got a question on this issue.
When modularizing Python code, how does one handle data exchange between
Python snippets?

I mean, you can't store anything complicated in a Session (for
instance). Yeah, I can pickle/unpickle any Python object but that feels
like a kludge. Should I setup some global hash, keyed by SessionID to
store data there?

--
Regards, Max.

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1093
by: Christopher J. Bottaro | last post by:
Python's base64 module encodes and decodes differently than PHP's. Python's docs says that it ahere's to RFC1521 (sept 1993), while PHP's adheres to RFC2045 (nov 1996). Is there any Python module that uses the new standard? Why is Python using the old standard anyways? Thanks.
1
1908
by: j-integra_support | last post by:
Looking for Java/COM interoperability tools? Thousands of companies world-wide are using J-Integra for COM for interoperability between Java and Microsoft COM applications. J-Integra for COM is a pure Java implementation of the DCOM protocol, making it several times faster than Web Services. J-Integra for COM Features: * Access J2EE components from VB, C++, ASPs, etc... * Access COM components from EJBs, Servlets, JSPs, Applets, etc......
1
1380
by: louis | last post by:
Today I got the latest propaganda email from MSFT talking about XML and interoperability. It's been bothering me all day and while the notion of interoperability is good -- the ability to interact with disparate heterogeneous platforms and protocols -- what really bugs me is the choice of words. Interoperability has 8 syllables, only 6 syllables shy of "Supercalifragilisticexpialidocious". Plus Inter implies movement between objects. ...
3
2383
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached response). My first reply directed me to source code migration but I didn't have the source code. The second reply mentioned about .NET interoperability (PInvoke I think) but I MENTIONED THAT I COULDN'T FIND ANY DOCUMENTATION FROM MSDN LIBRARY BASED ON...
0
1078
by: j-integra_support | last post by:
Looking for Java/.NET/CORBA interoperability tools? Intrinsyc Software has just released the latest addition to its popular J-Integra Interoperability Suite... J-Integra Espresso! J-Integra Espresso is a true CORBA solution for the Microsoft .NET framework. This Object Request Broker (ORB) has been written in C# and connects Java and CORBA with the .NET world. J-Integra Espresso has been developed entirely as managed code and can therefore...
6
4271
by: mc | last post by:
Is there an easy way to compile a Python class (or set of classes) into a .DLL that a C# program can call? Or otherwise to use an existing library of Python classes from a C# program as seamlessly as possible?
0
1645
by: Pradnya Patil | last post by:
Hi , I need to export some of the reports to MS EXCEL & MS WORD in a WEB APPLICATION.I also need to LOCK some of the Columns in EXCEL-sheet.Right now I need to run the Interoperability setup on the machine where the software will run.The machine
3
3498
by: Evren Esat Ozkan | last post by:
Hello, I'm trying to encrypt a string with RSA. But it needs to be compitable with Dave's JavaScript RSA implementation*. I'm already read and tried lots of different things about RSA and RSA in Python. But could not produce the same result with the javascript library. My experiments could be seen at: http://dpaste.com/hold/60741/ * JavaScript RSA Library: http://www.ohdave.com/rsa/
8
1524
by: Mailing List SVR | last post by:
Hi, I have to implement a soap web services from wsdl, the server is developed using oracle, is zsi or some other python library for soap interoperable with oracle soa? thanks Nicola
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.