Closed lognaturel closed 1 year ago
I changed
Survey
to get the multiple bindings for a single form element. There used to be axml_binding
method for the current survey element's binding andxml_bindings
for the bindings of the current element and descendants. I now havexml_bindings
for the current survey element's possibly multiple bindings andxml_descendent_bindings
for the bindings of the current element and descendants. I don't think there are regression risks but there's a chance this is being used as a public API. @ukanga @jnm any issues from your ends?
From a quick check, we are not using it directly as a public API. More checks are needed on my end but nothing should hold this work back from our end.
Thanks, @ukanga! If you find there’s an issue, we can make changes, even if it’s after an initial release.
Thanks for the mention, @lognaturel. I don't foresee any problems.
@lognaturel I know this is merged and released but just checking if you still want me to review this per your slack message?
Thanks, @lindsay-stevens! There are two things that I think would be helpful to get your feedback on:
entity
type that the next layers can look for. I put everything else as parameters
. For most other form components, the JSON structure matches the XForm structure. I didn't see any particular need to do that here and it would be awkward given the use of attributes. Interested in another opinion, though.entities
package I introduced. It's new to have a package that represents a domain slice. I think that's appropriate here since the entities spec is this extra layer. It might be a pattern we can use more. I didn't try to establish any reusable infrastructure here and just put entity-related functions in entities_parsing.py. I think it's nice and simple and again maybe a first step we could take to breaking down workbook_to_json
High-level, I really tried not to make things messier and I want to confirm I achieved that. I'm also interested in whether you see any patterns we could/should reuse and/or any missed opportunities to lay useful groundwork.
@lognaturel looks good to me. Some suggestions/notes
get_entity_declaration
type hint could be more specific e.g. Dict[str, Union[str, Dict[str, str]]]entities_parsing
is validation too.entities_parsing
pattern "if isinstance(x, bytes): x = x.encode('utf-8')" probably unnecessary in python3. If it is necessary then there should be a test (the tests pass with these removed).test_dataset_in_entities_sheet__adds_meta_entity_block
is used 7 times, I probably would put them in a separate TestCase, or stack all assertions together in one and comment them.~isort
wants to fix xlsparseutils
, I'll put a fix for that in another PR
Closes #622
Why is this the best possible solution? Were any other approaches considered?
This adds the desired support without increasing the size of
workbook_to_json
. It keeps the entities functionality relatively isolated which aligns well with the idea that this is an optional, experimental spec addition.The
entity
node in the main instance has several attributes that each have bindings. I kept the JSON representation simple by using the existingparameters
dictionary for the various aspects of entities that can be configured. Then I introduced aEntityDeclaration
SurveyElement
to create the attributes and their bindings. That feels better to me than trying to get an XForms-like representation in the json.What are the regression risks?
I changed
Survey
to get the multiple bindings for a single form element. There used to be axml_binding
method for the current survey element's binding andxml_bindings
for the bindings of the current element and descendants. I now havexml_bindings
for the current survey element's possibly multiple bindings andxml_descendent_bindings
for the bindings of the current element and descendants. I don't think there are regression risks but there's a chance this is being used as a public API. @ukanga @jnm any issues from your ends?Does this change require updates to documentation? If so, please file an issue here and include the link below.
https://github.com/XLSForm/xlsform.github.io/issues/232
Before submitting this PR, please make sure you have:
tests
nosetests
and verified all tests passblack pyxform tests
to format code