1717
1818class Context (UserDict ):
1919 """
20- A dictionary that keeps track of whether it's been used as dictionary
21- or if values has been set with dot notation. We expect things to be set
22- in dot notation so a warning is issued until next major version (1.0)
20+ This class represents the context that will be rendered in a template
21+ and then sent client-side through websockets.
22+
23+ It works just like a dictionary with the extension that you can set and get
24+ data through dot access.
25+
26+ > context.my_data = 'hello'
27+ > context.my_data # 'hello'
2328 """
29+ # NOTE for maintainer
30+ # A dictionary that keeps track of whether it's been used as dictionary
31+ # or if values has been set with dot notation. We expect things to be set
32+ # in dot notation so a warning is issued until next major version (1.0)
2433
2534 def __init__ (self , * args , ** kwargs ):
2635 super ().__init__ (* args , ** kwargs )
@@ -81,6 +90,15 @@ def __setattr__(self, name, value):
8190 super ().__setattr__ (name , value )
8291
8392 def get_context_data (self , * args , ** kwargs ):
93+ """
94+ Fetches the context from the view which the reflex belongs to.
95+ Once you've made modifications you can update the reflex context.
96+
97+ > context = self.get_context_data()
98+ > context['a_key'] = 'some data'
99+ > self.context.update(context)
100+ """
101+
84102 if self .context :
85103 self .context .update (** kwargs )
86104 return self .context
@@ -112,6 +130,7 @@ def get_channel_id(self):
112130
113131 @property
114132 def request (self ):
133+ """A synthetic request used to mimic the request-response cycle"""
115134 factory = RequestFactory ()
116135 request = factory .get (self .url )
117136 request .session = self .consumer .scope ["session" ]
@@ -120,5 +139,10 @@ def request(self):
120139 return request
121140
122141 def reload (self ):
123- """A default reflex to force a refresh"""
142+ """
143+ A default reflex to force a refresh, when used in html it will
144+ refresh the page
145+
146+ data-action="click->MyReflexClass#reload"
147+ """
124148 pass
0 commit comments