| t | Here are some notes on the new item refactoring: | t | |
| <p> | | |
| I'm writing some general-purpose routines to support managing content | | |
| from multiple locations, in multiple formats. | | |
| <p> | | |
| <h2><a name="location">location</a> | | |
| <span align=right class="section_edit_link">[<a href="/tbwiki/ItemNotes?action=edit§ion=location">edit section</a>]</font></span> | | |
| </h2> | | |
| A tbwiki "item" is a logical unit of the wiki, and can be one of the | | |
| following: | | |
| <ul><li>page | | |
| <li>block | | |
| <li>section | | |
| <li>row | | |
| <li>field | | |
| </ul> | | |
| <p> | | |
| A page is a whole file. A block is an item inside a file, defined by the | | |
| triple-brace syntax. A section is an item inside a file, defined by the | | |
| header syntax. A row is something that can be inside a page, block, or section. | | |
| This is used to express moin table rows. A field can be a single-line entry | | |
| appearing on a page, and defined by the definition list syntax. | | |
| <p> | | |
| <h2><a name="content_format">content_format</a> | | |
| <span align=right class="section_edit_link">[<a href="/tbwiki/ItemNotes?action=edit§ion=content_format">edit section</a>]</font></span> | | |
| </h2> | | |
| Each item is expressed in the raw text in a format: | | |
| <ul><li>tbmarkup - this is page data, and may hold sub-items, but does not itself express a record | | |
| <li>moin_table - this is a set of rows of moin-formatted table lines (starting with ||) | | |
| <li>tbattr - this is a single record in my 'config' format (supporting single and multi-line entries, and comments | | |
| <li>tbwikidb - this represents data attributes with definition entries and sections (in tbmarkup) | | |
| <li>json - usually whole-page, supports single, multi-line and list entries | | |
| <li>yaml - usually whole-page, supports single, multi-line and list entries, as well as comments and ordering | | |
| <li>moin_table_row - this defines a single record in a moin_table | | |
| </ul> | | |
| <p> | | |
| <h2><a name="item_class">item_class</a> | | |
| <span align=right class="section_edit_link">[<a href="/tbwiki/ItemNotes?action=edit§ion=item_class">edit section</a>]</font></span> | | |
| </h2> | | |
| A new set of routines is supposed to replace all previous access and update | | |
| routines for content, and allow different systems to access data items in | | |
| the wiki in a uniform manner. The different systems that need to access | | |
| the items are: | | |
| <ul><li>processors | | |
| <li>tables | | |
| <li>data handler (for tbclient) | | |
| <li>other external engines (Fuego) | | |
| </ul> | | |
| <p> | | |
| The idea is that items are addressable with a uniform resource string. | | |
| <p> | | |
| <h2><a name="item_class_routines">item_class routines</a> | | |
| <span align=right class="section_edit_link">[<a href="/tbwiki/ItemNotes?action=edit§ion=item_class_routines">edit section</a>]</font></span> | | |
| </h2> | | |
| Here are the functions supported by the new item_class: | | |
| <ul><li>__init__(name, location, source_file, parent) | | |
| <li>get_content() - load the content from it's source | | |
| <li>evalute_content() - execute processor, if any, for the content | | |
| <li>to_html() - convert item to html (for output) | | |
| <li>content_to_data() - convert content into data (parse it) | | |
| <li>data_to_content() - convert data into content (format it) | | |
| <li>update() - update one element of the data with a new value | | |
| <li>set_content() - push this content to parent (container item) | | |
| <li>write_content() - put content back on disk | | |
| </ul> | | |
| <p> | | |
| internal helper routines: | | |
| <ul><li>data_to_html() - convert data representation to html | | |
| </ul> | | |
| <p> | | |
| <h2><a name="example_uses">example uses</a> | | |
| <span align=right class="section_edit_link">[<a href="/tbwiki/ItemNotes?action=edit§ion=example_uses">edit section</a>]</font></span> | | |
| </h2> | | |
| <ul><li>in main page wiki: | | |
| <ul><li>show: | | |
| <ul><li>page = item_class(req.page_name, "page", req.page_filename) | | |
| <li>html = page.to_html() | | |
| </ul><li>in section edit_form: | | |
| <ul><li>page = item_class(req.page_name, "page", req.page_filename) | | |
| <li>section = item_class(section_name, "section", req.page_filename, page) | | |
| <li>put section.content into edit form | | |
| </ul><li>in section_edit action: | | |
| <ul><li>page = item_class(req.page_name, "page", req.page_filename) | | |
| <li>section = item_class(section_name, "section", req.page_filename, page) | | |
| <li>section.update(value_from_form) | | |
| <li>section.set_content() | | |
| <li>page.write_content() | | |
| </ul><li>in Processor: | | |
| <ul><li>parse_conf(block) | | |
| </ul><li>in data_handler: | | |
| <ul><li>get_page_item | | |
| <li>put_page_item | | |
| </ul><li>in table: | | |
| <ul><li>for source in source_list: | | |
| <ul><li>get_record(source) | | |
| <ul><li>page = item_class(req.page_name, "page", req.page_filename) | | |
| <li>record = make_record(page) | | |
| <ul><li>data = page.content_to_data() | | |
| <li>add field stuff | | |
| </ul></ul><li>format for table | | |
| </ul> | | |
| </ul> | | |
| </ul> | | |
| </ul> | | |
| <p> | | |