wee 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +75 -0
- data/README +17 -9
- data/Rakefile +2 -2
- data/TODO +20 -0
- data/benchmark/Makefile +14 -9
- data/benchmark/counter.rb +11 -30
- data/benchmark/report_req.rb +12 -0
- data/doc/rdoc/classes/Array.html +12 -12
- data/doc/rdoc/classes/Cache/StorageCache.html +38 -38
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +30 -30
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +24 -24
- data/doc/rdoc/classes/Enumerable.html +6 -6
- data/doc/rdoc/classes/Object.html +12 -12
- data/doc/rdoc/classes/OgApplication.html +126 -0
- data/doc/rdoc/classes/OgScaffolder.html +401 -0
- data/doc/rdoc/classes/OgSession.html +172 -0
- data/doc/rdoc/classes/String.html +12 -12
- data/doc/rdoc/classes/Struct.html +12 -12
- data/doc/rdoc/classes/Wee.html +5 -62
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +9 -9
- data/doc/rdoc/classes/Wee/Application.html +107 -39
- data/doc/rdoc/classes/Wee/Brush.html +22 -18
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +17 -11
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +18 -10
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +30 -64
- data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +8 -10
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +27 -79
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +179 -65
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +16 -18
- data/doc/rdoc/classes/Wee/Brush/ImageTag.html +203 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +17 -11
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +15 -15
- data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +147 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +17 -17
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +25 -50
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +7 -38
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +15 -16
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +65 -50
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +14 -64
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/ToCallback.html +146 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +40 -40
- data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
- data/doc/rdoc/classes/Wee/Canvas.html +24 -24
- data/doc/rdoc/classes/Wee/Component.html +232 -149
- data/doc/rdoc/classes/Wee/Component/OnAnswer.html +153 -0
- data/doc/rdoc/classes/Wee/Decoration.html +42 -42
- data/doc/rdoc/classes/Wee/Delegate.html +27 -27
- data/doc/rdoc/classes/Wee/ErrorResponse.html +12 -12
- data/doc/rdoc/classes/Wee/FormDecoration.html +148 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +6 -6
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +296 -215
- data/doc/rdoc/classes/Wee/HtmlWriter.html +83 -81
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +21 -16
- data/doc/rdoc/classes/Wee/MessageBox.html +180 -0
- data/doc/rdoc/classes/Wee/PageDecoration.html +30 -30
- data/doc/rdoc/classes/Wee/Presenter.html +237 -69
- data/doc/rdoc/classes/Wee/RedirectResponse.html +6 -6
- data/doc/rdoc/classes/Wee/RefreshResponse.html +6 -6
- data/doc/rdoc/classes/Wee/Request.html +18 -18
- data/doc/rdoc/classes/Wee/RequestHandler.html +43 -39
- data/doc/rdoc/classes/Wee/Response.html +24 -24
- data/doc/rdoc/classes/Wee/Session.html +746 -72
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +18 -18
- data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
- data/doc/rdoc/classes/Wee/Utils.html +138 -2
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +7 -7
- data/doc/rdoc/classes/Wee/ValueHolder.html +18 -18
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +43 -68
- data/doc/rdoc/classes/Wee/WrapperDecoration.html +150 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +29 -15
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/application_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components_rb.html +4 -1
- data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/continuation/session_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/continuation_rb.html +116 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/component_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core_rb.html +3 -3
- data/doc/rdoc/files/lib/wee/databases/og_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/session_rb.html +1 -2
- data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/helper_rb.html +1 -8
- data/doc/rdoc/files/lib/wee/utils_rb.html +110 -0
- data/doc/rdoc/files/lib/wee_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +11 -1
- data/doc/rdoc/fr_file_index.html +8 -0
- data/doc/rdoc/fr_method_index.html +269 -228
- data/examples/calculator.rb +69 -0
- data/examples/calendar.rb +5 -17
- data/examples/example.rb +2 -2
- data/examples/hw.rb +17 -0
- data/examples/live-update.rb +45 -0
- data/examples/og-test.rb +51 -0
- data/lib/wee.rb +1 -1
- data/lib/wee/adaptors/webrick.rb +2 -0
- data/lib/wee/application.rb +16 -0
- data/lib/wee/components.rb +3 -0
- data/lib/wee/components/form_decoration.rb +7 -0
- data/{test → lib/wee}/components/messagebox.rb +1 -1
- data/lib/wee/components/page_decoration.rb +5 -5
- data/lib/wee/components/wrapper_decoration.rb +7 -0
- data/lib/wee/continuation.rb +5 -0
- data/lib/wee/continuation/core/component.rb +55 -0
- data/lib/wee/continuation/session.rb +217 -0
- data/lib/wee/core/callback.rb +11 -6
- data/lib/wee/core/component.rb +45 -33
- data/lib/wee/core/presenter.rb +68 -0
- data/lib/wee/databases/og.rb +114 -0
- data/lib/wee/renderer/html/brushes.rb +179 -98
- data/lib/wee/renderer/html/canvas.rb +37 -13
- data/lib/wee/renderer/html/writer.rb +34 -32
- data/lib/wee/requesthandler.rb +6 -3
- data/lib/wee/session.rb +73 -54
- data/lib/wee/utils.rb +5 -0
- data/lib/wee/utils/autoreload.rb +1 -1
- data/lib/wee/utils/cache.rb +0 -2
- data/lib/wee/utils/helper.rb +40 -8
- data/test/components/calltest-cont.rb +16 -0
- data/test/components/calltest.rb +15 -10
- data/test/stress.rb +31 -28
- data/test/stress_and_measure.rb +53 -0
- data/test/stressed_application.rb +15 -0
- data/test/test_html_writer.rb +9 -4
- metadata +236 -195
- data/benchmark/bench.sh +0 -24
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
|
89
89
|
|
|
90
90
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
91
|
+
<a href="#M000227">new</a>
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
|
|
@@ -110,19 +110,19 @@
|
|
|
110
110
|
<div id="methods">
|
|
111
111
|
<h3 class="section-bar">Public Class methods</h3>
|
|
112
112
|
|
|
113
|
-
<div id="method-
|
|
114
|
-
<a name="
|
|
113
|
+
<div id="method-M000227" class="method-detail">
|
|
114
|
+
<a name="M000227"></a>
|
|
115
115
|
|
|
116
116
|
<div class="method-heading">
|
|
117
|
-
<a href="#
|
|
117
|
+
<a href="#M000227" class="method-signature">
|
|
118
118
|
<span class="method-name">new</span><span class="method-args">(location)</span>
|
|
119
119
|
</a>
|
|
120
120
|
</div>
|
|
121
121
|
|
|
122
122
|
<div class="method-description">
|
|
123
123
|
<p><a class="source-toggle" href="#"
|
|
124
|
-
onclick="toggleCode('
|
|
125
|
-
<div class="method-source-code" id="
|
|
124
|
+
onclick="toggleCode('M000227-source');return false;">[Source]</a></p>
|
|
125
|
+
<div class="method-source-code" id="M000227-source">
|
|
126
126
|
<pre>
|
|
127
127
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 41</span>
|
|
128
128
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">location</span>)
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
|
89
89
|
|
|
90
90
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
91
|
+
<a href="#M000204">new</a>
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
|
|
@@ -110,19 +110,19 @@
|
|
|
110
110
|
<div id="methods">
|
|
111
111
|
<h3 class="section-bar">Public Class methods</h3>
|
|
112
112
|
|
|
113
|
-
<div id="method-
|
|
114
|
-
<a name="
|
|
113
|
+
<div id="method-M000204" class="method-detail">
|
|
114
|
+
<a name="M000204"></a>
|
|
115
115
|
|
|
116
116
|
<div class="method-heading">
|
|
117
|
-
<a href="#
|
|
117
|
+
<a href="#M000204" class="method-signature">
|
|
118
118
|
<span class="method-name">new</span><span class="method-args">(message, location, seconds=10)</span>
|
|
119
119
|
</a>
|
|
120
120
|
</div>
|
|
121
121
|
|
|
122
122
|
<div class="method-description">
|
|
123
123
|
<p><a class="source-toggle" href="#"
|
|
124
|
-
onclick="toggleCode('
|
|
125
|
-
<div class="method-source-code" id="
|
|
124
|
+
onclick="toggleCode('M000204-source');return false;">[Source]</a></p>
|
|
125
|
+
<div class="method-source-code" id="M000204-source">
|
|
126
126
|
<pre>
|
|
127
127
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 49</span>
|
|
128
128
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">location</span>, <span class="ruby-identifier">seconds</span>=<span class="ruby-value">10</span>)
|
|
@@ -100,9 +100,9 @@ NOTE that if there are fields named "xxx" and
|
|
|
100
100
|
<h3 class="section-bar">Methods</h3>
|
|
101
101
|
|
|
102
102
|
<div class="name-list">
|
|
103
|
-
<a href="#
|
|
104
|
-
<a href="#
|
|
105
|
-
<a href="#
|
|
103
|
+
<a href="#M000248">application_path</a>
|
|
104
|
+
<a href="#M000249">build_url</a>
|
|
105
|
+
<a href="#M000247">new</a>
|
|
106
106
|
</div>
|
|
107
107
|
</div>
|
|
108
108
|
|
|
@@ -147,19 +147,19 @@ NOTE that if there are fields named "xxx" and
|
|
|
147
147
|
<div id="methods">
|
|
148
148
|
<h3 class="section-bar">Public Class methods</h3>
|
|
149
149
|
|
|
150
|
-
<div id="method-
|
|
151
|
-
<a name="
|
|
150
|
+
<div id="method-M000247" class="method-detail">
|
|
151
|
+
<a name="M000247"></a>
|
|
152
152
|
|
|
153
153
|
<div class="method-heading">
|
|
154
|
-
<a href="#
|
|
154
|
+
<a href="#M000247" class="method-signature">
|
|
155
155
|
<span class="method-name">new</span><span class="method-args">(app_path, path, headers, fields)</span>
|
|
156
156
|
</a>
|
|
157
157
|
</div>
|
|
158
158
|
|
|
159
159
|
<div class="method-description">
|
|
160
160
|
<p><a class="source-toggle" href="#"
|
|
161
|
-
onclick="toggleCode('
|
|
162
|
-
<div class="method-source-code" id="
|
|
161
|
+
onclick="toggleCode('M000247-source');return false;">[Source]</a></p>
|
|
162
|
+
<div class="method-source-code" id="M000247-source">
|
|
163
163
|
<pre>
|
|
164
164
|
<span class="ruby-comment cmt"># File lib/wee/request.rb, line 11</span>
|
|
165
165
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app_path</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">fields</span>)
|
|
@@ -195,19 +195,19 @@ NOTE that if there are fields named "xxx" and
|
|
|
195
195
|
|
|
196
196
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
197
197
|
|
|
198
|
-
<div id="method-
|
|
199
|
-
<a name="
|
|
198
|
+
<div id="method-M000248" class="method-detail">
|
|
199
|
+
<a name="M000248"></a>
|
|
200
200
|
|
|
201
201
|
<div class="method-heading">
|
|
202
|
-
<a href="#
|
|
202
|
+
<a href="#M000248" class="method-signature">
|
|
203
203
|
<span class="method-name">application_path</span><span class="method-args">()</span>
|
|
204
204
|
</a>
|
|
205
205
|
</div>
|
|
206
206
|
|
|
207
207
|
<div class="method-description">
|
|
208
208
|
<p><a class="source-toggle" href="#"
|
|
209
|
-
onclick="toggleCode('
|
|
210
|
-
<div class="method-source-code" id="
|
|
209
|
+
onclick="toggleCode('M000248-source');return false;">[Source]</a></p>
|
|
210
|
+
<div class="method-source-code" id="M000248-source">
|
|
211
211
|
<pre>
|
|
212
212
|
<span class="ruby-comment cmt"># File lib/wee/request.rb, line 38</span>
|
|
213
213
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application_path</span>
|
|
@@ -218,19 +218,19 @@ NOTE that if there are fields named "xxx" and
|
|
|
218
218
|
</div>
|
|
219
219
|
</div>
|
|
220
220
|
|
|
221
|
-
<div id="method-
|
|
222
|
-
<a name="
|
|
221
|
+
<div id="method-M000249" class="method-detail">
|
|
222
|
+
<a name="M000249"></a>
|
|
223
223
|
|
|
224
224
|
<div class="method-heading">
|
|
225
|
-
<a href="#
|
|
225
|
+
<a href="#M000249" class="method-signature">
|
|
226
226
|
<span class="method-name">build_url</span><span class="method-args">(request_handler_id=nil, page_id=nil, callback_id=nil)</span>
|
|
227
227
|
</a>
|
|
228
228
|
</div>
|
|
229
229
|
|
|
230
230
|
<div class="method-description">
|
|
231
231
|
<p><a class="source-toggle" href="#"
|
|
232
|
-
onclick="toggleCode('
|
|
233
|
-
<div class="method-source-code" id="
|
|
232
|
+
onclick="toggleCode('M000249-source');return false;">[Source]</a></p>
|
|
233
|
+
<div class="method-source-code" id="M000249-source">
|
|
234
234
|
<pre>
|
|
235
235
|
<span class="ruby-comment cmt"># File lib/wee/request.rb, line 42</span>
|
|
236
236
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_url</span>(<span class="ruby-identifier">request_handler_id</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">page_id</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">callback_id</span>=<span class="ruby-keyword kw">nil</span>)
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
|
89
89
|
|
|
90
90
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
93
|
-
<a href="#
|
|
94
|
-
<a href="#
|
|
95
|
-
<a href="#
|
|
91
|
+
<a href="#M000261">alive?</a>
|
|
92
|
+
<a href="#M000262">handle_request</a>
|
|
93
|
+
<a href="#M000264">new</a>
|
|
94
|
+
<a href="#M000263">statistics</a>
|
|
95
|
+
<a href="#M000260">teminate</a>
|
|
96
96
|
</div>
|
|
97
97
|
</div>
|
|
98
98
|
|
|
@@ -175,21 +175,21 @@ The maximum number of requests this handler should serve. A value of
|
|
|
175
175
|
<div id="methods">
|
|
176
176
|
<h3 class="section-bar">Public Class methods</h3>
|
|
177
177
|
|
|
178
|
-
<div id="method-
|
|
179
|
-
<a name="
|
|
178
|
+
<div id="method-M000264" class="method-detail">
|
|
179
|
+
<a name="M000264"></a>
|
|
180
180
|
|
|
181
181
|
<div class="method-heading">
|
|
182
|
-
<a href="#
|
|
182
|
+
<a href="#M000264" class="method-signature">
|
|
183
183
|
<span class="method-name">new</span><span class="method-args">()</span>
|
|
184
184
|
</a>
|
|
185
185
|
</div>
|
|
186
186
|
|
|
187
187
|
<div class="method-description">
|
|
188
188
|
<p><a class="source-toggle" href="#"
|
|
189
|
-
onclick="toggleCode('
|
|
190
|
-
<div class="method-source-code" id="
|
|
189
|
+
onclick="toggleCode('M000264-source');return false;">[Source]</a></p>
|
|
190
|
+
<div class="method-source-code" id="M000264-source">
|
|
191
191
|
<pre>
|
|
192
|
-
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line
|
|
192
|
+
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line 74</span>
|
|
193
193
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
|
194
194
|
<span class="ruby-ivar">@last_access</span> = <span class="ruby-ivar">@creation_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
|
195
195
|
<span class="ruby-ivar">@expire_after</span> = <span class="ruby-value">30</span><span class="ruby-operator">*</span><span class="ruby-value">60</span> <span class="ruby-comment cmt"># The default is 30 minutes of inactivity</span>
|
|
@@ -203,11 +203,11 @@ The maximum number of requests this handler should serve. A value of
|
|
|
203
203
|
|
|
204
204
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
205
205
|
|
|
206
|
-
<div id="method-
|
|
207
|
-
<a name="
|
|
206
|
+
<div id="method-M000261" class="method-detail">
|
|
207
|
+
<a name="M000261"></a>
|
|
208
208
|
|
|
209
209
|
<div class="method-heading">
|
|
210
|
-
<a href="#
|
|
210
|
+
<a href="#M000261" class="method-signature">
|
|
211
211
|
<span class="method-name">alive?</span><span class="method-args">()</span>
|
|
212
212
|
</a>
|
|
213
213
|
</div>
|
|
@@ -217,20 +217,20 @@ The maximum number of requests this handler should serve. A value of
|
|
|
217
217
|
Query whether this handler is still alive.
|
|
218
218
|
</p>
|
|
219
219
|
<p><a class="source-toggle" href="#"
|
|
220
|
-
onclick="toggleCode('
|
|
221
|
-
<div class="method-source-code" id="
|
|
220
|
+
onclick="toggleCode('M000261-source');return false;">[Source]</a></p>
|
|
221
|
+
<div class="method-source-code" id="M000261-source">
|
|
222
222
|
<pre>
|
|
223
|
-
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line
|
|
223
|
+
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line 43</span>
|
|
224
224
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alive?</span>
|
|
225
225
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@running</span>
|
|
226
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@max_requests</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@request_count</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@max_requests</span>
|
|
226
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@running</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@max_requests</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@request_count</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@max_requests</span>
|
|
227
227
|
|
|
228
228
|
<span class="ruby-identifier">now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
|
229
229
|
<span class="ruby-identifier">inactivity</span> = <span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@last_access</span>
|
|
230
230
|
<span class="ruby-identifier">lifetime</span> = <span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@creation_time</span>
|
|
231
231
|
|
|
232
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expire_after</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">inactivity</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@expire_after</span>
|
|
233
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@max_lifetime</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">lifetime</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@max_lifetime</span>
|
|
232
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@running</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expire_after</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">inactivity</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@expire_after</span>
|
|
233
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@running</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@max_lifetime</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">lifetime</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@max_lifetime</span>
|
|
234
234
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
|
235
235
|
<span class="ruby-keyword kw">end</span>
|
|
236
236
|
</pre>
|
|
@@ -238,25 +238,25 @@ Query whether this handler is still alive.
|
|
|
238
238
|
</div>
|
|
239
239
|
</div>
|
|
240
240
|
|
|
241
|
-
<div id="method-
|
|
242
|
-
<a name="
|
|
241
|
+
<div id="method-M000262" class="method-detail">
|
|
242
|
+
<a name="M000262"></a>
|
|
243
243
|
|
|
244
244
|
<div class="method-heading">
|
|
245
|
-
<a href="#
|
|
245
|
+
<a href="#M000262" class="method-signature">
|
|
246
246
|
<span class="method-name">handle_request</span><span class="method-args">(context)</span>
|
|
247
247
|
</a>
|
|
248
248
|
</div>
|
|
249
249
|
|
|
250
250
|
<div class="method-description">
|
|
251
251
|
<p>
|
|
252
|
-
Extend <a href="RequestHandler.html#
|
|
252
|
+
Extend <a href="RequestHandler.html#M000262">handle_request</a> in your own
|
|
253
253
|
subclass.
|
|
254
254
|
</p>
|
|
255
255
|
<p><a class="source-toggle" href="#"
|
|
256
|
-
onclick="toggleCode('
|
|
257
|
-
<div class="method-source-code" id="
|
|
256
|
+
onclick="toggleCode('M000262-source');return false;">[Source]</a></p>
|
|
257
|
+
<div class="method-source-code" id="M000262-source">
|
|
258
258
|
<pre>
|
|
259
|
-
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line
|
|
259
|
+
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line 58</span>
|
|
260
260
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
|
|
261
261
|
<span class="ruby-ivar">@request_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
262
262
|
<span class="ruby-ivar">@last_access</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
|
@@ -266,21 +266,21 @@ subclass.
|
|
|
266
266
|
</div>
|
|
267
267
|
</div>
|
|
268
268
|
|
|
269
|
-
<div id="method-
|
|
270
|
-
<a name="
|
|
269
|
+
<div id="method-M000263" class="method-detail">
|
|
270
|
+
<a name="M000263"></a>
|
|
271
271
|
|
|
272
272
|
<div class="method-heading">
|
|
273
|
-
<a href="#
|
|
273
|
+
<a href="#M000263" class="method-signature">
|
|
274
274
|
<span class="method-name">statistics</span><span class="method-args">()</span>
|
|
275
275
|
</a>
|
|
276
276
|
</div>
|
|
277
277
|
|
|
278
278
|
<div class="method-description">
|
|
279
279
|
<p><a class="source-toggle" href="#"
|
|
280
|
-
onclick="toggleCode('
|
|
281
|
-
<div class="method-source-code" id="
|
|
280
|
+
onclick="toggleCode('M000263-source');return false;">[Source]</a></p>
|
|
281
|
+
<div class="method-source-code" id="M000263-source">
|
|
282
282
|
<pre>
|
|
283
|
-
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line
|
|
283
|
+
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line 63</span>
|
|
284
284
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">statistics</span>
|
|
285
285
|
<span class="ruby-identifier">now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
|
286
286
|
{
|
|
@@ -296,11 +296,11 @@ subclass.
|
|
|
296
296
|
</div>
|
|
297
297
|
</div>
|
|
298
298
|
|
|
299
|
-
<div id="method-
|
|
300
|
-
<a name="
|
|
299
|
+
<div id="method-M000260" class="method-detail">
|
|
300
|
+
<a name="M000260"></a>
|
|
301
301
|
|
|
302
302
|
<div class="method-heading">
|
|
303
|
-
<a href="#
|
|
303
|
+
<a href="#M000260" class="method-signature">
|
|
304
304
|
<span class="method-name">teminate</span><span class="method-args">()</span>
|
|
305
305
|
</a>
|
|
306
306
|
</div>
|
|
@@ -308,12 +308,16 @@ subclass.
|
|
|
308
308
|
<div class="method-description">
|
|
309
309
|
<p>
|
|
310
310
|
Terminates the handler.
|
|
311
|
+
</p>
|
|
312
|
+
<p>
|
|
313
|
+
This will usually not immediatly terminate the handler from running, but
|
|
314
|
+
further requests will not be answered.
|
|
311
315
|
</p>
|
|
312
316
|
<p><a class="source-toggle" href="#"
|
|
313
|
-
onclick="toggleCode('
|
|
314
|
-
<div class="method-source-code" id="
|
|
317
|
+
onclick="toggleCode('M000260-source');return false;">[Source]</a></p>
|
|
318
|
+
<div class="method-source-code" id="M000260-source">
|
|
315
319
|
<pre>
|
|
316
|
-
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line
|
|
320
|
+
<span class="ruby-comment cmt"># File lib/wee/requesthandler.rb, line 37</span>
|
|
317
321
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">teminate</span>
|
|
318
322
|
<span class="ruby-ivar">@running</span> = <span class="ruby-keyword kw">false</span>
|
|
319
323
|
<span class="ruby-keyword kw">end</span>
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
|
89
89
|
|
|
90
90
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
93
|
-
<a href="#
|
|
94
|
-
<a href="#
|
|
91
|
+
<a href="#M000191"><<</a>
|
|
92
|
+
<a href="#M000189">content_type</a>
|
|
93
|
+
<a href="#M000190">content_type=</a>
|
|
94
|
+
<a href="#M000188">new</a>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
97
|
|
|
@@ -149,19 +149,19 @@
|
|
|
149
149
|
<div id="methods">
|
|
150
150
|
<h3 class="section-bar">Public Class methods</h3>
|
|
151
151
|
|
|
152
|
-
<div id="method-
|
|
153
|
-
<a name="
|
|
152
|
+
<div id="method-M000188" class="method-detail">
|
|
153
|
+
<a name="M000188"></a>
|
|
154
154
|
|
|
155
155
|
<div class="method-heading">
|
|
156
|
-
<a href="#
|
|
156
|
+
<a href="#M000188" class="method-signature">
|
|
157
157
|
<span class="method-name">new</span><span class="method-args">(mime_type = 'text/html', content='')</span>
|
|
158
158
|
</a>
|
|
159
159
|
</div>
|
|
160
160
|
|
|
161
161
|
<div class="method-description">
|
|
162
162
|
<p><a class="source-toggle" href="#"
|
|
163
|
-
onclick="toggleCode('
|
|
164
|
-
<div class="method-source-code" id="
|
|
163
|
+
onclick="toggleCode('M000188-source');return false;">[Source]</a></p>
|
|
164
|
+
<div class="method-source-code" id="M000188-source">
|
|
165
165
|
<pre>
|
|
166
166
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 9</span>
|
|
167
167
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">mime_type</span> = <span class="ruby-value str">'text/html'</span>, <span class="ruby-identifier">content</span>=<span class="ruby-value str">''</span>)
|
|
@@ -176,19 +176,19 @@
|
|
|
176
176
|
|
|
177
177
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
178
178
|
|
|
179
|
-
<div id="method-
|
|
180
|
-
<a name="
|
|
179
|
+
<div id="method-M000191" class="method-detail">
|
|
180
|
+
<a name="M000191"></a>
|
|
181
181
|
|
|
182
182
|
<div class="method-heading">
|
|
183
|
-
<a href="#
|
|
183
|
+
<a href="#M000191" class="method-signature">
|
|
184
184
|
<span class="method-name"><<</span><span class="method-args">(str)</span>
|
|
185
185
|
</a>
|
|
186
186
|
</div>
|
|
187
187
|
|
|
188
188
|
<div class="method-description">
|
|
189
189
|
<p><a class="source-toggle" href="#"
|
|
190
|
-
onclick="toggleCode('
|
|
191
|
-
<div class="method-source-code" id="
|
|
190
|
+
onclick="toggleCode('M000191-source');return false;">[Source]</a></p>
|
|
191
|
+
<div class="method-source-code" id="M000191-source">
|
|
192
192
|
<pre>
|
|
193
193
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 23</span>
|
|
194
194
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator"><<</span>(<span class="ruby-identifier">str</span>)
|
|
@@ -199,19 +199,19 @@
|
|
|
199
199
|
</div>
|
|
200
200
|
</div>
|
|
201
201
|
|
|
202
|
-
<div id="method-
|
|
203
|
-
<a name="
|
|
202
|
+
<div id="method-M000189" class="method-detail">
|
|
203
|
+
<a name="M000189"></a>
|
|
204
204
|
|
|
205
205
|
<div class="method-heading">
|
|
206
|
-
<a href="#
|
|
206
|
+
<a href="#M000189" class="method-signature">
|
|
207
207
|
<span class="method-name">content_type</span><span class="method-args">()</span>
|
|
208
208
|
</a>
|
|
209
209
|
</div>
|
|
210
210
|
|
|
211
211
|
<div class="method-description">
|
|
212
212
|
<p><a class="source-toggle" href="#"
|
|
213
|
-
onclick="toggleCode('
|
|
214
|
-
<div class="method-source-code" id="
|
|
213
|
+
onclick="toggleCode('M000189-source');return false;">[Source]</a></p>
|
|
214
|
+
<div class="method-source-code" id="M000189-source">
|
|
215
215
|
<pre>
|
|
216
216
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 15</span>
|
|
217
217
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type</span>
|
|
@@ -222,19 +222,19 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
</div>
|
|
224
224
|
|
|
225
|
-
<div id="method-
|
|
226
|
-
<a name="
|
|
225
|
+
<div id="method-M000190" class="method-detail">
|
|
226
|
+
<a name="M000190"></a>
|
|
227
227
|
|
|
228
228
|
<div class="method-heading">
|
|
229
|
-
<a href="#
|
|
229
|
+
<a href="#M000190" class="method-signature">
|
|
230
230
|
<span class="method-name">content_type=</span><span class="method-args">(mime_type)</span>
|
|
231
231
|
</a>
|
|
232
232
|
</div>
|
|
233
233
|
|
|
234
234
|
<div class="method-description">
|
|
235
235
|
<p><a class="source-toggle" href="#"
|
|
236
|
-
onclick="toggleCode('
|
|
237
|
-
<div class="method-source-code" id="
|
|
236
|
+
onclick="toggleCode('M000190-source');return false;">[Source]</a></p>
|
|
237
|
+
<div class="method-source-code" id="M000190-source">
|
|
238
238
|
<pre>
|
|
239
239
|
<span class="ruby-comment cmt"># File lib/wee/response.rb, line 19</span>
|
|
240
240
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type=</span>(<span class="ruby-identifier">mime_type</span>)
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
<a href="../../files/lib/wee/session_rb.html">
|
|
59
59
|
lib/wee/session.rb
|
|
60
60
|
</a>
|
|
61
|
+
<br />
|
|
62
|
+
<a href="../../files/lib/wee/continuation/session_rb.html">
|
|
63
|
+
lib/wee/continuation/session.rb
|
|
64
|
+
</a>
|
|
61
65
|
<br />
|
|
62
66
|
</td>
|
|
63
67
|
</tr>
|
|
@@ -82,21 +86,45 @@
|
|
|
82
86
|
|
|
83
87
|
|
|
84
88
|
|
|
89
|
+
<div id="contents-list">
|
|
90
|
+
<h3 class="section-bar">Contents</h3>
|
|
91
|
+
<ul>
|
|
92
|
+
<li><a href="#SEC00016">Properties</a></li>
|
|
93
|
+
<li><a href="#SEC00118">Properties</a></li>
|
|
94
|
+
</ul>
|
|
85
95
|
</div>
|
|
86
96
|
|
|
87
97
|
<div id="method-list">
|
|
88
98
|
<h3 class="section-bar">Methods</h3>
|
|
89
99
|
|
|
90
100
|
<div class="name-list">
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
93
|
-
<a href="#
|
|
94
|
-
<a href="#
|
|
95
|
-
<a href="#
|
|
96
|
-
<a href="#
|
|
97
|
-
<a href="#
|
|
98
|
-
<a href="#
|
|
99
|
-
<a href="#
|
|
101
|
+
<a href="#M000153">awake</a>
|
|
102
|
+
<a href="#M000167">awake</a>
|
|
103
|
+
<a href="#M000152">create_page</a>
|
|
104
|
+
<a href="#M000166">create_page</a>
|
|
105
|
+
<a href="#M000148">current</a>
|
|
106
|
+
<a href="#M000161">current</a>
|
|
107
|
+
<a href="#M000170">current_context</a>
|
|
108
|
+
<a href="#M000156">current_context</a>
|
|
109
|
+
<a href="#M000171">current_page</a>
|
|
110
|
+
<a href="#M000157">current_page</a>
|
|
111
|
+
<a href="#M000172">get_property</a>
|
|
112
|
+
<a href="#M000158">get_property</a>
|
|
113
|
+
<a href="#M000159">handle_new_page_view</a>
|
|
114
|
+
<a href="#M000173">handle_new_page_view</a>
|
|
115
|
+
<a href="#M000151">handle_request</a>
|
|
116
|
+
<a href="#M000164">handle_request</a>
|
|
117
|
+
<a href="#M000149">new</a>
|
|
118
|
+
<a href="#M000162">new</a>
|
|
119
|
+
<a href="#M000155">process_request</a>
|
|
120
|
+
<a href="#M000169">process_request</a>
|
|
121
|
+
<a href="#M000160">respond</a>
|
|
122
|
+
<a href="#M000174">respond</a>
|
|
123
|
+
<a href="#M000168">sleep</a>
|
|
124
|
+
<a href="#M000154">sleep</a>
|
|
125
|
+
<a href="#M000150">snapshot</a>
|
|
126
|
+
<a href="#M000163">snapshot</a>
|
|
127
|
+
<a href="#M000165">start_request_response_loop</a>
|
|
100
128
|
</div>
|
|
101
129
|
</div>
|
|
102
130
|
|
|
@@ -136,21 +164,409 @@
|
|
|
136
164
|
<div id="methods">
|
|
137
165
|
<h3 class="section-bar">Public Class methods</h3>
|
|
138
166
|
|
|
139
|
-
<div id="method-
|
|
140
|
-
<a name="
|
|
167
|
+
<div id="method-M000148" class="method-detail">
|
|
168
|
+
<a name="M000148"></a>
|
|
169
|
+
|
|
170
|
+
<div class="method-heading">
|
|
171
|
+
<a href="#M000148" class="method-signature">
|
|
172
|
+
<span class="method-name">current</span><span class="method-args">()</span>
|
|
173
|
+
</a>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div class="method-description">
|
|
177
|
+
<p><a class="source-toggle" href="#"
|
|
178
|
+
onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
|
|
179
|
+
<div class="method-source-code" id="M000148-source">
|
|
180
|
+
<pre>
|
|
181
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 7</span>
|
|
182
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current</span>
|
|
183
|
+
<span class="ruby-identifier">sess</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>]
|
|
184
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"not in session"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sess</span>.<span class="ruby-identifier">nil?</span>
|
|
185
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sess</span>
|
|
186
|
+
<span class="ruby-keyword kw">end</span>
|
|
187
|
+
</pre>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div id="method-M000149" class="method-detail">
|
|
193
|
+
<a name="M000149"></a>
|
|
194
|
+
|
|
195
|
+
<div class="method-heading">
|
|
196
|
+
<a href="#M000149" class="method-signature">
|
|
197
|
+
<span class="method-name">new</span><span class="method-args">(&block)</span>
|
|
198
|
+
</a>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div class="method-description">
|
|
202
|
+
<p><a class="source-toggle" href="#"
|
|
203
|
+
onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
|
|
204
|
+
<div class="method-source-code" id="M000149-source">
|
|
205
|
+
<pre>
|
|
206
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 13</span>
|
|
207
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
208
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>] = <span class="ruby-keyword kw">self</span>
|
|
209
|
+
|
|
210
|
+
<span class="ruby-ivar">@idgen</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">SimpleIdGenerator</span>.<span class="ruby-identifier">new</span>
|
|
211
|
+
|
|
212
|
+
<span class="ruby-comment cmt"># to serialize the requests we need a mutex</span>
|
|
213
|
+
<span class="ruby-ivar">@mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
|
|
214
|
+
|
|
215
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>)
|
|
216
|
+
|
|
217
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"No root component specified"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">nil?</span>
|
|
218
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"No page_store specified"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@page_store</span>.<span class="ruby-identifier">nil?</span>
|
|
219
|
+
|
|
220
|
+
<span class="ruby-ivar">@initial_snapshot</span> = <span class="ruby-identifier">snapshot</span>()
|
|
221
|
+
|
|
222
|
+
<span class="ruby-keyword kw">super</span>()
|
|
223
|
+
<span class="ruby-keyword kw">ensure</span>
|
|
224
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>] = <span class="ruby-keyword kw">nil</span>
|
|
225
|
+
<span class="ruby-keyword kw">end</span>
|
|
226
|
+
</pre>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
232
|
+
|
|
233
|
+
<div id="method-M000153" class="method-detail">
|
|
234
|
+
<a name="M000153"></a>
|
|
235
|
+
|
|
236
|
+
<div class="method-heading">
|
|
237
|
+
<a href="#M000153" class="method-signature">
|
|
238
|
+
<span class="method-name">awake</span><span class="method-args">()</span>
|
|
239
|
+
</a>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div class="method-description">
|
|
243
|
+
<p>
|
|
244
|
+
Is called before <a href="Session.html#M000155">process_request</a> is
|
|
245
|
+
invoked Can be used to setup e.g. a database connection.
|
|
246
|
+
</p>
|
|
247
|
+
<p><a class="source-toggle" href="#"
|
|
248
|
+
onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
|
|
249
|
+
<div class="method-source-code" id="M000153-source">
|
|
250
|
+
<pre>
|
|
251
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 66</span>
|
|
252
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">awake</span>
|
|
253
|
+
<span class="ruby-keyword kw">end</span>
|
|
254
|
+
</pre>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div id="method-M000152" class="method-detail">
|
|
260
|
+
<a name="M000152"></a>
|
|
261
|
+
|
|
262
|
+
<div class="method-heading">
|
|
263
|
+
<a href="#M000152" class="method-signature">
|
|
264
|
+
<span class="method-name">create_page</span><span class="method-args">(snapshot)</span>
|
|
265
|
+
</a>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div class="method-description">
|
|
269
|
+
<p><a class="source-toggle" href="#"
|
|
270
|
+
onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
|
|
271
|
+
<div class="method-source-code" id="M000152-source">
|
|
272
|
+
<pre>
|
|
273
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 59</span>
|
|
274
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">snapshot</span>)
|
|
275
|
+
<span class="ruby-identifier">idgen</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">SimpleIdGenerator</span>.<span class="ruby-identifier">new</span>
|
|
276
|
+
<span class="ruby-identifier">page</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">Page</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">snapshot</span>, <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">CallbackRegistry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">idgen</span>))
|
|
277
|
+
<span class="ruby-keyword kw">end</span>
|
|
278
|
+
</pre>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div id="method-M000156" class="method-detail">
|
|
284
|
+
<a name="M000156"></a>
|
|
285
|
+
|
|
286
|
+
<div class="method-heading">
|
|
287
|
+
<a href="#M000156" class="method-signature">
|
|
288
|
+
<span class="method-name">current_context</span><span class="method-args">()</span>
|
|
289
|
+
</a>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div class="method-description">
|
|
293
|
+
<p><a class="source-toggle" href="#"
|
|
294
|
+
onclick="toggleCode('M000156-source');return false;">[Source]</a></p>
|
|
295
|
+
<div class="method-source-code" id="M000156-source">
|
|
296
|
+
<pre>
|
|
297
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 148</span>
|
|
298
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_context</span>
|
|
299
|
+
<span class="ruby-ivar">@context</span>
|
|
300
|
+
<span class="ruby-keyword kw">end</span>
|
|
301
|
+
</pre>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
<div id="method-M000157" class="method-detail">
|
|
307
|
+
<a name="M000157"></a>
|
|
308
|
+
|
|
309
|
+
<div class="method-heading">
|
|
310
|
+
<a href="#M000157" class="method-signature">
|
|
311
|
+
<span class="method-name">current_page</span><span class="method-args">()</span>
|
|
312
|
+
</a>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<div class="method-description">
|
|
316
|
+
<p><a class="source-toggle" href="#"
|
|
317
|
+
onclick="toggleCode('M000157-source');return false;">[Source]</a></p>
|
|
318
|
+
<div class="method-source-code" id="M000157-source">
|
|
319
|
+
<pre>
|
|
320
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 152</span>
|
|
321
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_page</span>
|
|
322
|
+
<span class="ruby-ivar">@page</span>
|
|
323
|
+
<span class="ruby-keyword kw">end</span>
|
|
324
|
+
</pre>
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
<div id="method-M000151" class="method-detail">
|
|
330
|
+
<a name="M000151"></a>
|
|
331
|
+
|
|
332
|
+
<div class="method-heading">
|
|
333
|
+
<a href="#M000151" class="method-signature">
|
|
334
|
+
<span class="method-name">handle_request</span><span class="method-args">(context)</span>
|
|
335
|
+
</a>
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
<div class="method-description">
|
|
339
|
+
<p>
|
|
340
|
+
called by application to send the session a request
|
|
341
|
+
</p>
|
|
342
|
+
<p><a class="source-toggle" href="#"
|
|
343
|
+
onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
|
|
344
|
+
<div class="method-source-code" id="M000151-source">
|
|
345
|
+
<pre>
|
|
346
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 40</span>
|
|
347
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
|
|
348
|
+
<span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
|
|
349
|
+
<span class="ruby-keyword kw">begin</span>
|
|
350
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>] = <span class="ruby-keyword kw">self</span>
|
|
351
|
+
<span class="ruby-ivar">@context</span> = <span class="ruby-identifier">context</span>
|
|
352
|
+
<span class="ruby-keyword kw">super</span>
|
|
353
|
+
<span class="ruby-identifier">awake</span>
|
|
354
|
+
<span class="ruby-identifier">process_request</span>
|
|
355
|
+
<span class="ruby-identifier">sleep</span>
|
|
356
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exn</span>
|
|
357
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">ErrorResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">exn</span>)
|
|
358
|
+
<span class="ruby-keyword kw">ensure</span>
|
|
359
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>] = <span class="ruby-keyword kw">nil</span>
|
|
360
|
+
<span class="ruby-ivar">@context</span> = <span class="ruby-keyword kw">nil</span>
|
|
361
|
+
<span class="ruby-ivar">@page</span> = <span class="ruby-keyword kw">nil</span>
|
|
362
|
+
<span class="ruby-keyword kw">end</span>
|
|
363
|
+
<span class="ruby-keyword kw">end</span>
|
|
364
|
+
<span class="ruby-keyword kw">end</span>
|
|
365
|
+
</pre>
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<div id="method-M000155" class="method-detail">
|
|
371
|
+
<a name="M000155"></a>
|
|
372
|
+
|
|
373
|
+
<div class="method-heading">
|
|
374
|
+
<a href="#M000155" class="method-signature">
|
|
375
|
+
<span class="method-name">process_request</span><span class="method-args">()</span>
|
|
376
|
+
</a>
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
<div class="method-description">
|
|
380
|
+
<p><a class="source-toggle" href="#"
|
|
381
|
+
onclick="toggleCode('M000155-source');return false;">[Source]</a></p>
|
|
382
|
+
<div class="method-source-code" id="M000155-source">
|
|
383
|
+
<pre>
|
|
384
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 74</span>
|
|
385
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span>
|
|
386
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>.<span class="ruby-identifier">nil?</span>
|
|
387
|
+
|
|
388
|
+
<span class="ruby-comment cmt"># No page_id was specified in the URL. This means that we start with a</span>
|
|
389
|
+
<span class="ruby-comment cmt"># fresh component and a fresh page_id, then redirect to render itself.</span>
|
|
390
|
+
|
|
391
|
+
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-ivar">@initial_snapshot</span>)
|
|
392
|
+
|
|
393
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@page</span> = <span class="ruby-ivar">@page_store</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>, <span class="ruby-keyword kw">false</span>)
|
|
394
|
+
|
|
395
|
+
<span class="ruby-comment cmt"># A valid page_id was specified and the corresponding page exists.</span>
|
|
396
|
+
|
|
397
|
+
<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">restore</span>
|
|
398
|
+
|
|
399
|
+
<span class="ruby-identifier">p</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">fields</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
|
|
400
|
+
|
|
401
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">fields</span>.<span class="ruby-identifier">empty?</span>
|
|
402
|
+
|
|
403
|
+
<span class="ruby-comment cmt"># No action/inputs were specified -> render page</span>
|
|
404
|
+
<span class="ruby-comment cmt">#</span>
|
|
405
|
+
<span class="ruby-comment cmt"># 1. Reset the action/input fields (as they are regenerated in the</span>
|
|
406
|
+
<span class="ruby-comment cmt"># rendering process).</span>
|
|
407
|
+
<span class="ruby-comment cmt"># 2. Render the page (respond).</span>
|
|
408
|
+
<span class="ruby-comment cmt"># 3. Store the page back into the store</span>
|
|
409
|
+
|
|
410
|
+
<span class="ruby-ivar">@page</span> = <span class="ruby-identifier">create_page</span>(<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span>) <span class="ruby-comment cmt"># remove all action/input handlers</span>
|
|
411
|
+
<span class="ruby-identifier">respond</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-ivar">@page</span>.<span class="ruby-identifier">callbacks</span>) <span class="ruby-comment cmt"># render</span>
|
|
412
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>] = <span class="ruby-ivar">@page</span> <span class="ruby-comment cmt"># store</span>
|
|
413
|
+
|
|
414
|
+
<span class="ruby-keyword kw">else</span>
|
|
415
|
+
|
|
416
|
+
<span class="ruby-comment cmt"># Actions/inputs were specified.</span>
|
|
417
|
+
<span class="ruby-comment cmt">#</span>
|
|
418
|
+
<span class="ruby-comment cmt"># We process the request and invoke actions/inputs. Then we generate a</span>
|
|
419
|
+
<span class="ruby-comment cmt"># new page view. </span>
|
|
420
|
+
|
|
421
|
+
<span class="ruby-identifier">callback_stream</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">CallbackStream</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">callbacks</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">fields</span>)
|
|
422
|
+
|
|
423
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback_stream</span>.<span class="ruby-identifier">all_of_type</span>(<span class="ruby-identifier">:action</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
|
424
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Not allowed to specify more than one action callback"</span>
|
|
425
|
+
<span class="ruby-keyword kw">end</span>
|
|
426
|
+
|
|
427
|
+
<span class="ruby-identifier">live_update_response</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_live_update</span>) {
|
|
428
|
+
<span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_back_to_session</span>) {
|
|
429
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">process_callbacks_chain</span>(<span class="ruby-identifier">callback_stream</span>)
|
|
430
|
+
}
|
|
431
|
+
<span class="ruby-keyword kw">nil</span>
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">live_update_response</span>
|
|
435
|
+
<span class="ruby-comment cmt"># replace existing page with new snapshot</span>
|
|
436
|
+
<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">snapshot</span>
|
|
437
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>] = <span class="ruby-ivar">@page</span>
|
|
438
|
+
<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-identifier">live_update_response</span>
|
|
439
|
+
<span class="ruby-keyword kw">else</span>
|
|
440
|
+
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>)
|
|
441
|
+
<span class="ruby-keyword kw">end</span>
|
|
442
|
+
|
|
443
|
+
<span class="ruby-keyword kw">end</span>
|
|
444
|
+
|
|
445
|
+
<span class="ruby-keyword kw">else</span>
|
|
446
|
+
|
|
447
|
+
<span class="ruby-comment cmt"># A page_id was specified in the URL, but there's no page for it in the</span>
|
|
448
|
+
<span class="ruby-comment cmt"># page store. Either the page has timed out, or an invalid page_id was</span>
|
|
449
|
+
<span class="ruby-comment cmt"># specified. </span>
|
|
450
|
+
<span class="ruby-comment cmt">#</span>
|
|
451
|
+
<span class="ruby-comment cmt"># TODO:: Display an "invalid page or page timed out" message, which</span>
|
|
452
|
+
<span class="ruby-comment cmt"># forwards to /app/session-id</span>
|
|
453
|
+
|
|
454
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Not yet implemented"</span>
|
|
455
|
+
|
|
456
|
+
<span class="ruby-keyword kw">end</span>
|
|
457
|
+
<span class="ruby-keyword kw">end</span>
|
|
458
|
+
</pre>
|
|
459
|
+
</div>
|
|
460
|
+
</div>
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
<div id="method-M000154" class="method-detail">
|
|
464
|
+
<a name="M000154"></a>
|
|
465
|
+
|
|
466
|
+
<div class="method-heading">
|
|
467
|
+
<a href="#M000154" class="method-signature">
|
|
468
|
+
<span class="method-name">sleep</span><span class="method-args">()</span>
|
|
469
|
+
</a>
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
<div class="method-description">
|
|
473
|
+
<p>
|
|
474
|
+
Is called after <a href="Session.html#M000155">process_request</a> is run
|
|
475
|
+
Can be used to release e.g. a database connection.
|
|
476
|
+
</p>
|
|
477
|
+
<p><a class="source-toggle" href="#"
|
|
478
|
+
onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
|
|
479
|
+
<div class="method-source-code" id="M000154-source">
|
|
480
|
+
<pre>
|
|
481
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 71</span>
|
|
482
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sleep</span>
|
|
483
|
+
<span class="ruby-keyword kw">end</span>
|
|
484
|
+
</pre>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
</div>
|
|
488
|
+
|
|
489
|
+
<div id="method-M000150" class="method-detail">
|
|
490
|
+
<a name="M000150"></a>
|
|
491
|
+
|
|
492
|
+
<div class="method-heading">
|
|
493
|
+
<a href="#M000150" class="method-signature">
|
|
494
|
+
<span class="method-name">snapshot</span><span class="method-args">()</span>
|
|
495
|
+
</a>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<div class="method-description">
|
|
499
|
+
<p><a class="source-toggle" href="#"
|
|
500
|
+
onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
|
|
501
|
+
<div class="method-source-code" id="M000150-source">
|
|
502
|
+
<pre>
|
|
503
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 33</span>
|
|
504
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">snapshot</span>
|
|
505
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">backtrack_state_chain</span>(<span class="ruby-identifier">snap</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">new</span>)
|
|
506
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">snap</span>.<span class="ruby-identifier">freeze</span>
|
|
507
|
+
<span class="ruby-keyword kw">end</span>
|
|
508
|
+
</pre>
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
</div>
|
|
515
|
+
<div id="section">
|
|
516
|
+
<h2 class="section-title"><a name="SEC00016">Properties</a></h2>
|
|
517
|
+
<div class="section-comment">
|
|
518
|
+
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
<div id="attribute-list">
|
|
526
|
+
<h3 class="section-bar">Attributes</h3>
|
|
527
|
+
|
|
528
|
+
<div class="name-list">
|
|
529
|
+
<table>
|
|
530
|
+
<tr class="top-aligned-row context-row">
|
|
531
|
+
<td class="context-item-name">page_store</td>
|
|
532
|
+
<td class="context-item-value"> [RW] </td>
|
|
533
|
+
<td class="context-item-desc"></td>
|
|
534
|
+
</tr>
|
|
535
|
+
<tr class="top-aligned-row context-row">
|
|
536
|
+
<td class="context-item-name">properties</td>
|
|
537
|
+
<td class="context-item-value"> [RW] </td>
|
|
538
|
+
<td class="context-item-desc"></td>
|
|
539
|
+
</tr>
|
|
540
|
+
<tr class="top-aligned-row context-row">
|
|
541
|
+
<td class="context-item-name">root_component</td>
|
|
542
|
+
<td class="context-item-value"> [RW] </td>
|
|
543
|
+
<td class="context-item-desc"></td>
|
|
544
|
+
</tr>
|
|
545
|
+
</table>
|
|
546
|
+
</div>
|
|
547
|
+
</div>
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
<!-- if method_list -->
|
|
552
|
+
<div id="methods">
|
|
553
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
554
|
+
|
|
555
|
+
<div id="method-M000161" class="method-detail">
|
|
556
|
+
<a name="M000161"></a>
|
|
141
557
|
|
|
142
558
|
<div class="method-heading">
|
|
143
|
-
<a href="#
|
|
559
|
+
<a href="#M000161" class="method-signature">
|
|
144
560
|
<span class="method-name">current</span><span class="method-args">()</span>
|
|
145
561
|
</a>
|
|
146
562
|
</div>
|
|
147
563
|
|
|
148
564
|
<div class="method-description">
|
|
149
565
|
<p><a class="source-toggle" href="#"
|
|
150
|
-
onclick="toggleCode('
|
|
151
|
-
<div class="method-source-code" id="
|
|
566
|
+
onclick="toggleCode('M000161-source');return false;">[Source]</a></p>
|
|
567
|
+
<div class="method-source-code" id="M000161-source">
|
|
152
568
|
<pre>
|
|
153
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 8</span>
|
|
569
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 8</span>
|
|
154
570
|
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current</span>
|
|
155
571
|
<span class="ruby-identifier">sess</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>]
|
|
156
572
|
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"not in session"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sess</span>.<span class="ruby-identifier">nil?</span>
|
|
@@ -161,21 +577,21 @@
|
|
|
161
577
|
</div>
|
|
162
578
|
</div>
|
|
163
579
|
|
|
164
|
-
<div id="method-
|
|
165
|
-
<a name="
|
|
580
|
+
<div id="method-M000162" class="method-detail">
|
|
581
|
+
<a name="M000162"></a>
|
|
166
582
|
|
|
167
583
|
<div class="method-heading">
|
|
168
|
-
<a href="#
|
|
584
|
+
<a href="#M000162" class="method-signature">
|
|
169
585
|
<span class="method-name">new</span><span class="method-args">(&block)</span>
|
|
170
586
|
</a>
|
|
171
587
|
</div>
|
|
172
588
|
|
|
173
589
|
<div class="method-description">
|
|
174
590
|
<p><a class="source-toggle" href="#"
|
|
175
|
-
onclick="toggleCode('
|
|
176
|
-
<div class="method-source-code" id="
|
|
591
|
+
onclick="toggleCode('M000162-source');return false;">[Source]</a></p>
|
|
592
|
+
<div class="method-source-code" id="M000162-source">
|
|
177
593
|
<pre>
|
|
178
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 14</span>
|
|
594
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 14</span>
|
|
179
595
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
180
596
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-identifier">:wee_session</span>] = <span class="ruby-keyword kw">self</span>
|
|
181
597
|
|
|
@@ -201,21 +617,47 @@
|
|
|
201
617
|
|
|
202
618
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
203
619
|
|
|
204
|
-
<div id="method-
|
|
205
|
-
<a name="
|
|
620
|
+
<div id="method-M000167" class="method-detail">
|
|
621
|
+
<a name="M000167"></a>
|
|
622
|
+
|
|
623
|
+
<div class="method-heading">
|
|
624
|
+
<a href="#M000167" class="method-signature">
|
|
625
|
+
<span class="method-name">awake</span><span class="method-args">()</span>
|
|
626
|
+
</a>
|
|
627
|
+
</div>
|
|
628
|
+
|
|
629
|
+
<div class="method-description">
|
|
630
|
+
<p>
|
|
631
|
+
Is called before <a href="Session.html#M000155">process_request</a> is
|
|
632
|
+
invoked Can be used to setup e.g. a database connection.
|
|
633
|
+
</p>
|
|
634
|
+
<p><a class="source-toggle" href="#"
|
|
635
|
+
onclick="toggleCode('M000167-source');return false;">[Source]</a></p>
|
|
636
|
+
<div class="method-source-code" id="M000167-source">
|
|
637
|
+
<pre>
|
|
638
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 94</span>
|
|
639
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">awake</span>
|
|
640
|
+
<span class="ruby-keyword kw">end</span>
|
|
641
|
+
</pre>
|
|
642
|
+
</div>
|
|
643
|
+
</div>
|
|
644
|
+
</div>
|
|
645
|
+
|
|
646
|
+
<div id="method-M000166" class="method-detail">
|
|
647
|
+
<a name="M000166"></a>
|
|
206
648
|
|
|
207
649
|
<div class="method-heading">
|
|
208
|
-
<a href="#
|
|
650
|
+
<a href="#M000166" class="method-signature">
|
|
209
651
|
<span class="method-name">create_page</span><span class="method-args">(snapshot)</span>
|
|
210
652
|
</a>
|
|
211
653
|
</div>
|
|
212
654
|
|
|
213
655
|
<div class="method-description">
|
|
214
656
|
<p><a class="source-toggle" href="#"
|
|
215
|
-
onclick="toggleCode('
|
|
216
|
-
<div class="method-source-code" id="
|
|
657
|
+
onclick="toggleCode('M000166-source');return false;">[Source]</a></p>
|
|
658
|
+
<div class="method-source-code" id="M000166-source">
|
|
217
659
|
<pre>
|
|
218
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line
|
|
660
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 87</span>
|
|
219
661
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">snapshot</span>)
|
|
220
662
|
<span class="ruby-identifier">idgen</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">SimpleIdGenerator</span>.<span class="ruby-identifier">new</span>
|
|
221
663
|
<span class="ruby-identifier">page</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">Page</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">snapshot</span>, <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">CallbackRegistry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">idgen</span>))
|
|
@@ -225,11 +667,87 @@
|
|
|
225
667
|
</div>
|
|
226
668
|
</div>
|
|
227
669
|
|
|
228
|
-
<div id="method-
|
|
229
|
-
<a name="
|
|
670
|
+
<div id="method-M000170" class="method-detail">
|
|
671
|
+
<a name="M000170"></a>
|
|
672
|
+
|
|
673
|
+
<div class="method-heading">
|
|
674
|
+
<a href="#M000170" class="method-signature">
|
|
675
|
+
<span class="method-name">current_context</span><span class="method-args">()</span>
|
|
676
|
+
</a>
|
|
677
|
+
</div>
|
|
678
|
+
|
|
679
|
+
<div class="method-description">
|
|
680
|
+
<p><a class="source-toggle" href="#"
|
|
681
|
+
onclick="toggleCode('M000170-source');return false;">[Source]</a></p>
|
|
682
|
+
<div class="method-source-code" id="M000170-source">
|
|
683
|
+
<pre>
|
|
684
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 176</span>
|
|
685
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_context</span>
|
|
686
|
+
<span class="ruby-ivar">@context</span>
|
|
687
|
+
<span class="ruby-keyword kw">end</span>
|
|
688
|
+
</pre>
|
|
689
|
+
</div>
|
|
690
|
+
</div>
|
|
691
|
+
</div>
|
|
692
|
+
|
|
693
|
+
<div id="method-M000171" class="method-detail">
|
|
694
|
+
<a name="M000171"></a>
|
|
695
|
+
|
|
696
|
+
<div class="method-heading">
|
|
697
|
+
<a href="#M000171" class="method-signature">
|
|
698
|
+
<span class="method-name">current_page</span><span class="method-args">()</span>
|
|
699
|
+
</a>
|
|
700
|
+
</div>
|
|
701
|
+
|
|
702
|
+
<div class="method-description">
|
|
703
|
+
<p><a class="source-toggle" href="#"
|
|
704
|
+
onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
|
|
705
|
+
<div class="method-source-code" id="M000171-source">
|
|
706
|
+
<pre>
|
|
707
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 180</span>
|
|
708
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_page</span>
|
|
709
|
+
<span class="ruby-ivar">@page</span>
|
|
710
|
+
<span class="ruby-keyword kw">end</span>
|
|
711
|
+
</pre>
|
|
712
|
+
</div>
|
|
713
|
+
</div>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
<div id="method-M000158" class="method-detail">
|
|
717
|
+
<a name="M000158"></a>
|
|
718
|
+
|
|
719
|
+
<div class="method-heading">
|
|
720
|
+
<a href="#M000158" class="method-signature">
|
|
721
|
+
<span class="method-name">get_property</span><span class="method-args">(prop, klass)</span>
|
|
722
|
+
</a>
|
|
723
|
+
</div>
|
|
724
|
+
|
|
725
|
+
<div class="method-description">
|
|
726
|
+
<p>
|
|
727
|
+
Returns an "owned" property for the given <tt>klass</tt>.
|
|
728
|
+
</p>
|
|
729
|
+
<p><a class="source-toggle" href="#"
|
|
730
|
+
onclick="toggleCode('M000158-source');return false;">[Source]</a></p>
|
|
731
|
+
<div class="method-source-code" id="M000158-source">
|
|
732
|
+
<pre>
|
|
733
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 164</span>
|
|
734
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_property</span>(<span class="ruby-identifier">prop</span>, <span class="ruby-identifier">klass</span>)
|
|
735
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@properties</span>
|
|
736
|
+
<span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">klass</span>, {})[<span class="ruby-identifier">prop</span>]
|
|
737
|
+
<span class="ruby-keyword kw">else</span>
|
|
738
|
+
<span class="ruby-keyword kw">nil</span>
|
|
739
|
+
<span class="ruby-keyword kw">end</span>
|
|
740
|
+
<span class="ruby-keyword kw">end</span>
|
|
741
|
+
</pre>
|
|
742
|
+
</div>
|
|
743
|
+
</div>
|
|
744
|
+
</div>
|
|
745
|
+
|
|
746
|
+
<div id="method-M000164" class="method-detail">
|
|
747
|
+
<a name="M000164"></a>
|
|
230
748
|
|
|
231
749
|
<div class="method-heading">
|
|
232
|
-
<a href="#
|
|
750
|
+
<a href="#M000164" class="method-signature">
|
|
233
751
|
<span class="method-name">handle_request</span><span class="method-args">(context)</span>
|
|
234
752
|
</a>
|
|
235
753
|
</div>
|
|
@@ -239,10 +757,10 @@
|
|
|
239
757
|
called by application to send the session a request
|
|
240
758
|
</p>
|
|
241
759
|
<p><a class="source-toggle" href="#"
|
|
242
|
-
onclick="toggleCode('
|
|
243
|
-
<div class="method-source-code" id="
|
|
760
|
+
onclick="toggleCode('M000164-source');return false;">[Source]</a></p>
|
|
761
|
+
<div class="method-source-code" id="M000164-source">
|
|
244
762
|
<pre>
|
|
245
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 39</span>
|
|
763
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 39</span>
|
|
246
764
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
|
|
247
765
|
<span class="ruby-keyword kw">super</span>
|
|
248
766
|
|
|
@@ -258,21 +776,21 @@ called by application to send the session a request
|
|
|
258
776
|
</div>
|
|
259
777
|
</div>
|
|
260
778
|
|
|
261
|
-
<div id="method-
|
|
262
|
-
<a name="
|
|
779
|
+
<div id="method-M000169" class="method-detail">
|
|
780
|
+
<a name="M000169"></a>
|
|
263
781
|
|
|
264
782
|
<div class="method-heading">
|
|
265
|
-
<a href="#
|
|
783
|
+
<a href="#M000169" class="method-signature">
|
|
266
784
|
<span class="method-name">process_request</span><span class="method-args">()</span>
|
|
267
785
|
</a>
|
|
268
786
|
</div>
|
|
269
787
|
|
|
270
788
|
<div class="method-description">
|
|
271
789
|
<p><a class="source-toggle" href="#"
|
|
272
|
-
onclick="toggleCode('
|
|
273
|
-
<div class="method-source-code" id="
|
|
790
|
+
onclick="toggleCode('M000169-source');return false;">[Source]</a></p>
|
|
791
|
+
<div class="method-source-code" id="M000169-source">
|
|
274
792
|
<pre>
|
|
275
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line
|
|
793
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 102</span>
|
|
276
794
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span>
|
|
277
795
|
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>.<span class="ruby-identifier">nil?</span>
|
|
278
796
|
|
|
@@ -281,11 +799,11 @@ called by application to send the session a request
|
|
|
281
799
|
|
|
282
800
|
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-ivar">@initial_snapshot</span>)
|
|
283
801
|
|
|
284
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-
|
|
802
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@page</span> = <span class="ruby-ivar">@page_store</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>, <span class="ruby-keyword kw">false</span>)
|
|
285
803
|
|
|
286
804
|
<span class="ruby-comment cmt"># A valid page_id was specified and the corresponding page exists.</span>
|
|
287
805
|
|
|
288
|
-
<span class="ruby-
|
|
806
|
+
<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">restore</span>
|
|
289
807
|
|
|
290
808
|
<span class="ruby-identifier">p</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">fields</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
|
|
291
809
|
|
|
@@ -298,9 +816,9 @@ called by application to send the session a request
|
|
|
298
816
|
<span class="ruby-comment cmt"># 2. Render the page (respond).</span>
|
|
299
817
|
<span class="ruby-comment cmt"># 3. Store the page back into the store</span>
|
|
300
818
|
|
|
301
|
-
<span class="ruby-
|
|
302
|
-
<span class="ruby-identifier">respond</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-
|
|
303
|
-
<span class="ruby-ivar">@page_store</span>[<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>] = <span class="ruby-
|
|
819
|
+
<span class="ruby-ivar">@page</span> = <span class="ruby-identifier">create_page</span>(<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span>) <span class="ruby-comment cmt"># remove all action/input handlers</span>
|
|
820
|
+
<span class="ruby-identifier">respond</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-ivar">@page</span>.<span class="ruby-identifier">callbacks</span>) <span class="ruby-comment cmt"># render</span>
|
|
821
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>] = <span class="ruby-ivar">@page</span> <span class="ruby-comment cmt"># store</span>
|
|
304
822
|
|
|
305
823
|
<span class="ruby-keyword kw">else</span>
|
|
306
824
|
|
|
@@ -309,16 +827,27 @@ called by application to send the session a request
|
|
|
309
827
|
<span class="ruby-comment cmt"># We process the request and invoke actions/inputs. Then we generate a</span>
|
|
310
828
|
<span class="ruby-comment cmt"># new page view. </span>
|
|
311
829
|
|
|
312
|
-
<span class="ruby-identifier">callback_stream</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">CallbackStream</span>.<span class="ruby-identifier">new</span>(<span class="ruby-
|
|
830
|
+
<span class="ruby-identifier">callback_stream</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">CallbackStream</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">callbacks</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">fields</span>)
|
|
313
831
|
|
|
314
832
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback_stream</span>.<span class="ruby-identifier">all_of_type</span>(<span class="ruby-identifier">:action</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
|
315
833
|
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Not allowed to specify more than one action callback"</span>
|
|
316
834
|
<span class="ruby-keyword kw">end</span>
|
|
317
835
|
|
|
318
|
-
<span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:
|
|
319
|
-
<span class="ruby-
|
|
836
|
+
<span class="ruby-identifier">live_update_response</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_live_update</span>) {
|
|
837
|
+
<span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_back_to_session</span>) {
|
|
838
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">process_callbacks_chain</span>(<span class="ruby-identifier">callback_stream</span>)
|
|
839
|
+
}
|
|
840
|
+
<span class="ruby-keyword kw">nil</span>
|
|
320
841
|
}
|
|
321
|
-
|
|
842
|
+
|
|
843
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">live_update_response</span>
|
|
844
|
+
<span class="ruby-comment cmt"># replace existing page with new snapshot</span>
|
|
845
|
+
<span class="ruby-ivar">@page</span>.<span class="ruby-identifier">snapshot</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">snapshot</span>
|
|
846
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">page_id</span>] = <span class="ruby-ivar">@page</span>
|
|
847
|
+
<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-identifier">live_update_response</span>
|
|
848
|
+
<span class="ruby-keyword kw">else</span>
|
|
849
|
+
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>)
|
|
850
|
+
<span class="ruby-keyword kw">end</span>
|
|
322
851
|
|
|
323
852
|
<span class="ruby-keyword kw">end</span>
|
|
324
853
|
|
|
@@ -340,21 +869,47 @@ called by application to send the session a request
|
|
|
340
869
|
</div>
|
|
341
870
|
</div>
|
|
342
871
|
|
|
343
|
-
<div id="method-
|
|
344
|
-
<a name="
|
|
872
|
+
<div id="method-M000168" class="method-detail">
|
|
873
|
+
<a name="M000168"></a>
|
|
874
|
+
|
|
875
|
+
<div class="method-heading">
|
|
876
|
+
<a href="#M000168" class="method-signature">
|
|
877
|
+
<span class="method-name">sleep</span><span class="method-args">()</span>
|
|
878
|
+
</a>
|
|
879
|
+
</div>
|
|
880
|
+
|
|
881
|
+
<div class="method-description">
|
|
882
|
+
<p>
|
|
883
|
+
Is called after <a href="Session.html#M000155">process_request</a> is run
|
|
884
|
+
Can be used to release e.g. a database connection.
|
|
885
|
+
</p>
|
|
886
|
+
<p><a class="source-toggle" href="#"
|
|
887
|
+
onclick="toggleCode('M000168-source');return false;">[Source]</a></p>
|
|
888
|
+
<div class="method-source-code" id="M000168-source">
|
|
889
|
+
<pre>
|
|
890
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 99</span>
|
|
891
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sleep</span>
|
|
892
|
+
<span class="ruby-keyword kw">end</span>
|
|
893
|
+
</pre>
|
|
894
|
+
</div>
|
|
895
|
+
</div>
|
|
896
|
+
</div>
|
|
897
|
+
|
|
898
|
+
<div id="method-M000163" class="method-detail">
|
|
899
|
+
<a name="M000163"></a>
|
|
345
900
|
|
|
346
901
|
<div class="method-heading">
|
|
347
|
-
<a href="#
|
|
902
|
+
<a href="#M000163" class="method-signature">
|
|
348
903
|
<span class="method-name">snapshot</span><span class="method-args">()</span>
|
|
349
904
|
</a>
|
|
350
905
|
</div>
|
|
351
906
|
|
|
352
907
|
<div class="method-description">
|
|
353
908
|
<p><a class="source-toggle" href="#"
|
|
354
|
-
onclick="toggleCode('
|
|
355
|
-
<div class="method-source-code" id="
|
|
909
|
+
onclick="toggleCode('M000163-source');return false;">[Source]</a></p>
|
|
910
|
+
<div class="method-source-code" id="M000163-source">
|
|
356
911
|
<pre>
|
|
357
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 33</span>
|
|
912
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 33</span>
|
|
358
913
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">snapshot</span>
|
|
359
914
|
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">backtrack_state_chain</span>(<span class="ruby-identifier">snap</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">new</span>)
|
|
360
915
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">snap</span>.<span class="ruby-identifier">freeze</span>
|
|
@@ -364,21 +919,21 @@ called by application to send the session a request
|
|
|
364
919
|
</div>
|
|
365
920
|
</div>
|
|
366
921
|
|
|
367
|
-
<div id="method-
|
|
368
|
-
<a name="
|
|
922
|
+
<div id="method-M000165" class="method-detail">
|
|
923
|
+
<a name="M000165"></a>
|
|
369
924
|
|
|
370
925
|
<div class="method-heading">
|
|
371
|
-
<a href="#
|
|
926
|
+
<a href="#M000165" class="method-signature">
|
|
372
927
|
<span class="method-name">start_request_response_loop</span><span class="method-args">()</span>
|
|
373
928
|
</a>
|
|
374
929
|
</div>
|
|
375
930
|
|
|
376
931
|
<div class="method-description">
|
|
377
932
|
<p><a class="source-toggle" href="#"
|
|
378
|
-
onclick="toggleCode('
|
|
379
|
-
<div class="method-source-code" id="
|
|
933
|
+
onclick="toggleCode('M000165-source');return false;">[Source]</a></p>
|
|
934
|
+
<div class="method-source-code" id="M000165-source">
|
|
380
935
|
<pre>
|
|
381
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 50</span>
|
|
936
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 50</span>
|
|
382
937
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_request_response_loop</span>
|
|
383
938
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">abort_on_exception</span> = <span class="ruby-keyword kw">true</span>
|
|
384
939
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {
|
|
@@ -404,7 +959,9 @@ called by application to send the session a request
|
|
|
404
959
|
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"invalid request"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">nil?</span>
|
|
405
960
|
|
|
406
961
|
<span class="ruby-keyword kw">begin</span>
|
|
962
|
+
<span class="ruby-identifier">awake</span>
|
|
407
963
|
<span class="ruby-identifier">process_request</span>
|
|
964
|
+
<span class="ruby-identifier">sleep</span>
|
|
408
965
|
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exn</span>
|
|
409
966
|
<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">ErrorResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">exn</span>)
|
|
410
967
|
<span class="ruby-keyword kw">end</span>
|
|
@@ -420,21 +977,138 @@ called by application to send the session a request
|
|
|
420
977
|
|
|
421
978
|
<h3 class="section-bar">Private Instance methods</h3>
|
|
422
979
|
|
|
423
|
-
<div id="method-
|
|
424
|
-
<a name="
|
|
980
|
+
<div id="method-M000159" class="method-detail">
|
|
981
|
+
<a name="M000159"></a>
|
|
982
|
+
|
|
983
|
+
<div class="method-heading">
|
|
984
|
+
<a href="#M000159" class="method-signature">
|
|
985
|
+
<span class="method-name">handle_new_page_view</span><span class="method-args">(context, snapshot=nil)</span>
|
|
986
|
+
</a>
|
|
987
|
+
</div>
|
|
988
|
+
|
|
989
|
+
<div class="method-description">
|
|
990
|
+
<p><a class="source-toggle" href="#"
|
|
991
|
+
onclick="toggleCode('M000159-source');return false;">[Source]</a></p>
|
|
992
|
+
<div class="method-source-code" id="M000159-source">
|
|
993
|
+
<pre>
|
|
994
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 174</span>
|
|
995
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-identifier">context</span>, <span class="ruby-identifier">snapshot</span>=<span class="ruby-keyword kw">nil</span>)
|
|
996
|
+
<span class="ruby-identifier">new_page_id</span> = <span class="ruby-ivar">@idgen</span>.<span class="ruby-identifier">next</span>.<span class="ruby-identifier">to_s</span>
|
|
997
|
+
<span class="ruby-identifier">new_page</span> = <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">snapshot</span> <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">snapshot</span>())
|
|
998
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-identifier">new_page_id</span>] = <span class="ruby-identifier">new_page</span>
|
|
999
|
+
<span class="ruby-identifier">redirect_url</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">build_url</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">request_handler_id</span>, <span class="ruby-identifier">new_page_id</span>)
|
|
1000
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">RedirectResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">redirect_url</span>)
|
|
1001
|
+
<span class="ruby-keyword kw">end</span>
|
|
1002
|
+
</pre>
|
|
1003
|
+
</div>
|
|
1004
|
+
</div>
|
|
1005
|
+
</div>
|
|
1006
|
+
|
|
1007
|
+
<div id="method-M000160" class="method-detail">
|
|
1008
|
+
<a name="M000160"></a>
|
|
1009
|
+
|
|
1010
|
+
<div class="method-heading">
|
|
1011
|
+
<a href="#M000160" class="method-signature">
|
|
1012
|
+
<span class="method-name">respond</span><span class="method-args">(context, callbacks)</span>
|
|
1013
|
+
</a>
|
|
1014
|
+
</div>
|
|
1015
|
+
|
|
1016
|
+
<div class="method-description">
|
|
1017
|
+
<p><a class="source-toggle" href="#"
|
|
1018
|
+
onclick="toggleCode('M000160-source');return false;">[Source]</a></p>
|
|
1019
|
+
<div class="method-source-code" id="M000160-source">
|
|
1020
|
+
<pre>
|
|
1021
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 182</span>
|
|
1022
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">respond</span>(<span class="ruby-identifier">context</span>, <span class="ruby-identifier">callbacks</span>)
|
|
1023
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">GenericResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'text/html'</span>, <span class="ruby-value str">''</span>)
|
|
1024
|
+
|
|
1025
|
+
<span class="ruby-identifier">rctx</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderingContext</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">request</span>, <span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span>, <span class="ruby-identifier">callbacks</span>, <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">HtmlWriter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span>.<span class="ruby-identifier">content</span>))
|
|
1026
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">do_render_chain</span>(<span class="ruby-identifier">rctx</span>)
|
|
1027
|
+
<span class="ruby-keyword kw">end</span>
|
|
1028
|
+
</pre>
|
|
1029
|
+
</div>
|
|
1030
|
+
</div>
|
|
1031
|
+
</div>
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
</div>
|
|
1035
|
+
<div id="section">
|
|
1036
|
+
<h2 class="section-title"><a name="SEC00118">Properties</a></h2>
|
|
1037
|
+
<div class="section-comment">
|
|
1038
|
+
|
|
1039
|
+
</div>
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
<div id="attribute-list">
|
|
1046
|
+
<h3 class="section-bar">Attributes</h3>
|
|
1047
|
+
|
|
1048
|
+
<div class="name-list">
|
|
1049
|
+
<table>
|
|
1050
|
+
<tr class="top-aligned-row context-row">
|
|
1051
|
+
<td class="context-item-name">properties</td>
|
|
1052
|
+
<td class="context-item-value"> [RW] </td>
|
|
1053
|
+
<td class="context-item-desc"></td>
|
|
1054
|
+
</tr>
|
|
1055
|
+
</table>
|
|
1056
|
+
</div>
|
|
1057
|
+
</div>
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
<!-- if method_list -->
|
|
1062
|
+
<div id="methods">
|
|
1063
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
1064
|
+
|
|
1065
|
+
<div id="method-M000172" class="method-detail">
|
|
1066
|
+
<a name="M000172"></a>
|
|
1067
|
+
|
|
1068
|
+
<div class="method-heading">
|
|
1069
|
+
<a href="#M000172" class="method-signature">
|
|
1070
|
+
<span class="method-name">get_property</span><span class="method-args">(prop, klass)</span>
|
|
1071
|
+
</a>
|
|
1072
|
+
</div>
|
|
1073
|
+
|
|
1074
|
+
<div class="method-description">
|
|
1075
|
+
<p>
|
|
1076
|
+
Returns an "owned" property for the given <tt>klass</tt>.
|
|
1077
|
+
</p>
|
|
1078
|
+
<p><a class="source-toggle" href="#"
|
|
1079
|
+
onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
|
|
1080
|
+
<div class="method-source-code" id="M000172-source">
|
|
1081
|
+
<pre>
|
|
1082
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 192</span>
|
|
1083
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_property</span>(<span class="ruby-identifier">prop</span>, <span class="ruby-identifier">klass</span>)
|
|
1084
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@properties</span>
|
|
1085
|
+
<span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">klass</span>, {})[<span class="ruby-identifier">prop</span>]
|
|
1086
|
+
<span class="ruby-keyword kw">else</span>
|
|
1087
|
+
<span class="ruby-keyword kw">nil</span>
|
|
1088
|
+
<span class="ruby-keyword kw">end</span>
|
|
1089
|
+
<span class="ruby-keyword kw">end</span>
|
|
1090
|
+
</pre>
|
|
1091
|
+
</div>
|
|
1092
|
+
</div>
|
|
1093
|
+
</div>
|
|
1094
|
+
|
|
1095
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
|
1096
|
+
|
|
1097
|
+
<div id="method-M000173" class="method-detail">
|
|
1098
|
+
<a name="M000173"></a>
|
|
425
1099
|
|
|
426
1100
|
<div class="method-heading">
|
|
427
|
-
<a href="#
|
|
1101
|
+
<a href="#M000173" class="method-signature">
|
|
428
1102
|
<span class="method-name">handle_new_page_view</span><span class="method-args">(context, snapshot=nil)</span>
|
|
429
1103
|
</a>
|
|
430
1104
|
</div>
|
|
431
1105
|
|
|
432
1106
|
<div class="method-description">
|
|
433
1107
|
<p><a class="source-toggle" href="#"
|
|
434
|
-
onclick="toggleCode('
|
|
435
|
-
<div class="method-source-code" id="
|
|
1108
|
+
onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
|
|
1109
|
+
<div class="method-source-code" id="M000173-source">
|
|
436
1110
|
<pre>
|
|
437
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line
|
|
1111
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 202</span>
|
|
438
1112
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-identifier">context</span>, <span class="ruby-identifier">snapshot</span>=<span class="ruby-keyword kw">nil</span>)
|
|
439
1113
|
<span class="ruby-identifier">new_page_id</span> = <span class="ruby-ivar">@idgen</span>.<span class="ruby-identifier">next</span>.<span class="ruby-identifier">to_s</span>
|
|
440
1114
|
<span class="ruby-identifier">new_page</span> = <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">snapshot</span> <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">snapshot</span>())
|
|
@@ -447,21 +1121,21 @@ called by application to send the session a request
|
|
|
447
1121
|
</div>
|
|
448
1122
|
</div>
|
|
449
1123
|
|
|
450
|
-
<div id="method-
|
|
451
|
-
<a name="
|
|
1124
|
+
<div id="method-M000174" class="method-detail">
|
|
1125
|
+
<a name="M000174"></a>
|
|
452
1126
|
|
|
453
1127
|
<div class="method-heading">
|
|
454
|
-
<a href="#
|
|
1128
|
+
<a href="#M000174" class="method-signature">
|
|
455
1129
|
<span class="method-name">respond</span><span class="method-args">(context, callbacks)</span>
|
|
456
1130
|
</a>
|
|
457
1131
|
</div>
|
|
458
1132
|
|
|
459
1133
|
<div class="method-description">
|
|
460
1134
|
<p><a class="source-toggle" href="#"
|
|
461
|
-
onclick="toggleCode('
|
|
462
|
-
<div class="method-source-code" id="
|
|
1135
|
+
onclick="toggleCode('M000174-source');return false;">[Source]</a></p>
|
|
1136
|
+
<div class="method-source-code" id="M000174-source">
|
|
463
1137
|
<pre>
|
|
464
|
-
<span class="ruby-comment cmt"># File lib/wee/session.rb, line
|
|
1138
|
+
<span class="ruby-comment cmt"># File lib/wee/continuation/session.rb, line 210</span>
|
|
465
1139
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">respond</span>(<span class="ruby-identifier">context</span>, <span class="ruby-identifier">callbacks</span>)
|
|
466
1140
|
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">response</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">GenericResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'text/html'</span>, <span class="ruby-value str">''</span>)
|
|
467
1141
|
|