I am new to turbogears and have an app that I am creating with multiple directories under public/media/ballots. I need to see if a directory exists.
path = "public/media/ballots/" + x['directoryName']
#return path
if os.path.exists(path):
listing = os.listdir(path)
i=0
for infile in listing:
#find path for ballot1, ballot2, etc from files in directory
i +=1
Ballot = "Ballot" +str(i)
x['Ballot']= infile
return x
else:
return "false"
I've tried multiple ways of defining the path: "/media/ballots/", "./media/ballots/", "media/ballots". But the os.path.exists(path) always returns false. I'm not sure how TG is accessing the public files.
I had to make the path="projectname/public/media/ballots/"