Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Maybe use django like context #68

Open
jbzdak opened this issue Oct 16, 2012 · 1 comment
Open

Maybe use django like context #68

jbzdak opened this issue Oct 16, 2012 · 1 comment

Comments

@jbzdak
Copy link
Contributor

jbzdak commented Oct 16, 2012

Django context is really nice, it is a list of maps.

If we need to get a key from this context it just does something like:

for map in reversed(self.dicts)
    if key in map: 
       return map[key]

If we employed this in Role.context and push a new dict to context everytime someone does with Role.using(other_role):, and then pop it afterwards we would have no unneded keys in context, and my problems with passing settings in context from #67 would be solved (since when exiting using we would have erased stuff added to context by used role) .

Another issue it would sove is that we could have problems with implementing sontext managers for owner and modifiers that are nestable.

However it would break stuff.

@diogobaeder
Copy link
Contributor

Hmmm... interesting, I didn't take a deeper look into the impact of this, but it sounds good to me. So I'd recommend you keep the build running under this implementation change, if you want to try it.

An alternative we have, to avoid inadverted mutations between roles, would be to reference the context to a deepcopy of the original context; For example, we could make the "context" name a @ property method, and make it return the current role context.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants