3.6.3. Context Objects#
-
PyTypeObject CpContext_Type#
The type object for the
CpContextObjectclass.
-
type CpContextObject#
C implementation of the Python equivalent. Represents a context object with attribute-style access, which also conforms to the context protocol.
-
int CpContext_CheckExact(PyObject *op)#
Checks if the given object is an
CpContextObject.
-
int CpContext_Check(PyObject *op)#
Checks if the given object is instance of an
CpContextObject.
-
PyObject *CpContext_New(void)#
- Return value: New reference.
Creates a new context and returns it. Returns NULL if an error occurs.
-
PyObject *CpContext_GetDict(PyObject *context)#
- Return value: New reference.
Returns a new reference to the dictionary backing
context. A native context is implemented as a dictionary object with additional protocol helpers.
-
PyObject *CpContext_GetRoot(PyObject *context)#
- Return value: New reference.
Returns a new reference to
context["_root"]when present; otherwise returns a new reference tocontextitself.
-
PyObject *CpContext_GenericGetAttr(PyObject *context, PyObject *path)#
- Return value: New reference.
Resolves a dotted context path. The first path node is read from the context mapping when possible, then remaining nodes are resolved with normal Python attribute access. Returns a new reference or
NULLon error.
-
PyObject *CpContext_GenericGetAttrString(PyObject *context, const char *path)#
- Return value: New reference.
String variant of
CpContext_GenericGetAttr().
-
int CpContext_GenericSetAttr(PyObject *context, PyObject *path, PyObject *value)#
Sets a context path. Single-node paths are written into the context mapping. Dotted paths resolve the parent path first and then assign the final attribute on the resolved object. Returns
0on success and-1on failure.
-
int CpContext_GenericSetAttrString(PyObject *context, const char *path, PyObject *value)#
String variant of
CpContext_GenericSetAttr().
4