Created
August 8, 2015 15:14
-
-
Save kannan4k/8ce471b2f635a754be0c to your computer and use it in GitHub Desktop.
This file contains 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
class Model(object): | |
accessors = {} | |
def __init__(self, hash = None, options = {}): | |
self._dynamic_accessors = [] | |
if hash: | |
self.__class__.mass_assign(self, hash, {}) | |
@classmethod | |
def add_field(cls, fname, type_f, options={}): | |
setattr(cls, fname, None) | |
if not cls.__class__.accessors: | |
cls.__class__.accessors[cls.__class__] = [] | |
exclude = options.get('exclude', []) | |
cls.__class__.accessors[cls.__class__].append({'name': fname, 'type': type_f, 'exclude': exclude}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment