ActivePython2.0 - Server Side objects for ASP problem

Syver Enstad syver at NOSPAMcyberwatcher.com
Thu Jan 11 08:04:36 EST 2001


I've successfully mixed languages with Python ASP, tell me if you want to
know how.

"Satheesh Babu" <vsbabu at erols.com> wrote in message
news:93k6k5$1g7$1 at bob.news.rcn.net...
> Hi Steve,
>
> That worked! Thanks...
>
> My actual requirement is not to gather HTML pages (I've one for that in
100%
> python ASP
> and by setting a BASE HREF, it works fine). I have this proprietary
software
> from a vendor
> which runs a server on some port and it accepts some commands on that
port.
> My requirement
> is to generate these commands on the fly, send it to this server and get
> response, from many
> ASP pages. I don't know how to do network programming in ASP/VBScript. In
> Python I've
> already written something which works, using socket library. My initial
> thought was to embed
> that Python code into my ASP scripts - won't work since ASP (atleast my
> installation) doesn't
> allow mixing of different languages. Making a COM object on the server is
> also beyond me.
> So, I got this idea and was just checking it out.
>
> Many thanks again
>
>
> --
> v.s.babu
> vsbabu at erols.com
> http://vsbabu.csoft.net
> "Steve Holden" <sholden at holdenweb.com> wrote in message
> news:tK876.2719$24.38513 at e420r-atl2.usenetserver.com...
> > "Satheesh Babu" <vsbabu at erols.com> wrote in message
> > news:93j0qi$7cv$1 at bob.news.rcn.net...
> > > Hi,
> > >
> > > I'm trying to use a server side python object to be called from a
> VBScript
> > > ASP code.
> > > It works nicely for simple things. When I try to use urllib functions,
I
> > get
> > > an error. Any
> > > idea? The second function works nicely. I'm using Win98, PWS with
> > Build202.
> > > I'll try
> > > on NT4.0 IIS tomorrow. Any help is greatly appreciated.
> > >
> > > ----------------- ASP file -----------------
> > > <% @LANGUAGE="VBSCRIPT" %>
> > > <!--#include file="pymod.asp"-->
> > > <%= SlurpURL("http://vsbabu.csoft.net/") %>
> > > <%= CapitalizeIt("the first letter should be capitalized") %>
> > >
> > > ----------------pymod.asp------------------
> > > <script language='python' runat='server'>
> > > from urllib import *
> > > from string import *
> >
> > # Is this safe? from module import * is often not a good idea unless
> > # the module has been designed with that in mind...
> >
> > >
> > > def SlurpURL(i_url):
> > >     f = urlopen(i_url)
> >
> > # Try changing preceding line to read f = urlopen(str(i_url))
> >
> > >     o_data = f.read()
> > >     f.close()
> > >     return o_data
> > >
> > > def CapitalizeIt(i_str)
> > >     return capitalize(i_str)
> >
> > # Maybe this would need to be return capitalize(str(i_str)) as well
> >
> > >
> > >
> > > </script>
> > > ------------------ error message -----------------
> > > Python ActiveX Scripting Engine error '80020009'
> > >
> > > Traceback (innermost last): File "<Script Block >", line 4, in
SlurpURL
> f
> > =
> > > urlopen(i_url) File "c:\python20\lib\urllib.py", line 61, in urlopen
> > return
> > > _urlopener.open(url) File "c:\python20\lib\urllib.py", line 166, in
open
> > > return getattr(self, name)(url) File "c:\python20\lib\urllib.py", line
> > 248,
> > > in open_http host, selector = url ValueError: unpack sequence of wrong
> > size
> > >
> > > ?
> > >
> > > host, selector = url
> > >
> > > ======================
> >
> > With the changes above I get *something* other than an error message in
my
> > browser window, but of course because you aren't re-interpreting the
HTML
> as
> > you pass it through, all the links are broken and no graphics appear.
> >
> > You might want to consider adding a <BASE> tag to your page, quoting the
> > original URL and therefore persuading your browser to interpret embedded
> > URLs correctly.
> >
> > regards
> >  Steve
> >
> >
>
>





More information about the Python-list mailing list