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):
xML.append(l.rstrip(".xml\n"))
return xML
if __name__ == '__main__':
pass
Any ideas would be appreciated :)