Skip to content

Instantly share code, notes, and snippets.

@alts
Created March 8, 2011 00:10
Show Gist options
  • Save alts/859562 to your computer and use it in GitHub Desktop.
Save alts/859562 to your computer and use it in GitHub Desktop.
New __getattr__ definition
# 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