# HG changeset patch # User Paul Boddie # Date 1354665500 -3600 # Node ID 55e021cabb0bb8946f7f98511910d10d42eea12d # Parent 0065b36bc983b65ec5782c7283f51146121367b2 Added support for conditional regions that require the absence of a field. diff -r 0065b36bc983 -r 55e021cabb0b MoinForms.py --- a/MoinForms.py Mon Dec 03 01:47:09 2012 +0100 +++ b/MoinForms.py Wed Dec 05 00:58:20 2012 +0100 @@ -228,6 +228,8 @@ getFormStructure(body, request, path and ("%s/%s" % (path, section_name)) or section_name, section) elif attributes.has_key("message"): getFormStructure(body, request, path, structure) + elif attributes.has_key("not-message"): + getFormStructure(body, request, path, structure) # Get field details from other kinds of region. @@ -305,6 +307,7 @@ elif format == "form": section_name = attributes.get("section") message_name = attributes.get("message") + absent_message_name = attributes.get("not-message") # Sections are groups of fields in their own namespace. @@ -326,6 +329,12 @@ elif message_name and section.has_key(message_name): output.append(getFormOutput(body, section, path)) + # Not-message regions are conditional on a particular field being + # absent. They reference the current namespace. + + elif absent_message_name and not section.has_key(absent_message_name): + output.append(getFormOutput(body, section, path)) + # Inspect and include other regions. else: