Skip to content

Move parent attribute from SurveyElement to relevant subclasses #751

@lindsay-stevens

Description

@lindsay-stevens

As noted here, not all SurveyElement subclasses will have a meaningful or useful parent assigned. This attribute should be moved to the subclasses where a parent is relevant, so that it is clear which objects should have this property. This should also reduce memory usage by removing an unnecessary attribute descriptor from every choice item (Option).

Consideration needs to be given to methods that reference the parent attribute i.e. the logic within these methods, and sensible location for them - such as helper functions or a mixin class. For example in SurveyElement, ._link_children(), .iter_ancestors(), .to_json_dict(), etc.

From a quick look it seems like the following use parent:

  • EntityDeclaration: child of GroupedSection(name="meta")
  • ExternalInstance: child of Survey
  • GroupedSection: child of Survey / GroupedSection / RepeatingSection
  • Question: child of Survey / GroupedSection / RepeatingSection
  • RepeatingSection: child of Survey / GroupedSection / RepeatingSection
  • Tag: child of OsmUploadQuestion

The following do not:

  • Section: not instantiated directly. Survey is a subclass so parent can't be here.
  • Survey: this is the top-most object
  • Option: these belong to an Itemset but are not nestable like Question / GroupedSection / RepeatingSection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions