Skip to content

Commit cfcd1b3

Browse files
committed
documentation update.
1 parent 7b3504a commit cfcd1b3

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

bson/context.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,45 @@ class InvalidConfiguration(BSONError):
6060
import threading
6161
import copy
6262
class Context(object): # ||:cls:||
63-
'''BSON encoding/decoding configuration context.
63+
"""BSON encoding/decoding configuration context.
64+
65+
**C Extension (De-)Activation**
66+
67+
Encoding/decoding functions are retrieved from :class:`Context`
68+
attributes. The active set of functions can be switched with
69+
:meth:`enable_c`, :meth:`enable_c_encoding`,
70+
:meth:`enable_c_decoding`. Methods :meth:`is_c_enabled`,
71+
:meth:`is_c_encoding_enabled`, :meth:`is_c_decoding_enabled` are
72+
used to determine the active function set.
73+
74+
**Automatic Object Conversion**
75+
76+
:attr:`object_state_hooks` holds parameters for object attributes
77+
that are used, when an object cannot be converted::
78+
79+
[(attribute_name, dict_required), ...]
80+
81+
E.g.::
82+
83+
context.object_state_hooks = [('__bson__', False), ('__getstate__', True), ('__dict__', True)]
84+
85+
If an object attribute is found and provides the :meth:` __call__`
86+
interface, it is invoked as a method, otherwise the attribute
87+
value is used as is.
88+
89+
:attr:`get_object_state` holds a last resort callback to retrieve
90+
an object's state::
91+
92+
valid, result = context.get_object_state(obj, need_dict)
93+
94+
**Context Locking**
95+
96+
The :attr:`lock` attribute is used to serialize access to the
97+
context. It is internally used by the :meth:`__getstate__` and
98+
:meth:`__setstate__` methods.
6499
65100
.. versionadded:: 2.2.1-fork
66-
'''
101+
"""
67102
# class attributes
68103
_attrib_ = list()
69104
_defaults_ = SON((
@@ -81,16 +116,8 @@ class Context(object): # ||:cls:||
81116
('_get_more_message', None),
82117

83118
# object_state_hooks:
84-
# [(attribute_name, dict_required), ...]
85-
# If attribute provides __call__ interface, it is invoked as a method,
86-
# otherwise the attribute is used as is.
87-
# e.g.
88-
# [('__bson__', False), ('__getstate__', True), ('__dict__', True)]
89-
# ('object_state_hooks', [('__bson__', False)]),
90119
('object_state_hooks', []),
91120

92-
# last resort callback to retrieve object state:
93-
# valid, result = get_object_state(obj, need_dict)
94121
('get_object_state', None),
95122

96123
# document class, when context is used as `as_class` parameter

waste_of_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
-s, --stats print profiler statistics
2121
-r, --ref-time=FLOAT reference time
2222
23-
-c, --calibrate calibrate profiler (not needed for cProfile)
23+
--calibrate calibrate profiler (not needed for cProfile)
2424
2525
-q, --quiet suppress warnings
2626
-v, --verbose verbose test output

0 commit comments

Comments
 (0)