Skip to content

Instantly share code, notes, and snippets.

@quis
Created June 12, 2020 16:58
Show Gist options
  • Save quis/6980cf93e640badde8baff987da3f5af to your computer and use it in GitHub Desktop.
Save quis/6980cf93e640badde8baff987da3f5af to your computer and use it in GitHub Desktop.
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