wee 0.1.0 → 0.3.1
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/INSTALL +7 -0
- data/README +268 -0
- data/Rakefile +26 -0
- data/TODO +116 -0
- data/benchmark/Centrino1300/result.2000.counter.action +45 -0
- data/benchmark/Centrino1300/result.2000.counter.render +43 -0
- data/benchmark/Centrino1300/result.2000.filehandler +43 -0
- data/benchmark/Centrino600/result.2000.counter.action +47 -0
- data/benchmark/Centrino600/result.2000.counter.render +45 -0
- data/benchmark/Centrino600/result.2000.filehandler +43 -0
- data/benchmark/Makefile +48 -0
- data/benchmark/bench.sh +24 -0
- data/benchmark/counter.rb +96 -0
- data/benchmark/filehandler.rb +6 -0
- data/doc/rdoc/classes/Array.html +172 -0
- data/doc/rdoc/classes/Cache.html +126 -0
- data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
- data/doc/rdoc/classes/Cache/Strategy.html +128 -0
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
- data/doc/rdoc/classes/Enumerable.html +146 -0
- data/doc/rdoc/classes/LiteralMethod.html +196 -0
- data/doc/rdoc/classes/Object.html +178 -0
- data/doc/rdoc/classes/String.html +172 -0
- data/doc/rdoc/classes/Struct.html +174 -0
- data/doc/rdoc/classes/Wee.html +160 -0
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
- data/doc/rdoc/classes/Wee/Application.html +337 -0
- data/doc/rdoc/classes/Wee/Brush.html +245 -0
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
- data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
- data/doc/rdoc/classes/Wee/Callback.html +231 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
- data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
- data/doc/rdoc/classes/Wee/Canvas.html +235 -0
- data/doc/rdoc/classes/Wee/Component.html +933 -0
- data/doc/rdoc/classes/Wee/Context.html +111 -0
- data/doc/rdoc/classes/Wee/Decoration.html +338 -0
- data/doc/rdoc/classes/Wee/Delegate.html +247 -0
- data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
- data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
- data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
- data/doc/rdoc/classes/Wee/Page.html +111 -0
- data/doc/rdoc/classes/Wee/Presenter.html +521 -0
- data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
- data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
- data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
- data/doc/rdoc/classes/Wee/Request.html +268 -0
- data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
- data/doc/rdoc/classes/Wee/Response.html +260 -0
- data/doc/rdoc/classes/Wee/Session.html +469 -0
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
- data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
- data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
- data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
- data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
- data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
- data/doc/rdoc/classes/Wee/Utils.html +111 -0
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
- data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/INSTALL.html +118 -0
- data/doc/rdoc/files/README.html +466 -0
- data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
- data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
- data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee_rb.html +132 -0
- data/doc/rdoc/fr_class_index.html +93 -0
- data/doc/rdoc/fr_file_index.html +51 -0
- data/doc/rdoc/fr_method_index.html +242 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/ObjectSpaceBrowser.rb +199 -0
- data/examples/calendar.rb +366 -0
- data/examples/cc.rb +94 -0
- data/examples/draw.rb +91 -0
- data/examples/example.rb +223 -0
- data/examples/test.rb +66 -0
- data/examples/window.rb +53 -0
- data/lib/cache/cache.rb +9 -0
- data/lib/wee.rb +18 -8
- data/lib/wee/adaptors/webrick.rb +73 -0
- data/lib/wee/application.rb +69 -71
- data/lib/wee/context.rb +2 -12
- data/lib/wee/core.rb +15 -0
- data/lib/wee/core/callback.rb +108 -0
- data/lib/wee/core/component.rb +314 -0
- data/lib/wee/core/decoration.rb +129 -0
- data/lib/wee/core/presenter.rb +132 -0
- data/lib/wee/core/snapshot.rb +21 -0
- data/lib/wee/core/valueholder.rb +19 -0
- data/lib/wee/idgen.rb +13 -0
- data/lib/wee/page.rb +1 -1
- data/lib/wee/renderer/html/brushes.rb +435 -0
- data/lib/wee/renderer/html/canvas.rb +148 -0
- data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
- data/lib/wee/request.rb +57 -0
- data/lib/wee/requesthandler.rb +77 -0
- data/lib/wee/response.rb +77 -0
- data/lib/wee/session.rb +70 -64
- data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
- data/test/components/calltest.rb +16 -0
- data/test/components/counter.rb +17 -0
- data/test/components/messagebox.rb +15 -0
- data/test/components/page.rb +14 -0
- data/test/components/page_decoration.rb +7 -0
- data/test/stress.rb +64 -0
- data/test/test_component.rb +106 -0
- data/test/test_html_canvas.rb +25 -0
- data/test/test_html_writer.rb +27 -0
- data/test/test_request.rb +13 -0
- data/test/utils/cross.rb +65 -0
- data/test/utils/generic_plotter.rb +28 -0
- data/test/utils/gnuplot.rb +31 -0
- data/test/utils/measure_memory.rb +9 -0
- data/test/utils/memory_plotter.rb +10 -0
- data/test/utils/object_plotter.rb +10 -0
- data/test/utils/webrick_background.rb +31 -0
- data/wee.gemspec +22 -0
- metadata +222 -18
- data/lib/wee/component.rb +0 -126
- data/lib/wee/delegate_decoration.rb +0 -22
- data/lib/wee/handler_registry.rb +0 -89
- data/lib/wee/holder.rb +0 -14
- data/lib/wee/html_canvas.rb +0 -379
- data/lib/wee/state_registry.rb +0 -173
- data/lib/wee/stuff.rb +0 -29
- data/lib/wee/webrick.rb +0 -15
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: Wee::Session</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Wee::Session</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/wee/session_rb.html">
|
|
59
|
+
lib/wee/session.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="RequestHandler.html">
|
|
69
|
+
Wee::RequestHandler
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- banner header -->
|
|
76
|
+
|
|
77
|
+
<div id="bodyContent">
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div id="contextContent">
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div id="method-list">
|
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
|
89
|
+
|
|
90
|
+
<div class="name-list">
|
|
91
|
+
<a href="#M000129">create_page</a>
|
|
92
|
+
<a href="#M000124">current</a>
|
|
93
|
+
<a href="#M000131">handle_new_page_view</a>
|
|
94
|
+
<a href="#M000127">handle_request</a>
|
|
95
|
+
<a href="#M000125">new</a>
|
|
96
|
+
<a href="#M000130">process_request</a>
|
|
97
|
+
<a href="#M000132">respond</a>
|
|
98
|
+
<a href="#M000126">snapshot</a>
|
|
99
|
+
<a href="#M000128">start_request_response_loop</a>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<!-- if includes -->
|
|
107
|
+
|
|
108
|
+
<div id="section">
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<div id="attribute-list">
|
|
115
|
+
<h3 class="section-bar">Attributes</h3>
|
|
116
|
+
|
|
117
|
+
<div class="name-list">
|
|
118
|
+
<table>
|
|
119
|
+
<tr class="top-aligned-row context-row">
|
|
120
|
+
<td class="context-item-name">page_store</td>
|
|
121
|
+
<td class="context-item-value"> [RW] </td>
|
|
122
|
+
<td class="context-item-desc"></td>
|
|
123
|
+
</tr>
|
|
124
|
+
<tr class="top-aligned-row context-row">
|
|
125
|
+
<td class="context-item-name">root_component</td>
|
|
126
|
+
<td class="context-item-value"> [RW] </td>
|
|
127
|
+
<td class="context-item-desc"></td>
|
|
128
|
+
</tr>
|
|
129
|
+
</table>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
<!-- if method_list -->
|
|
136
|
+
<div id="methods">
|
|
137
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
138
|
+
|
|
139
|
+
<div id="method-M000124" class="method-detail">
|
|
140
|
+
<a name="M000124"></a>
|
|
141
|
+
|
|
142
|
+
<div class="method-heading">
|
|
143
|
+
<a href="#M000124" class="method-signature">
|
|
144
|
+
<span class="method-name">current</span><span class="method-args">()</span>
|
|
145
|
+
</a>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div class="method-description">
|
|
149
|
+
<p><a class="source-toggle" href="#"
|
|
150
|
+
onclick="toggleCode('M000124-source');return false;">[Source]</a></p>
|
|
151
|
+
<div class="method-source-code" id="M000124-source">
|
|
152
|
+
<pre>
|
|
153
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 7</span>
|
|
154
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current</span>
|
|
155
|
+
<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
|
+
<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>
|
|
157
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sess</span>
|
|
158
|
+
<span class="ruby-keyword kw">end</span>
|
|
159
|
+
</pre>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div id="method-M000125" class="method-detail">
|
|
165
|
+
<a name="M000125"></a>
|
|
166
|
+
|
|
167
|
+
<div class="method-heading">
|
|
168
|
+
<a href="#M000125" class="method-signature">
|
|
169
|
+
<span class="method-name">new</span><span class="method-args">(&block)</span>
|
|
170
|
+
</a>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<div class="method-description">
|
|
174
|
+
<p><a class="source-toggle" href="#"
|
|
175
|
+
onclick="toggleCode('M000125-source');return false;">[Source]</a></p>
|
|
176
|
+
<div class="method-source-code" id="M000125-source">
|
|
177
|
+
<pre>
|
|
178
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 13</span>
|
|
179
|
+
<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
|
+
<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
|
+
|
|
182
|
+
<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>
|
|
183
|
+
<span class="ruby-ivar">@in_queue</span>, <span class="ruby-ivar">@out_queue</span> = <span class="ruby-constant">SizedQueue</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>), <span class="ruby-constant">SizedQueue</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>)
|
|
184
|
+
|
|
185
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>)
|
|
186
|
+
|
|
187
|
+
<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>
|
|
188
|
+
<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>
|
|
189
|
+
|
|
190
|
+
<span class="ruby-ivar">@initial_snapshot</span> = <span class="ruby-identifier">snapshot</span>()
|
|
191
|
+
|
|
192
|
+
<span class="ruby-identifier">start_request_response_loop</span>
|
|
193
|
+
<span class="ruby-keyword kw">super</span>()
|
|
194
|
+
<span class="ruby-keyword kw">ensure</span>
|
|
195
|
+
<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>
|
|
196
|
+
<span class="ruby-keyword kw">end</span>
|
|
197
|
+
</pre>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
203
|
+
|
|
204
|
+
<div id="method-M000129" class="method-detail">
|
|
205
|
+
<a name="M000129"></a>
|
|
206
|
+
|
|
207
|
+
<div class="method-heading">
|
|
208
|
+
<a href="#M000129" class="method-signature">
|
|
209
|
+
<span class="method-name">create_page</span><span class="method-args">(snapshot)</span>
|
|
210
|
+
</a>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div class="method-description">
|
|
214
|
+
<p><a class="source-toggle" href="#"
|
|
215
|
+
onclick="toggleCode('M000129-source');return false;">[Source]</a></p>
|
|
216
|
+
<div class="method-source-code" id="M000129-source">
|
|
217
|
+
<pre>
|
|
218
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 65</span>
|
|
219
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">snapshot</span>)
|
|
220
|
+
<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
|
+
<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>))
|
|
222
|
+
<span class="ruby-keyword kw">end</span>
|
|
223
|
+
</pre>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<div id="method-M000127" class="method-detail">
|
|
229
|
+
<a name="M000127"></a>
|
|
230
|
+
|
|
231
|
+
<div class="method-heading">
|
|
232
|
+
<a href="#M000127" class="method-signature">
|
|
233
|
+
<span class="method-name">handle_request</span><span class="method-args">(context)</span>
|
|
234
|
+
</a>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
<div class="method-description">
|
|
238
|
+
<p>
|
|
239
|
+
called by application to send the session a request
|
|
240
|
+
</p>
|
|
241
|
+
<p><a class="source-toggle" href="#"
|
|
242
|
+
onclick="toggleCode('M000127-source');return false;">[Source]</a></p>
|
|
243
|
+
<div class="method-source-code" id="M000127-source">
|
|
244
|
+
<pre>
|
|
245
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 38</span>
|
|
246
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle_request</span>(<span class="ruby-identifier">context</span>)
|
|
247
|
+
<span class="ruby-keyword kw">super</span>
|
|
248
|
+
|
|
249
|
+
<span class="ruby-comment cmt"># Send a request to the session. If the session is currently busy</span>
|
|
250
|
+
<span class="ruby-comment cmt"># processing another request, this will block. </span>
|
|
251
|
+
<span class="ruby-ivar">@in_queue</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">context</span>)
|
|
252
|
+
|
|
253
|
+
<span class="ruby-comment cmt"># Wait for the response.</span>
|
|
254
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@out_queue</span>.<span class="ruby-identifier">pop</span>
|
|
255
|
+
<span class="ruby-keyword kw">end</span>
|
|
256
|
+
</pre>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
<div id="method-M000130" class="method-detail">
|
|
262
|
+
<a name="M000130"></a>
|
|
263
|
+
|
|
264
|
+
<div class="method-heading">
|
|
265
|
+
<a href="#M000130" class="method-signature">
|
|
266
|
+
<span class="method-name">process_request</span><span class="method-args">()</span>
|
|
267
|
+
</a>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div class="method-description">
|
|
271
|
+
<p><a class="source-toggle" href="#"
|
|
272
|
+
onclick="toggleCode('M000130-source');return false;">[Source]</a></p>
|
|
273
|
+
<div class="method-source-code" id="M000130-source">
|
|
274
|
+
<pre>
|
|
275
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 70</span>
|
|
276
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span>
|
|
277
|
+
<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
|
+
|
|
279
|
+
<span class="ruby-comment cmt"># No page_id was specified in the URL. This means that we start with a</span>
|
|
280
|
+
<span class="ruby-comment cmt"># fresh component and a fresh page_id, then redirect to render itself.</span>
|
|
281
|
+
|
|
282
|
+
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-ivar">@initial_snapshot</span>)
|
|
283
|
+
|
|
284
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">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
|
+
|
|
286
|
+
<span class="ruby-comment cmt"># A valid page_id was specified and the corresponding page exists.</span>
|
|
287
|
+
|
|
288
|
+
<span class="ruby-identifier">page</span>.<span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">restore</span>
|
|
289
|
+
|
|
290
|
+
<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
|
+
|
|
292
|
+
<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>
|
|
293
|
+
|
|
294
|
+
<span class="ruby-comment cmt"># No action/inputs were specified -> render page</span>
|
|
295
|
+
<span class="ruby-comment cmt">#</span>
|
|
296
|
+
<span class="ruby-comment cmt"># 1. Reset the action/input fields (as they are regenerated in the</span>
|
|
297
|
+
<span class="ruby-comment cmt"># rendering process).</span>
|
|
298
|
+
<span class="ruby-comment cmt"># 2. Render the page (respond).</span>
|
|
299
|
+
<span class="ruby-comment cmt"># 3. Store the page back into the store</span>
|
|
300
|
+
|
|
301
|
+
<span class="ruby-identifier">page</span> = <span class="ruby-identifier">create_page</span>(<span class="ruby-identifier">page</span>.<span class="ruby-identifier">snapshot</span>) <span class="ruby-comment cmt"># remove all action/input handlers</span>
|
|
302
|
+
<span class="ruby-identifier">respond</span>(<span class="ruby-ivar">@context</span>, <span class="ruby-identifier">page</span>.<span class="ruby-identifier">callbacks</span>) <span class="ruby-comment cmt"># render</span>
|
|
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-identifier">page</span> <span class="ruby-comment cmt"># store</span>
|
|
304
|
+
|
|
305
|
+
<span class="ruby-keyword kw">else</span>
|
|
306
|
+
|
|
307
|
+
<span class="ruby-comment cmt"># Actions/inputs were specified.</span>
|
|
308
|
+
<span class="ruby-comment cmt">#</span>
|
|
309
|
+
<span class="ruby-comment cmt"># We process the request and invoke actions/inputs. Then we generate a</span>
|
|
310
|
+
<span class="ruby-comment cmt"># new page view. </span>
|
|
311
|
+
|
|
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-identifier">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
|
+
|
|
314
|
+
<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
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Not allowed to specify more than one action callback"</span>
|
|
316
|
+
<span class="ruby-keyword kw">end</span>
|
|
317
|
+
|
|
318
|
+
<span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:wee_back_to_session</span>) {
|
|
319
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">process_callbacks_chain</span>(<span class="ruby-identifier">callback_stream</span>)
|
|
320
|
+
}
|
|
321
|
+
<span class="ruby-identifier">handle_new_page_view</span>(<span class="ruby-ivar">@context</span>)
|
|
322
|
+
|
|
323
|
+
<span class="ruby-keyword kw">end</span>
|
|
324
|
+
|
|
325
|
+
<span class="ruby-keyword kw">else</span>
|
|
326
|
+
|
|
327
|
+
<span class="ruby-comment cmt"># A page_id was specified in the URL, but there's no page for it in the</span>
|
|
328
|
+
<span class="ruby-comment cmt"># page store. Either the page has timed out, or an invalid page_id was</span>
|
|
329
|
+
<span class="ruby-comment cmt"># specified. </span>
|
|
330
|
+
<span class="ruby-comment cmt">#</span>
|
|
331
|
+
<span class="ruby-comment cmt"># TODO:: Display an "invalid page or page timed out" message, which</span>
|
|
332
|
+
<span class="ruby-comment cmt"># forwards to /app/session-id</span>
|
|
333
|
+
|
|
334
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Not yet implemented"</span>
|
|
335
|
+
|
|
336
|
+
<span class="ruby-keyword kw">end</span>
|
|
337
|
+
<span class="ruby-keyword kw">end</span>
|
|
338
|
+
</pre>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<div id="method-M000126" class="method-detail">
|
|
344
|
+
<a name="M000126"></a>
|
|
345
|
+
|
|
346
|
+
<div class="method-heading">
|
|
347
|
+
<a href="#M000126" class="method-signature">
|
|
348
|
+
<span class="method-name">snapshot</span><span class="method-args">()</span>
|
|
349
|
+
</a>
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<div class="method-description">
|
|
353
|
+
<p><a class="source-toggle" href="#"
|
|
354
|
+
onclick="toggleCode('M000126-source');return false;">[Source]</a></p>
|
|
355
|
+
<div class="method-source-code" id="M000126-source">
|
|
356
|
+
<pre>
|
|
357
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 32</span>
|
|
358
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">snapshot</span>
|
|
359
|
+
<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
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">snap</span>.<span class="ruby-identifier">freeze</span>
|
|
361
|
+
<span class="ruby-keyword kw">end</span>
|
|
362
|
+
</pre>
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
<div id="method-M000128" class="method-detail">
|
|
368
|
+
<a name="M000128"></a>
|
|
369
|
+
|
|
370
|
+
<div class="method-heading">
|
|
371
|
+
<a href="#M000128" class="method-signature">
|
|
372
|
+
<span class="method-name">start_request_response_loop</span><span class="method-args">()</span>
|
|
373
|
+
</a>
|
|
374
|
+
</div>
|
|
375
|
+
|
|
376
|
+
<div class="method-description">
|
|
377
|
+
<p><a class="source-toggle" href="#"
|
|
378
|
+
onclick="toggleCode('M000128-source');return false;">[Source]</a></p>
|
|
379
|
+
<div class="method-source-code" id="M000128-source">
|
|
380
|
+
<pre>
|
|
381
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 49</span>
|
|
382
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_request_response_loop</span>
|
|
383
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">abort_on_exception</span> = <span class="ruby-keyword kw">true</span>
|
|
384
|
+
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {
|
|
385
|
+
<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>
|
|
386
|
+
<span class="ruby-identifier">loop</span> {
|
|
387
|
+
<span class="ruby-ivar">@context</span> = <span class="ruby-ivar">@in_queue</span>.<span class="ruby-identifier">pop</span>
|
|
388
|
+
<span class="ruby-keyword kw">begin</span>
|
|
389
|
+
<span class="ruby-identifier">process_request</span>
|
|
390
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exn</span>
|
|
391
|
+
<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>)
|
|
392
|
+
<span class="ruby-keyword kw">end</span>
|
|
393
|
+
<span class="ruby-ivar">@out_queue</span>.<span class="ruby-identifier">push</span>(<span class="ruby-ivar">@context</span>)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
<span class="ruby-keyword kw">end</span>
|
|
397
|
+
</pre>
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
|
|
402
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
|
403
|
+
|
|
404
|
+
<div id="method-M000131" class="method-detail">
|
|
405
|
+
<a name="M000131"></a>
|
|
406
|
+
|
|
407
|
+
<div class="method-heading">
|
|
408
|
+
<a href="#M000131" class="method-signature">
|
|
409
|
+
<span class="method-name">handle_new_page_view</span><span class="method-args">(context, snapshot=nil)</span>
|
|
410
|
+
</a>
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
<div class="method-description">
|
|
414
|
+
<p><a class="source-toggle" href="#"
|
|
415
|
+
onclick="toggleCode('M000131-source');return false;">[Source]</a></p>
|
|
416
|
+
<div class="method-source-code" id="M000131-source">
|
|
417
|
+
<pre>
|
|
418
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 135</span>
|
|
419
|
+
<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>)
|
|
420
|
+
<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>
|
|
421
|
+
<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>())
|
|
422
|
+
<span class="ruby-ivar">@page_store</span>[<span class="ruby-identifier">new_page_id</span>] = <span class="ruby-identifier">new_page</span>
|
|
423
|
+
<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>)
|
|
424
|
+
<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>)
|
|
425
|
+
<span class="ruby-keyword kw">end</span>
|
|
426
|
+
</pre>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
<div id="method-M000132" class="method-detail">
|
|
432
|
+
<a name="M000132"></a>
|
|
433
|
+
|
|
434
|
+
<div class="method-heading">
|
|
435
|
+
<a href="#M000132" class="method-signature">
|
|
436
|
+
<span class="method-name">respond</span><span class="method-args">(context, callbacks)</span>
|
|
437
|
+
</a>
|
|
438
|
+
</div>
|
|
439
|
+
|
|
440
|
+
<div class="method-description">
|
|
441
|
+
<p><a class="source-toggle" href="#"
|
|
442
|
+
onclick="toggleCode('M000132-source');return false;">[Source]</a></p>
|
|
443
|
+
<div class="method-source-code" id="M000132-source">
|
|
444
|
+
<pre>
|
|
445
|
+
<span class="ruby-comment cmt"># File lib/wee/session.rb, line 143</span>
|
|
446
|
+
<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>)
|
|
447
|
+
<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>)
|
|
448
|
+
|
|
449
|
+
<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>))
|
|
450
|
+
<span class="ruby-ivar">@root_component</span>.<span class="ruby-identifier">do_render_chain</span>(<span class="ruby-identifier">rctx</span>)
|
|
451
|
+
<span class="ruby-keyword kw">end</span>
|
|
452
|
+
</pre>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
</div>
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
<div id="validator-badges">
|
|
465
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
466
|
+
</div>
|
|
467
|
+
|
|
468
|
+
</body>
|
|
469
|
+
</html>
|