#!/usr/bin/python
import cgi, os, os.path, time, re
lockFileName = "files/todolock"
fileName = "files/todos.xml"
while(os.path.exists(lockFileName)):
time.sleep(.25)
lockFileHandle = open(lockFileName, "w")
lockFileHandle.write("locked")
lockFileHandle.close()
form = cgi.FieldStorage()
catToUpdate = form.getfirst("category")
isUpMove = int(form.getfirst("isUp"))
#catToUpdate = "Pending"
#isUpMove = 0
oldFile = open(fileName, 'r')
oldFileLines = oldFile.readlines()
oldFile.close()
catStartRe = re.compile(r'^' % catToUpdate)
catEndRe = re.compile(r'^')
otherCatStartRe = re.compile(r'^