ActivePython2.0 - Server Side objects for ASP problem
Steve Holden
sholden at holdenweb.com
Wed Jan 10 21:17:29 EST 2001
"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