You might try something like the following for your question #2:

i = Request.querystring("obj")

# enumerate all methods and properties of object obj
#   and provide a linked list  of 

# exec executes a string as if it were a line of code.
exec ('j = ' +  i)
for k in dir(j):
        ...

-----Original Message-----
From: Rohr, Rob [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 26, 2000 4:27 PM
To: '[EMAIL PROTECTED]'
Subject: Python in Active Server Pages


I'm trying to mix scripting languages (even though I know this is
inefficient) in server side processing of Active server pages, so I can
continue to use my old server side include files written in VBScript.  In
the documentation, I found a Client side script that called a VBScript
subroutine using the doc. namespace.

Needless to say, in <SCRIPT LANGUAGE='VBScript' RUNAT='server'> blocks, the
doc namespace won't work.

In an effort to solve the problem, I made use of the dir() command to list
available methods and properties of any object within the context of the
page itself.  I soon ran into a problem.  In an attempt to have a dynamic
page, I started passing the page the name of the object on the command line.
However, when I run the string through the dir() command, I get (naturally)
the methods and properties associated with a string object, rather than the
object named in the string.  Anybody know a way I can resolve a name to the
named object or should I reference this particular question to a generic
Python list?  I've been reading Python FAQs and Tutorials etc. and have been
running web searches but have found precious little relating to Python usage
in ASPs other than the fact that one can.

My upbringing has been in the Microsoft (boo, hiss) world, so my grasp of
the lexicon seems to be such that I only am able to create ineffective
searches.  Any help would be appreciated.

Code samples below:

Question one (referencing VBScript subs in server side includes):
<%@ LANGUAGE="Python" %>
<!--#include virtual="/include/random.inc"-->

<script language='vbscript' runat='server'>
        Sub ShowHead (strTitle)
                Response.Write "<html>"
                Response.Write "<head>"
                Response.Write "<title>" & strTitle & "</title>"
                Response.Write "</head>"
                Response.Write "<body>"
        End Sub
</script>

<%

# A sorry attempt to call the vbscript routine listed above...
ShowHead('Display Server variables.')

# show all HTTP server variables...
for n in Request.ServerVariables:
        Response.write("<b>%s</b>: %s<br>" % (n,
Request.ServerVariables(n)))

Response.write('</body>')
Response.write('</html>')

%>

****************************************

Question two (change a string to an object, assume this listing is saved as
thispage.asp):

<%@ LANGUAGE="Python" %>
<%
# assume object name sent inline with page address as tag obj
# sample: thispage.asp?obj=__builtins__
i = Request.querystring("obj")

# enumerate all methods and properties of object obj
#   and provide a linked list  of 
for k in dir(i):
        Response.write("<b>%s</b>: <a
href='thispage.asp?obj=%s.%s'>%s</a><br>" % (k, i, k, k))

# When obj=ax, gives the results for dir("ax") rather than the results for
dir(ax)
%>

Rob Rohr     mailto:[EMAIL PROTECTED]
UVM - School of Business Administration
http://bsad.uvm.edu/personnel.asp?name=rohr
230 Kalkin Hall  :  (802) 656-0800
Find My Office (IE4 or higher):
     http://bsad.uvm.edu/map/map.asp?find=rohr

_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to