[PythonReports-checkins] PythonReports/PythonReports template.py, 1.5, 1.6
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2006-12-15 11:36:15
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30077 Modified Files: template.py Log Message: allow empty detail section; fix Layout: require either pagesize or width and height Index: template.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/template.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** template.py 15 Dec 2006 08:30:22 -0000 1.5 --- template.py 15 Dec 2006 11:36:08 -0000 1.6 *************** *** 1,4 **** --- 1,6 ---- """PythonReports Template (PRT) structures""" """History (most recent first): + 15-dec-2006 [als] allow empty detail section; + fix Layout: require either pagesize or width and height 15-dec-2006 [als] group header an footer renamed to title and summary 07-dec-2006 [als] added Rectangle.opaque *************** *** 267,276 **** # pylint: disable-msg=W0613 # W0613: Unused argument 'tree' ! _group = element.find("group") ! _detail = element.find("detail") ! if _group and _detail: raise XmlValidationError("Found both 'group' and 'detail'", element, path) ! elif not (_group or _detail): raise XmlValidationError( "Either 'group' or 'detail' child is required", element, path) --- 269,278 ---- # pylint: disable-msg=W0613 # W0613: Unused argument 'tree' ! _have_group = element.find("group") is not None ! _have_detail = element.find("detail") is not None ! if _have_group and _have_detail: raise XmlValidationError("Found both 'group' and 'detail'", element, path) ! elif not (_have_group or _have_detail): raise XmlValidationError( "Either 'group' or 'detail' child is required", element, path) *************** *** 300,307 **** Group.child_validators["group"] = Group Layout = Validator(tag="layout", prevalidate=Data.collect, ! validate=_need_subgroup_or_detail, ! attributes={ "pagesize": (PageSize, None), "width": (Dimension, None), --- 302,327 ---- Group.child_validators["group"] = Group + def _need_pagesize(tree, element, path): + """Additional validator for "layout" element: check for page dimensions + + Page size may be specified either with the "pagesize" attribute + of with a pair of "width" and "height". If neither is set, it's an error. + + """ + # pylint: disable-msg=W0613 + # W0613: Unused argument 'tree' + if element.get("pagesize"): + return + if element.get("width") and element.get("height"): + return + raise XmlValidationError( + "Must have either 'pagesize' or 'width' and 'height'", element, path) + Layout = Validator(tag="layout", prevalidate=Data.collect, ! validate=( ! _need_pagesize, ! _need_subgroup_or_detail, ! ), attributes={ "pagesize": (PageSize, None), "width": (Dimension, None), |