Created
March 8, 2011 00:10
-
-
Save alts/859562 to your computer and use it in GitHub Desktop.
New __getattr__ definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# New __getattr__ definition for bson/dbref.py to support pickling | |
def __getattr__(self, key): | |
# checking for the mangled name. ugly. | |
if '_DBRef__kwargs' in self.__dict__: | |
try: | |
return self.__kwargs[key] | |
except KeyError: | |
pass | |
raise AttributeError("'{0}' object has no attribute '{1}'".format( | |
self.__class__.__name__, key | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment