Created
June 12, 2020 16:58
-
-
Save quis/6980cf93e640badde8baff987da3f5af to your computer and use it in GitHub Desktop.
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
class MinimalModel(): | |
@property | |
@abstractmethod | |
def properties(self): | |
pass | |
def __init__(self, database_object): | |
for property in self.properties: | |
setattr(self, property getattr(database_object, property)) | |
class ApiKey(MinimalModel): | |
properties = ('id', 'secret', 'expiry_time') | |
class MinimalModels() | |
@property | |
@abstractmethod | |
def model(self): | |
pass | |
def __init__(self, database_objects): | |
self.database_objects = list(database_objects) | |
def __getitem__(self, index): | |
return self.model(self.items[index]) | |
class ApiKeys(MinimalModels) | |
model = ApiKeys | |
api_keys = ApiKeys(database_objects) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment