Skip to content

Instantly share code, notes, and snippets.

@zancas
Last active May 19, 2016 04:28
Show Gist options
  • Save zancas/96bee980680440b0f8ddfbc5cf9b667c to your computer and use it in GitHub Desktop.
Save zancas/96bee980680440b0f8ddfbc5cf9b667c to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
class ReplaceDefaultNameMixin(object):
def __getattribute__(self, name):
if name in self._meta_data['override_classes']:
return self._meta_data['override_classes'][name](self)
elif name in self.__dict__:
return self.__dict__[name]
else:
return self.__getattr__(name)
....
and you must add
self._meta_data['override_classes'] = {FOO.__name__: FOO}
to the class that's receiving the mixin...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment