[python-win32] import and asp-python and iis - strange behaviour

Simon Hook simon.j.hook at jpl.nasa.gov
Wed Jun 8 06:00:41 CEST 2005


Mark et al

I cleaned up my example so you do not need to explicity define the 
directory that the .py script is in, provided it is in the same 
directory as the asp script. Is there any way to avoid the 2 import 
statements, "import somefunctions" in order to be able to use reload and 
"from somefunctions import *" to avoid having to say 
somefunctions.importthevalue().

--------------------filelisting1 
gofetch.asp---------------------------------
<%@ LANGUAGE = Python%>
<%
# Add this scripts path to the system path so can import modules in this 
directory
import sys
sys.path.append(Server.MapPath(".")) 
# Import a module with a function returnthevalue
import somefunctions

# When no longer need to reload module set to 0
debug_mode = 1

# Force a reload to ensure any changes to .py files are included
if debug_mode:
   reload(somefunctions)

# Import again so can call by name without "somefuctions."
from somefunctions import *
%>  <%=returnthevalue("okay it works")%>
-------------------------------------------------------------------------

-----------file listing2 somefunctions.py----------------------------------
def returnthevalue(thevalue):
   return thevalue
-------------------------------------------------------------------------

Many thanks,

Simon

Mark Hammond wrote:

>> Also thanks for info on python versus asp. In my previous message 
>> using reload in a python file does work so you do not need to restart 
>> iis everytime but it is probably inefficient?
>>
>
> Having something like:
>
> import foo, bar
>
> debug_mode = 1
>
> if debug_mode:
>  reload(foo)
>  reload(bar)
>
> When finished dev, set debug_mode = 0, then the penalty is very small.
>
> Mark
>


More information about the Python-win32 mailing list