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

Support using Klein instances as class variables to decorate methods. #9

Merged
merged 6 commits into from
Feb 27, 2013

Conversation

dreid
Copy link
Contributor

@dreid dreid commented Feb 21, 2013

No description provided.

if self._instance is None:
self._instance = instance

return self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole method isn't reentrant. I was going to suggest checking self._instance to make sure it wasn't bound to anything, but that breaks if you ever have two instances of the class this Klein is attached to.

@@ -45,9 +45,12 @@ class Klein(object):
@ivar _endpoints: A C{dict} mapping endpoint names to handler functions.
"""

_bound_klein_instances = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a weakref.WeakValueDictionary so it doesn't prevent garbage collection of instances using bound Kleins.

dreid added a commit that referenced this pull request Feb 27, 2013
Support using Klein instances as class variables to decorate methods.
@dreid dreid merged commit 98fc6f7 into master Feb 27, 2013
@wsanchez wsanchez deleted the stateful-handlers branch December 9, 2016 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants