#!/usr/bin/env python

import sys, os, cgi, cPickle #, tempfile
from PythonInsideHTML import PIH

import cgitb; cgitb.enable(display=0, logdir='/tmp')

from cgitools import *
from tools import decodeStr

# Retrieve data from user
form = cgi.FieldStorage()

#print cgi_token
#print form

name_dict = cPickle.loads(decodeStr(form.getvalue('name_dict')))
#ids = [int(a[2:] for a in id_vars]
for ftype,v in name_dict.items():
	pth = data_subdirs[ftype].get('name_full', '')
	if not pth: continue
	for rid, fname in v.items():
		if form.has_key(rid): 
			os.remove(os.path.join(pth, fname))

print cgi_token

#print 'hehe<p>', id_vars, ids_to_del, '<p>',form,'<p>'
exec PIH('pages/ui_manage.pih').pythonCode()
