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 :)

12 Years
Discussion Span
Last Post by Debbie Webbie

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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.