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.
Files changed (193) hide show
  1. data/INSTALL +7 -0
  2. data/README +268 -0
  3. data/Rakefile +26 -0
  4. data/TODO +116 -0
  5. data/benchmark/Centrino1300/result.2000.counter.action +45 -0
  6. data/benchmark/Centrino1300/result.2000.counter.render +43 -0
  7. data/benchmark/Centrino1300/result.2000.filehandler +43 -0
  8. data/benchmark/Centrino600/result.2000.counter.action +47 -0
  9. data/benchmark/Centrino600/result.2000.counter.render +45 -0
  10. data/benchmark/Centrino600/result.2000.filehandler +43 -0
  11. data/benchmark/Makefile +48 -0
  12. data/benchmark/bench.sh +24 -0
  13. data/benchmark/counter.rb +96 -0
  14. data/benchmark/filehandler.rb +6 -0
  15. data/doc/rdoc/classes/Array.html +172 -0
  16. data/doc/rdoc/classes/Cache.html +126 -0
  17. data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
  18. data/doc/rdoc/classes/Cache/Strategy.html +128 -0
  19. data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
  20. data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
  21. data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
  22. data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
  23. data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
  24. data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
  25. data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
  26. data/doc/rdoc/classes/Enumerable.html +146 -0
  27. data/doc/rdoc/classes/LiteralMethod.html +196 -0
  28. data/doc/rdoc/classes/Object.html +178 -0
  29. data/doc/rdoc/classes/String.html +172 -0
  30. data/doc/rdoc/classes/Struct.html +174 -0
  31. data/doc/rdoc/classes/Wee.html +160 -0
  32. data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
  33. data/doc/rdoc/classes/Wee/Application.html +337 -0
  34. data/doc/rdoc/classes/Wee/Brush.html +245 -0
  35. data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
  36. data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
  37. data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
  38. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
  39. data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
  40. data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
  41. data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
  42. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
  43. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
  44. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
  45. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
  46. data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
  47. data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
  48. data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
  49. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
  50. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
  51. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
  52. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
  53. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
  54. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
  55. data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
  56. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
  57. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
  58. data/doc/rdoc/classes/Wee/Callback.html +231 -0
  59. data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
  60. data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
  61. data/doc/rdoc/classes/Wee/Canvas.html +235 -0
  62. data/doc/rdoc/classes/Wee/Component.html +933 -0
  63. data/doc/rdoc/classes/Wee/Context.html +111 -0
  64. data/doc/rdoc/classes/Wee/Decoration.html +338 -0
  65. data/doc/rdoc/classes/Wee/Delegate.html +247 -0
  66. data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
  67. data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
  68. data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
  69. data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
  70. data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
  71. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
  72. data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
  73. data/doc/rdoc/classes/Wee/Page.html +111 -0
  74. data/doc/rdoc/classes/Wee/Presenter.html +521 -0
  75. data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
  76. data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
  77. data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
  78. data/doc/rdoc/classes/Wee/Request.html +268 -0
  79. data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
  80. data/doc/rdoc/classes/Wee/Response.html +260 -0
  81. data/doc/rdoc/classes/Wee/Session.html +469 -0
  82. data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
  83. data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
  84. data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
  85. data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
  86. data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
  87. data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
  88. data/doc/rdoc/classes/Wee/Utils.html +111 -0
  89. data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
  90. data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
  91. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
  92. data/doc/rdoc/created.rid +1 -0
  93. data/doc/rdoc/files/INSTALL.html +118 -0
  94. data/doc/rdoc/files/README.html +466 -0
  95. data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
  96. data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
  97. data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
  98. data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
  99. data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
  100. data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
  101. data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
  102. data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
  103. data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
  104. data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
  105. data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
  106. data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
  107. data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
  108. data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
  109. data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
  110. data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
  111. data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
  112. data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
  113. data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
  114. data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
  115. data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
  116. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
  117. data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
  118. data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
  119. data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
  120. data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
  121. data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
  122. data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
  123. data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
  124. data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
  125. data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
  126. data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
  127. data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
  128. data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
  129. data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
  130. data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
  131. data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
  132. data/doc/rdoc/files/lib/wee_rb.html +132 -0
  133. data/doc/rdoc/fr_class_index.html +93 -0
  134. data/doc/rdoc/fr_file_index.html +51 -0
  135. data/doc/rdoc/fr_method_index.html +242 -0
  136. data/doc/rdoc/index.html +24 -0
  137. data/doc/rdoc/rdoc-style.css +208 -0
  138. data/examples/ObjectSpaceBrowser.rb +199 -0
  139. data/examples/calendar.rb +366 -0
  140. data/examples/cc.rb +94 -0
  141. data/examples/draw.rb +91 -0
  142. data/examples/example.rb +223 -0
  143. data/examples/test.rb +66 -0
  144. data/examples/window.rb +53 -0
  145. data/lib/cache/cache.rb +9 -0
  146. data/lib/wee.rb +18 -8
  147. data/lib/wee/adaptors/webrick.rb +73 -0
  148. data/lib/wee/application.rb +69 -71
  149. data/lib/wee/context.rb +2 -12
  150. data/lib/wee/core.rb +15 -0
  151. data/lib/wee/core/callback.rb +108 -0
  152. data/lib/wee/core/component.rb +314 -0
  153. data/lib/wee/core/decoration.rb +129 -0
  154. data/lib/wee/core/presenter.rb +132 -0
  155. data/lib/wee/core/snapshot.rb +21 -0
  156. data/lib/wee/core/valueholder.rb +19 -0
  157. data/lib/wee/idgen.rb +13 -0
  158. data/lib/wee/page.rb +1 -1
  159. data/lib/wee/renderer/html/brushes.rb +435 -0
  160. data/lib/wee/renderer/html/canvas.rb +148 -0
  161. data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
  162. data/lib/wee/request.rb +57 -0
  163. data/lib/wee/requesthandler.rb +77 -0
  164. data/lib/wee/response.rb +77 -0
  165. data/lib/wee/session.rb +70 -64
  166. data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
  167. data/test/components/calltest.rb +16 -0
  168. data/test/components/counter.rb +17 -0
  169. data/test/components/messagebox.rb +15 -0
  170. data/test/components/page.rb +14 -0
  171. data/test/components/page_decoration.rb +7 -0
  172. data/test/stress.rb +64 -0
  173. data/test/test_component.rb +106 -0
  174. data/test/test_html_canvas.rb +25 -0
  175. data/test/test_html_writer.rb +27 -0
  176. data/test/test_request.rb +13 -0
  177. data/test/utils/cross.rb +65 -0
  178. data/test/utils/generic_plotter.rb +28 -0
  179. data/test/utils/gnuplot.rb +31 -0
  180. data/test/utils/measure_memory.rb +9 -0
  181. data/test/utils/memory_plotter.rb +10 -0
  182. data/test/utils/object_plotter.rb +10 -0
  183. data/test/utils/webrick_background.rb +31 -0
  184. data/wee.gemspec +22 -0
  185. metadata +222 -18
  186. data/lib/wee/component.rb +0 -126
  187. data/lib/wee/delegate_decoration.rb +0 -22
  188. data/lib/wee/handler_registry.rb +0 -89
  189. data/lib/wee/holder.rb +0 -14
  190. data/lib/wee/html_canvas.rb +0 -379
  191. data/lib/wee/state_registry.rb +0 -173
  192. data/lib/wee/stuff.rb +0 -29
  193. data/lib/wee/webrick.rb +0 -15
@@ -0,0 +1,466 @@
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>File: README</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="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jan 05 14:36:24 CET 2005</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1><a href="../classes/Wee.html">Wee</a> Web Framework</h1>
73
+ <h2>Copyright and License</h2>
74
+ <p>
75
+ Copyright &#169; 2004, 2005 by Michael Neumann (mneumann@ntecs.de).
76
+ </p>
77
+ <p>
78
+ Released under the same terms of license as Ruby. Some files under
79
+ directory <tt>examples/</tt> might be copyrighted by third parties and
80
+ licensed under different terms.
81
+ </p>
82
+ <h2>Status and Bugs</h2>
83
+ <p>
84
+ <a href="../classes/Wee.html">Wee</a> is not considered production ready!
85
+ It should only be used for small things.
86
+ </p>
87
+ <p>
88
+ Known Bugs:
89
+ </p>
90
+ <ul>
91
+ <li>Continuations leak memory!
92
+
93
+ </li>
94
+ <li>Sessions get never reclaimed (easy to fix).
95
+
96
+ </li>
97
+ </ul>
98
+ <h2>Introduction</h2>
99
+ <p>
100
+ <a href="../classes/Wee.html">Wee</a> is a light-weight, very high-level
101
+ and modern web-framework that makes <b>W</b>eb <b>e</b>ngineering
102
+ <b>e</b>asy. It mainly inherits many ideas and features from <a
103
+ href="http://beta4.com/seaside2">Seaside2</a>, but was written from scratch
104
+ without ever looking at the Seaside (or any other) sources. All code was
105
+ developed from ideas and lots of discussions with Avi Bryant.
106
+ </p>
107
+ <h2>Features</h2>
108
+ <h3>Reusable components</h3>
109
+ <p>
110
+ <a href="../classes/Wee.html">Wee</a> has <em>real</em> components, which
111
+ are like widgets in a GUI. Once written, you can use them everywhere. They
112
+ are completely independent and do not interfere with other components.
113
+ Components encapsulate state, a view and actions. Of course you can use an
114
+ external model or use templates for rendering.
115
+ </p>
116
+ <h3>Backtracking</h3>
117
+ <p>
118
+ See the <em>What is backtracking?</em> section below. In short,
119
+ backtracking lets the browser&#8217;s back and forward-button play well
120
+ together with your application.
121
+ </p>
122
+ <h3>Clean and concise</h3>
123
+ <p>
124
+ <a href="../classes/Wee.html">Wee</a> is well thought out, is written in
125
+ <b>and</b> supports clean and concise code. Furthermore I think most parts
126
+ are now very well documented.
127
+ </p>
128
+ <h3>Abstract core</h3>
129
+ <p>
130
+ The core of <a href="../classes/Wee.html">Wee</a> is completely independent
131
+ of both HTTP and HTML. That means, with little effort, you should be able
132
+ to render other formats than HTML and use other communication protocols
133
+ like SOAP, XML-RPC, Email, GUI or Console.
134
+ </p>
135
+ <h3>Templating-independent</h3>
136
+ <p>
137
+ <a href="../classes/Wee.html">Wee</a> does not depend on a special
138
+ templating-engine. You can use a different templating engine for each
139
+ component if you want.
140
+ </p>
141
+ <h3>Powerful programmatic HTML generation</h3>
142
+ <p>
143
+ <a href="../classes/Wee.html">Wee</a> ships with an easy to use and very
144
+ powerful programmatic html-generation library. For example you can create a
145
+ select list easily with this piece of code:
146
+ </p>
147
+ <pre>
148
+ # select an object from these items
149
+ items = [1, 2, 3, 4]
150
+
151
+ # the labels shown to the user
152
+ labels = items.map {|i| i.to_s}
153
+
154
+ # render it
155
+ r.select_list(items).labels(labels).callback {|choosen| p choosen}
156
+
157
+ # render a multi-select list, with objects 2 and 4 selected
158
+ r.select_list(items).multi.labels(labels).selected([2,4])
159
+ </pre>
160
+ <p>
161
+ The callback is called with the selected objects from the <em>items</em>
162
+ array. Items can be any object, e.g. whole components:
163
+ </p>
164
+ <pre>
165
+ labels = [&quot;msg1&quot;, &quot;msg2&quot;]
166
+ items = labels.collect {|m| MessageBox.new(m)}
167
+ r.select_list(items).labels(labels).callback {|choosen| call choosen.first}
168
+ </pre>
169
+ <h3>Continuation based (Optional)</h3>
170
+ <p>
171
+ <b>IMPORTANT:</b> <em>The current implementation of continuations in Ruby
172
+ might lead to memory leaks, if you use continuations. Furthermore, if you
173
+ use continuations, it&#8217;s no longer possible to store the session state
174
+ to disk.</em>
175
+ </p>
176
+ <p>
177
+ Continuation-based frameworks are also known as <em>modal</em> frameworks.
178
+ You can write code like the one shown below (taken from one of Avi&#8217;s
179
+ emails) where each method displays a new page:
180
+ </p>
181
+ <pre>
182
+ def checkout
183
+ billing = getAddress(&quot;Billing Address&quot;)
184
+ if useSeparateShippingAddress()
185
+ shipping = getAddress(&quot;Shipping Address&quot;)
186
+ else
187
+ shipping = billing
188
+ end
189
+ payment = getPaymentInfo()
190
+ showConfirmation(billing, shipping, payment)
191
+ end
192
+ </pre>
193
+ <p>
194
+ Try to implement the same in a non-continuation based framework and show me
195
+ your code&#8230; ;-)
196
+ </p>
197
+ <h3>Fully Marshallable (drops Continuation support)</h3>
198
+ <p>
199
+ If you don&#8217;t need continuations, <a
200
+ href="../classes/Wee.html">Wee</a> can be made fully marshallable. It is
201
+ not yet fully marshallable (it was in the past), but it can be made, if
202
+ required.
203
+ </p>
204
+ <h2>Observations and Limitations</h2>
205
+ <ul>
206
+ <li>Using continuations (might) lead to memory leaks!
207
+
208
+ </li>
209
+ <li>When using continuations for cross-component calls, it&#8217;s impossible
210
+ to store a session to disk (at least in Ruby). This problem is partly
211
+ addressed by checkpointing provided by operating systems like <a
212
+ href="http://www.dragonflybsd.org">DragonFly</a>. But with this approach
213
+ it&#8217;s still impossible to store sessions <em>selectively</em> to disk.
214
+
215
+ </li>
216
+ <li>Each session runs in it&#8217;s own (light-weigth) thread (this is a
217
+ neccessity when using continuations).
218
+
219
+ </li>
220
+ <li>Only one action callback can be invoked per request (a former version of <a
221
+ href="../classes/Wee.html">Wee</a> was able to invoke multiple callback,
222
+ and answer even from multiple components at the same time, but this was
223
+ removed, due to the unreliability of continuations in Ruby).
224
+
225
+ </li>
226
+ <li>Components are thread-safe, as a fresh components-tree is created for each
227
+ session and requests inside a session are serialized.
228
+
229
+ </li>
230
+ </ul>
231
+ <h2>What is backtracking?</h2>
232
+ <p>
233
+ If you want, you can make the back-button of your browser work correctly
234
+ together with your web-application. Imagine you have a simple counter
235
+ application, which shows the current count and two links <em>inc</em> and
236
+ <em>dec</em> with which you can increase or decrease the current count.
237
+ Starting with an inital count of 0, you increase the counter up to 8, then
238
+ click three times the back button of your browser (now displays 5) and
239
+ finally decrease by one, then the counter really shows the expected 4,
240
+ instead of 7 (as clicking the back button does usually not send a HTTP
241
+ request, and the last state of your application was 8).
242
+ </p>
243
+ <p>
244
+ Only individual objects are backtracked, those of which you explicitly take
245
+ a snapshot, not the whole component. That&#8217;s the easiest (from an
246
+ application programmers perspective) and most flexible way. And its fast
247
+ and uses less memory.
248
+ </p>
249
+ <p>
250
+ You can decide yourself whether you want infinite backtracking or only
251
+ backtracking up to n pages, with whatever replacement strategy you want,
252
+ least recently used (LRU), least frequently used (LFU) etc.
253
+ </p>
254
+ <h2>Decorations</h2>
255
+ <p>
256
+ Decorations are used to modify the look and behaviour of a component,
257
+ without modifying the components tree. A component can have more than one
258
+ decoration. This is implemented as a linked list of decorations
259
+ (Wee::Decoration#owner points to the next decoration). <a
260
+ href="../classes/Wee/Component.html#M000170">Wee::Component#decoration</a>
261
+ points to the first decoration in the chain or to the component itself, if
262
+ no decorations were specified. We actually use a <a
263
+ href="../classes/Wee/ValueHolder.html">Wee::ValueHolder</a> for the
264
+ <tt>@decoration</tt> instance variable of class <a
265
+ href="../classes/Wee/Component.html">Wee::Component</a> to be able to
266
+ easily backtrack it (required if you want to &quot;undo&quot; component
267
+ calls).
268
+ </p>
269
+ <h2>The anatomy of a request/response cycle</h2>
270
+ <p>
271
+ The request/response cycle in <a href="../classes/Wee.html">Wee</a> is
272
+ actually split into two separate phases or steps. Depending on the
273
+ point-of-view (given that a page is rendered and the user clicks on a link
274
+ or button), the first phase is to invoke an action (a
275
+ &quot;callback&quot;). Then in the second phase, a new page is rendered and
276
+ sent back to the user. So the two steps are:
277
+ </p>
278
+ <ol>
279
+ <li>invoke callbacks (action phase)
280
+
281
+ </li>
282
+ <li>render new page and display (render phase)
283
+
284
+ </li>
285
+ </ol>
286
+ <p>
287
+ These two phases repeat permanently. Which tasks are performed in each of
288
+ them, is briefly listed below:
289
+ </p>
290
+ <p>
291
+ <b>Action:</b>
292
+ </p>
293
+ <ol>
294
+ <li>restore snapshot (if not up-to-date)
295
+
296
+ </li>
297
+ <li>invoke actions
298
+
299
+ </li>
300
+ <li>backtrack state
301
+
302
+ </li>
303
+ <li>update url -&gt; redirect to render phase (not yet)
304
+
305
+ </li>
306
+ </ol>
307
+ <p>
308
+ <b>Render:</b>
309
+ </p>
310
+ <ol>
311
+ <li>restore snapshot (if not up-to-date)
312
+
313
+ </li>
314
+ <li>render
315
+
316
+ </li>
317
+ </ol>
318
+ <p>
319
+ For each session there is at most one request handled at the same time.
320
+ That means, that there is either one action request or one render request
321
+ handled. Why? Because we have only one components tree, which we update on
322
+ action requests. As <a href="../classes/Wee.html">Wee</a> allows to go back
323
+ in time, we have to restore this components tree to a certain point in time
324
+ before we can handle an action or render request. This disallows to handle
325
+ e.g. two render requests simultaneous.
326
+ </p>
327
+ <h3>Action Phase (Invoking Callbacks)</h3>
328
+ <p>
329
+ Possible sources for callbacks are links (anchors) and all kinds of
330
+ form-elements like submit buttons, input-fields etc. There are two
331
+ different kinds of callbacks:
332
+ </p>
333
+ <ul>
334
+ <li>Input callbacks (input-fields)
335
+
336
+ </li>
337
+ <li>Action callbacks (anchor, submit-button)
338
+
339
+ </li>
340
+ </ul>
341
+ <p>
342
+ The distinction between input and action callbacks is important, as action
343
+ callbacks might depend on values of input-fields being assigned to instance
344
+ variables of the controlling component. Hence, <a
345
+ href="../classes/Wee.html">Wee</a> first invokes all input callbacks before
346
+ any action callback is triggered.
347
+ </p>
348
+ <p>
349
+ There are two methods related to callback processing:
350
+ </p>
351
+ <ul>
352
+ <li><a
353
+ href="../classes/Wee/Component.html#M000165">Wee::Component#process_callbacks_chain</a>
354
+
355
+ </li>
356
+ <li><a
357
+ href="../classes/Wee/Presenter.html#M000187">Wee::Presenter#process_callbacks</a>
358
+
359
+ </li>
360
+ </ul>
361
+ <p>
362
+ Note that each <a href="../classes/Wee/Component.html">Wee::Component</a>
363
+ is also a <a href="../classes/Wee/Presenter.html">Wee::Presenter</a>,
364
+ whereas a <a href="../classes/Wee/Decoration.html">Wee::Decoration</a> is
365
+ not a Component (but a Presenter)!
366
+ </p>
367
+ <p>
368
+ Method <em>process_callbacks_chain</em> invokes <em>process_callbacks</em>
369
+ for it&#8217;s first decoration, or if the component has no decorations,
370
+ the method is called for the component itself. As such,
371
+ <em>process_callbacks_chain</em> is important to avoid entering an infinite
372
+ loop (a method calling itself). What decorations are, is discussed
373
+ elsewhere.
374
+ </p>
375
+ <p>
376
+ Method <em>process_callbacks</em> of class Component first invokes all
377
+ input callbacks specified for this component, then calls
378
+ <em>process_callbacks_chain</em> for all of it&#8217;s child components.
379
+ This ensures, that all input callbacks are triggered before the first
380
+ action callback is run. Finally, it invokes all of it&#8217;s action
381
+ callbacks.
382
+ </p>
383
+ <h3>Rendering Phase</h3>
384
+ <p>
385
+ The rendering phase is assumed to be side-effect free! So, you as a
386
+ programmer should take care to meet this assumption.
387
+ </p>
388
+ <p>
389
+ Similar as in the callback-step, there are two methods related to rendering
390
+ a page:
391
+ </p>
392
+ <ul>
393
+ <li><a
394
+ href="../classes/Wee/Component.html#M000163">Wee::Component#do_render_chain</a>
395
+
396
+ </li>
397
+ <li><a
398
+ href="../classes/Wee/Presenter.html#M000182">Wee::Presenter#do_render</a>
399
+
400
+ </li>
401
+ </ul>
402
+ <p>
403
+ Method <em>Component#do_render_chain</em> starts rendering the decoration
404
+ chain by calling <em>Presenter#do_render</em> for the first decoration of
405
+ the component or for the component itself if no decorations were specified.
406
+ Method <em>Presenter#do_render</em> then generates the desired output which
407
+ gets sent to the user. Note that method <em>do_render</em> might call other
408
+ components&#8217; <em>do_render_chain</em> methods to display those
409
+ components &quot;inside&quot; itself (usually a component does this for
410
+ it&#8217;s child components, but this has to be implemented by the
411
+ programmer).
412
+ </p>
413
+ <h3>Further Reads</h3>
414
+ <p>
415
+ In this order:
416
+ </p>
417
+ <ul>
418
+ <li><a href="../classes/Wee/Presenter.html">Wee::Presenter</a>
419
+
420
+ </li>
421
+ <li><a href="../classes/Wee/Component.html">Wee::Component</a>
422
+
423
+ </li>
424
+ <li><a href="../classes/Wee/Decoration.html">Wee::Decoration</a>
425
+
426
+ </li>
427
+ <li><a href="../classes/Wee/Delegate.html">Wee::Delegate</a>
428
+
429
+ </li>
430
+ <li><a href="../classes/Wee/AnswerDecoration.html">Wee::AnswerDecoration</a>
431
+
432
+ </li>
433
+ </ul>
434
+
435
+ </div>
436
+
437
+
438
+ </div>
439
+
440
+
441
+ </div>
442
+
443
+
444
+ <!-- if includes -->
445
+
446
+ <div id="section">
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+ <!-- if method_list -->
456
+
457
+
458
+ </div>
459
+
460
+
461
+ <div id="validator-badges">
462
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
463
+ </div>
464
+
465
+ </body>
466
+ </html>