FrontPage 

TB Wiki

Login

Regression Test

Expected HTML for page "Table_Architecture"


expected html
nothing
t1 t
2<table align="right"><tr><td><div class="toc">
3Contents:
4<ul>
5  <ul>
6    <li><a href="#Table_types">Table&nbsp;types</a></li>
7    <ul>
8      <li><a href="#commonalities_and_differences">commonalities&nbsp;and&nbsp;differences</a></li>
9    </ul>
10    <li><a href="#Form_creation">Form&nbsp;creation</a></li>
11    <li><a href="#Schema_determination">Schema&nbsp;determination</a></li>
12    <ul>
13      <li><a href="#Field_attributes">Field&nbsp;attributes</a></li>
14      <ul>
15        <li><a href="#Field_color">Field&nbsp;color</a></li>
16      </ul>
17    </ul>
18    <li><a href="#Current_Code">Current&nbsp;Code</a></li>
19    <li><a href="#New_Code_(Refactor_ideas)">New&nbsp;Code&nbsp;(Refactor&nbsp;ideas)</a></li>
20    <li><a href="#Interface_A_-_between_table.py_and_db">Interface&nbsp;A&nbsp;-&nbsp;between&nbsp;table.py&nbsp;and&nbsp;db</a></li>
21    <li><a href="#Interface_B_-_between_db_and_tbwiki_engine">Interface&nbsp;B&nbsp;-&nbsp;between&nbsp;db&nbsp;and&nbsp;tbwiki_engine</a></li>
22  </ul>
23</ul>
24</div></td></tr></table>
25<p>
26This page describes the TBWiki table architecture
27<p>
28Table data is managed in the TBWiki with the table module.
29<p>
30<h2><a name="Table_types">Table types</a>
31<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Table_types">edit section</a>]</font></span>
32</h2>
33The table code recognizes three distinct table types:
34<ul><li>attribute databases
35<li>row-column databases
36<li>scraped databases
37</ul>
38<p>
39Attribute databases consist of records which have name-value
40pairs.  These are usually read from multiple TBWiki page files.
41<p>
42Row-column databases consist of values which are associated
43with each other by row and column (similar to a relational
44database).  These are usually read from a single TBWiki page file
45Currently, the data is formatted in MoinMoin table markup.
46<p>
47Writing code to handle these two different types of tables
48is challenging.
49<p>
50<h3><a name="commonalities_and_differences">commonalities and differences</a>
51<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=commonalities_and_differences">edit section</a>]</font></span>
52</h3>
53Here are some commonalities and differences between the two
54database types:
55<ul><li>attr dbs have sparse field values (not every record has every field)
56<li>attr dbs are parsed from multiple files
57<li>attr dbs have to keep track of which record came from which file
58<li>attr dbs have NO inherent record or field ordering
59</ul>
60<p>
61<ul><li>row-col dbs have no identifying record-id (this has to be synthesized
62 from the row position)
63<li>row-col dbs have inherent record and field ordering (row and col position)
64</ul>
65<p>
66Another possible database is the web-scraped database.
67<p>
68This database has records and fields which are "scraped" from
69existing TBWiki pages or from external web sites.
70<ul><li>scraped dbs have sparse field values
71<li>scraped dbs have non-editable fields
72</ul>
73<p>
74<h2><a name="Form_creation">Form creation</a>
75<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Form_creation">edit section</a>]</font></span>
76</h2>
77The current table code can create simple data entry forms for
78a database that consists of fields on type "single-line text".
79<p>
80The current table code supports user-specified data entry forms.
81<p>
82Forms for displaying the database and for adding or editing records
83are expressed as multi-line strings with python string variables
84where the field values or field form elements are to be placed.
85The rest of the form is expressed in HTML (not TBWiki markup).
86<p>
87For example, if a database 'People' has 'Name' and 'Phone' fields, a form
88for outputting this could look like this:
89<pre>
90"""&lt;table&gt;
91&lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Phone&lt;/td&gt;&lt;/tr&gt;
92&lt;tr&gt;&lt;td&gt;%(Name)s&lt;/td&gt;&lt;td&gt;%(Phone)s&lt;/td&gt;&lt;/tr&gt;
93&lt;/table&gt;"""
94[This example is not complete.]
95</pre>
96How do you specify the start, record portion and end of a formspec??
97<p>
98<hr size=2>
99A record data entry form might look like this:
100<pre>
101Name: %(NameField)s
102Phone: %(PhoneField)s
103%(SaveButton)s %(CancelButton)s
104</pre>
105<p>
106Forms can be stored as TBWiki pages, with the names:
107PeopleAddForm or PeopleEditForm.
108<p>
109It would be nice to auto-detect form elements for checkboxes, radio
110buttons, selects, and multi-line text.
111<p>
112(Maybe use schema-by-example...???)
113<p>
114<h2><a name="Schema_determination">Schema determination</a>
115<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Schema_determination">edit section</a>]</font></span>
116</h2>
117Field names are autodetected from the table data itself.
118<p>
119Field attributes, such as type (which can influence the type of form element
120used for inputing that field), possible values, and others, are expressed
121in a configuration block.  These are referred to internally as the field_db.
122<p>
123Here's a sample field_db block:
124<pre>
125field=Description
126type=TextArea
127 
128field=Status
129type=Select
130possible_values="""not done
131in progress
132done"""
133colors="""not done:red
134in progress:yellow
135done:green"""
136</pre>
137<p>
138<h3><a name="Field_attributes">Field attributes</a>
139<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Field_attributes">edit section</a>]</font></span>
140</h3>
141Possible types are:
142<ul><li>Text
143<li>TextArea
144<li>Select
145<li>Radio
146<li>Checkbox
147</ul>
148<p>
149Field attributes currently implemented are:
150<ul><li>type
151<li>possible_values
152<li>colors
153</ul>
154<p>
155<h4><a name="Field_color">Field color</a>
156<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Field_color">edit section</a>]</font></span>
157</h4>
158The syntax for colors is:
159colors="""&lt;cexpr&gt;:&lt;color&gt;
160&lt;cexpr2&gt;:&lt;color2&gt;
161..."""
162<p>
163&lt;cexpr&gt; can be a straight value, or an boolean expression.
164If it is a boolean expression, it must start with an open paren, '(',
165and do some comparison on the variable 'value'.  A &lt;cexpr&gt; which is
166a straight variable is converted into the expression:
167"(value=="&lt;variable&gt;")"
168<p>
169The following are some examples:
170<pre>colors="""not done: red
171done:green"""
172</pre>
173<p>
174<pre>colors="""(int(value)&lt;5):green
175(int(value)&gt;=6):red"""
176</pre>
177<p>
178Field attributes that I've thought about, but are not implemented yet are:
179<ul><li>constraints - complex expression-oriented constraints, such as "one of", "in range", or "re.match"
180<li>display_attrs - more complex display attributes (besides just bgcolor)
181</ul>
182<p>
183<h2><a name="Current_Code">Current Code</a>
184<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Current_Code">edit section</a>]</font></span>
185</h2>
186table.py
187<p>
188functions:
189<ul><li>def print_error(msg):
190<li>def generate_field_input(col_name, field_type, value):
191<li>class form_field_generator_class():
192<ul><li>def __init__(self, record, col_map, field_type_hints=None):
193<li>def __getitem__(self, key):
194</ul><li>def cell_trans(value):
195<li>def value_trans(value):
196<li>class table_class():
197<ul><li>def __init__(self, source_spec, page_name="(no page name)"):
198<li>def add_or_edit_numbered_record(self, record, record_id=""):
199<li>def remove_numbered_record(self, record_id):
200<li>def set_col_output_list(self, order=None):
201<li>def set_row_output_list(self, order=None):
202<li>def set_row_filter(self, filter):
203<li>def filter_match(self, record):
204<li>def show(self):
205<li>def add_to_message(self, message):
206<li>def html_string(self):
207<li>def show_form(self, form_spec=None, record_id=None):
208<li>def show_record_form(self, form_spec=None, record_id=None):
209<li>def show_edit_table_form(self, form_spec=None):
210<li>def edit_link(self):
211</ul><li>def get_table(req, args):
212<li>def get_form_spec(req, tb, form, source_spec, operation):
213<li>def add_row_form(req):
214<li>def edit_table(req):
215<li>def parse_moin_table(tb, data, source_spec):
216<li>def read_moin_table_file(tb, data_dir, source_spec):
217<li>def read_moin_table_from_page(tb, data_dir, source_spec):
218<li>def read_attrdb_file(file_path, source_spec):
219<li>def load_schema(tb):
220<li>def db_from_attrdb_files(tb, data_dir, source_spec):
221<li>def save_attrs_to_file(tb, record):
222<li>def save_attrdb(tb):
223<li>def remove_attrdb_file(tb, record_id):
224<li>def render_moin_table(tb):
225<li>def get_table_type(source_spec):
226<li>def get_table_data(req, data_dir, source_spec, page_name):
227<li>def save_table_data(data_dir, source_spec, tb):
228<li>def action(req):
229</ul>
230<p>
231<h2><a name="New_Code_(Refactor_ideas)">New Code (Refactor ideas)</a>
232<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=New_Code_(Refactor_ideas)">edit section</a>]</font></span>
233</h2>
234Split code into:
235<ul><li>db read
236<li>db present
237<li>db edit
238<li>db write
239</ul>
240<p>
241Allow different presentation modules and different editing modules:
242<ul><li>present as a list of records
243<li>present as a table
244<li>add a single record
245<li>edit a single record
246<li>edit as a table
247</ul>
248<p>
249[Describe different interfaces here]
250<p>
251<h2><a name="Interface_A_-_between_table.py_and_db">Interface A - between table.py and db</a>
252<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Interface_A_-_between_table.py_and_db">edit section</a>]</font></span>
253</h2>
254<ul><li>db_read()
255<li>db_write()
256<li>db_get_record(record_id)
257<li>db_update_record(record, record_id)
258<li>db_add_record(record, record_id)
259<li>db_remove_record(record_id)
260<li>db_backup()??
261</ul>
262<p>
263<h2><a name="Interface_B_-_between_db_and_tbwiki_engine">Interface B - between db and tbwiki_engine</a>
264<span align=right class="section_edit_link">[<a href="/tbwiki/Table_Architecture?action=edit&section=Interface_B_-_between_db_and_tbwiki_engine">edit section</a>]</font></span>
265</h2>
266<ul><li>read_page(page_name[, page_namespace??])
267<li>write_page(page_name[, page_namespace??])
268<li>make_backup(page_name[, page_namespace??])
269<li>read_page_item(page_name, item_name)
270<li>write_page_item(page_name, item_name, content)
271</ul>
272<p>
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

Differences for page "Table_Architecture"


expected html
generated html
t No Differences Found t No Differences Found 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

Update saved output

Back to diff page

Return to Regression_Test page
TBWiki engine 1.9.3 by Tim Bird