I'm having trouble with a module in my program that is supposed to read in the files in a directory and return those with the .xml extension. When I import the module from the command line it works perfectly and will return a different list as soon as I change the contents of the directory. On the other hand, this is not the case when I call it from a cgi script module that displays a web page. I get the right list at first but if I change the contents of the directory there is no change in the list as I refresh the page. Here is what the module looks like:

import os
import re
def findXML():
xML = []
os.system("ls data > xml")
file = open("xml",'r')
lines = file.readlines()
for l in lines:
if re.search("\.xml",l):
return xML
if __name__ == '__main__':

Any ideas would be appreciated :)

Recommended Answers

All 2 Replies

Have you checked into function reload(my_module)?

What happened to your indentations?

Nice thought...but it didn't work! I tried reload both before and after the call but nothing changed. It's especially weird that the page produced by the cgi script does change on refresh after the command line call produces a new list.

Thanx for the attempt :) Any more suggestions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.