do not fail on forms without category

This commit is contained in:
Frédéric Péters 2014-06-04 14:27:37 +02:00
parent 9cc48f4cf9
commit 140867e505
1 changed files with 2 additions and 1 deletions

View File

@ -17,7 +17,8 @@ pub._set_request(wcs.qommon.http_request.HTTPRequest(None, {}))
pub.get_request().environ['SCRIPT_NAME'] = ''
xml = ET.parse(sys.argv[1]).getroot()
xml.remove([x for x in xml.getchildren() if x.tag == 'category'][0])
if [x for x in xml.getchildren() if x.tag == 'category']:
xml.remove([x for x in xml.getchildren() if x.tag == 'category'][0])
formdef = wcs.formdef.FormDef.import_from_xml_tree(xml, charset='utf-8')
wcs_admin_page = LocalFormDefPage(formdef)
print wcs_admin_page.get_preview()