-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
45 lines (35 loc) · 1.46 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from eve_sqlalchemy.config import DomainConfig, ResourceConfig
from api.models import *
from config import Config, MY_ROOT_DIR
import os
class Settings(Config):
# SERVER_NAME = '0.0.0.0:6000'
DEBUG = True
EMBEDDING = True
PAGINATION_DEFAULT = 1000
PAGINATION_LIMIT = 1000
"""
@RESOURCE_METHODS 端点 支持http 方法 如: http://demo/user
@ITEM_METHODS 端点 支持http 方法 如: http://demo/user/<id>
"""
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PUT', 'PATCH', 'DELETE']
URL_PREFIX = 'api'
IF_MATCH = False # disable etag from http://docs.python-eve.org/en/latest/features.html#concurrency
X_DOMAINS = '*'
X_HEADERS = '*'
HATEOAS = False
ALLOW_UNKNOWN = True # for user.password_hash updated by password
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
STATIC_FOLDER = os.path.join(MY_ROOT_DIR, 'static')
DOMAIN = DomainConfig({
'user': ResourceConfig(User),
'role': ResourceConfig(Role),
'address': ResourceConfig(Address),
}).render()
# dynamic relation cannot be json serialized , relationship backref => model name
DOMAIN['user']['datasource']['projection']['address'] = 0
DOMAIN['address']['schema']['user']['data_relation']['embeddable'] = True
def load_settings(self):
return {name: getattr(self, name) for name in dir(self) if
not name.startswith('__') and not hasattr(getattr(self, name), '__call__')}