Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to control the wrapper class #5

Open
thorwhalen opened this issue Nov 16, 2021 · 0 comments
Open

Better way to control the wrapper class #5

thorwhalen opened this issue Nov 16, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@thorwhalen
Copy link
Member

thorwhalen commented Nov 16, 2021

The use of Store.wrap to wrap stores led to some design difficulties when wrapping objects that have methods, other than those of MutuableMapping that use (as inputs or outputs) keys or values.

This happened in the context of our work on Mapping Views and mongodol.

@valentin-feron; you can add more detail if you want.

In order to repair this, a wrapper argument was added to kv_wraps, used like this:

wrapper = wrapper or Store
...
return wrapper.wrap(store, class_trans=class_trans)

The problem here is that this method obliges us to add this wrapper argument in all our store wrappers -- or at least those who use Store.wrap.

One way to mitigate this would be to make the store_decorator add that argument (and it's handling).

Another way would be to not include this wrapper argument in the wrapping functions at all, but instead, have them look for
a hook in the object they're wrapping. Which would result in the above code being replaced by:

wrapper = getattr(store, 'wrap') or Store.wrap
...
return wrapper(store, class_trans=class_trans)

┆Issue is synchronized with this Asana task by Unito

@thorwhalen thorwhalen added the enhancement New feature or request label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants