Skip to content

Replaced attached properties with hidden database#92

Merged
da-h merged 4 commits intomasterfrom
replaced_attached_properties
Nov 11, 2021
Merged

Replaced attached properties with hidden database#92
da-h merged 4 commits intomasterfrom
replaced_attached_properties

Conversation

@da-h
Copy link
Copy Markdown
Owner

@da-h da-h commented Nov 11, 2021

#Replaced attached properties with hidden database
Attention: This is a breaking change.

This MR changes the way miniflask saves data that relates to the wrapped event functions.

Previously:

  • Wrapped events (functions or classes) were decorated with attributes that specify how the callables are used to construct the actual events
  • Especially, when using classes this may lead to unexpected behavior

To solve this, the event object now contains a hidden _data dictionary that saves this information.
New Behavior:

  • event._data[eventname] contains the dictionary with all information required to construct the events
  • event._data[eventname]["modules"]: list of modules that define the event eventname
  • event._data[eventname]["wrapped_event"]: symlink to event.eventname
  • event._data[eventname]["wrapped_single_events"]: list of all wrapped events in case of non-unique event eventname
  • event._data[eventname]["raw_functions"]: list of all raw functions (as defined in code) in the modules given above (same order as in the modules list)
  • event._data[eventname]["raw_function_args"]: the mf, state and event objects arguments needed for the raw functions

Check all before creating this PR:

  • Documentation adapted
  • unit tests adapted / created

@da-h da-h linked an issue Nov 11, 2021 that may be closed by this pull request
@da-h da-h merged commit 312de42 into master Nov 11, 2021
@da-h da-h deleted the replaced_attached_properties branch November 11, 2021 19:02
github-actions Bot pushed a commit that referenced this pull request Nov 11, 2021
Replaced attached properties with hidden database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't pollute objects with properties / attributes.

1 participant