Created
April 20, 2020 11:04
-
-
Save Mc01/88eb20dae45d937dfceff6b74e465a2a to your computer and use it in GitHub Desktop.
Microframework ideas
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 HTTP: | |
Create = 0 | |
List = 1 | |
Retrieve = 2 | |
Update = 3 | |
Delete = 4 | |
class App: | |
def __init__(self, **kwargs): | |
self.urls = {} | |
class Field: | |
class Integer: | |
def __init__(self, **kwargs): | |
pass | |
class Permission: | |
AllowAny = 0 | |
""" | |
Imports | |
""" | |
# app.py | |
app = App() | |
# validation.py | |
def fake_attribute(): | |
return | |
def less_than_200(value): | |
return value < 200 | |
# models.py | |
class Model: | |
# db fields | |
attribute = Field.Integer( | |
# defaults | |
default=100, | |
# validation | |
validation=less_than_200, | |
faker=fake_attribute, | |
) | |
class Meta: | |
# db | |
collection = 'models' | |
# api | |
http = [HTTP.Create, HTTP.List, HTTP.Retrieve] | |
http__permissions = [Permission.AllowAny] | |
# docs | |
docs__request__examples = { | |
HTTP.Create: { 'attribute': 150 }, | |
} | |
docs__response__examples = { | |
HTTP.List: [ | |
{'id': 1, 'attribute': 150}, | |
{'id': 2, 'attribute': 160}, | |
], | |
HTTP.Retrieve: {'id': 1, 'attribute': 150}, | |
} | |
# crud + dash analysis | |
admin_dashboard = '' | |
# urls.py | |
app.urls['/models'] = Model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment