dimagi/commcare-hq — pull request #1651 by mwhite (2013-10-28 23:50:57+00:00)
Title: extract common logic from xform.get_questions()

For the case property reference stuff, I needed to be able to walk over
all of the questions in the form in order to inspect their attributes.
xform.get_questions() already did that, so I've extracted the generic
parts into xform.for_each_leaf_control_node() and
xform.for_each_leaf_data_node().

I've added a test for xform.get_questions() with a form that covers the
basic scenarios.

This change also includes a couple related changes:

- change the wrapped methods on WrappedNode to be actual methods instead
of dynamic attributes. I find it slightly easier to read now (at
least if you didn't already know what it was doing), but more
importantly you won't be dynamically creating these methods for every
single node that you traverse, which in a large form could take a
non-trivial amount of time.

- add a WrappedAttribs class that wraps node.attribs so you can access
namespaced attributes using the same namespace abbreviations (need
this for getting itext stuff with the 'jr' namespace).