-
Notifications
You must be signed in to change notification settings - Fork 19
/
context.py
30 lines (25 loc) · 1.06 KB
/
context.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
from .object_serializers import get_default_object_serializer_set
from .contenttype_serializers import get_default_serializer_set
from .response_shape import ResponseShapeSimple
class TransmuteContext(object):
"""
TransmuteContext contains all of the configuration points for a
framework based off of transmute.
It is useful for customizing default behaviour in Transmute, such
as serialization of additional content types, or using different
serializers for objects to and from basic data times.
"""
def __init__(self, serializers=None, contenttype_serializers=None,
response_shape=None):
self.serializers = (
serializers or
get_default_object_serializer_set()
)
self.contenttype_serializers = (
contenttype_serializers or
get_default_serializer_set()
)
self.response_shape = ResponseShapeSimple
# a global context is provided, if a singleton is sufficient
# or deviations from the defaults are unnescessary
default_context = TransmuteContext()