INNER CODE UNIT · Python
DictAsObject
psevensas/DjangoChannelsGraphqlWs · channels_graphql_ws/dict_as_object.py:25
class DictAsObject:
"""Dict wrapper to access keys as attributes."""
def __init__(self, scope):
"""Remember given `scope`."""
self._scope = scope
def _asdict(self):
"""Provide inner Channels scope object."""
return self._scope
# ------------------------------------------------ WRAPPER FUNCTIONS
def __getattr__(self, name):
"""Route attributes to the scope object."""
if name.startswith("_"):
raise AttributeError()
try:
return self._scope[name]