DocInternalAPI 

TB Wiki

Login

DocInternalAPI

Here are some details about the operation of the code and the internal APIs available:

tbwiki_engine.py [edit section]

Classes overview [edit section]

  • class stub_class - formerly used as a flat-attribute class, like a struct, for the wiki config
  • class config_class - used for the wiki config
  • class user_class - used for user accounts
  • class req_class - used for the main request data
  • class data_class - used for data output into headers, footers, and pages
  • class parse_state - holds the context for the current parse

Functions [edit section]

 * def html_error(msg):
 * def html_escape(str):
 * def make_link(href, cover):
 * def add_to_log(req, action, timestamp, message):
 * def scan_log(req, page_name):
 * def get_env(key):
 * def show_env(env, full=0):
 * def authenticate_user(req, name, password):
 * def create_user(req, name, password):
 * def html_bullet(state, indent, rest):
 * def show_close(state):
 * def html_close(state):
 * def do_search(req, patc):
 * def do_diff(req, page1, page2):
 * def get_section(data, section):
 * def get_named_block(lines, block_name):
 * def put_named_block(lines, block_name, new_content):
 * def set_section(data, section, section_text):
 * def block_to_html(req, data):
 * def line_to_html(state, line, continuation=0):
 * def save_uploaded_file(req, form_field, upload_dir):
 * def main(req)

main(req): details [edit section]

def main(req):

Main steps:

  • get the URL and POST query data
  • determine what action should be performed. This defaults to "show" and is specified in the URL with "action=<foo>"
  • parse the page name out of the URL or query
  • set the user
  • load plugins (macros and processors)
  • do main action loop, which is a "while not handled:"
    • check permissions (actions that need read and actions that need write)
    • show
      • show header
      • read page data
      • convert to html
      • print html
      • set handled and break!
    • raw - show unconverted text (just html_escape it)
    • split - print raw and formatted content side-by-side, for each paragraph
    • edit - show an edit form
    • save - save the data from an edit form
    • links_here - show pages that link to this one (using do_search)
    • search - show pages that match search term
    • history - scan backups directory and show table of previous page versions
    • info - show information about a page (last edit time, size, etc.)
    • diff - show a diff of two revisions from the history page
    • user.loginform - show a login form
    • user.login - authenticate user, and set their cookie
      • after authentication, loop to a 'show' action
    • user.logout - clear the user account, and set the cookie
      • after logging out, loop to a 'show' action
    • user.createform - show a form for creating a user
    • user.create - create a new user file based on the form
    • user.editform - edit user data based on the form
    • user.edit - save edited user data (NOT CURRENTLY IMPLEMENTED)
    • upload - show form for uploading 3 files
    • do_upload - process form for uploading files
    • rename - show a rename form
    • do_rename - process form for renaming a page
    • delete - show a delete form
    • really_delete - process form for deleting a page
    • check for processor actions, of the form <processor_name>:<action>
      • if found a match, call it
      • consider the request handled, on return
    • if no action matches, show an error
  • finally, show the footer

Classes details [edit section]

class stub_class:

class config_class:
    def __init__(self):

class user_class:
    def __init__(self, name = "not-logged-in"):

class req_class:
    def __init__(self, config):
    def set_page_name(self, page_name):
    def page_filename(self):
    def read_page(self, page_name=""):
    def get_page_item(self, item_ref):
    def put_page_item(self, item_ref, data):
    def make_backup(self, content, page_name=""):
    def make_backup_from_file(self, page_name=""):
    def write_page(self, content, page_name=""):
    def foo(self):
    def make_url(self, page_name):
    def html_escape(self, str):
    def add_to_message(self, msg):
    def add_msg_and_traceback(self, msg):
    def show_header(self, title):
    def show_footer(self):
    def set_user(self):
    def check_permission(self, wanted_access, page=None):
    def parse_attrs(self, data):

class data_class:
    def __init__(self, req, init_data = {} ):
    def __getitem__(self, key):
    def page_url(self, req):
    def asctime(self, req):
    def login_form(self, req):
    def login_form_nobr(self, req):
    def nav_box_sidebar(self, req):
    def nav_bar(self, req):
    def nav_bar_bar(self, req):
    def search_form(self, req):
    def search_form_nobr(self, req):
    def toolbox(self, req):
    def action_bar(self, req):
    def message(self, req):

class parse_state:
	def __init__(self, req):

table.py [edit section]

Classes overview [edit section]

  • class form_fields_generator_class:
  • class range_class:
  • class io_handler_base:
    • class io_handler_test(io_handler_base):
    • class io_handler_moin_file(io_handler_base):
    • class io_handler_moin_in_page(io_handler_base):
    • class io_handler_attr_files(io_handler_base):
    • class io_handler_parsed_files(io_handler_base):
  • class table_conf_class:
  • class table_class:

Functions [edit section]

def print_error(msg):
def generate_field_input(tb, col_name, field_type, value, record_id):
def value_trans(tb, value):
def parse_range(tb, cell_row, cell_col, formula):
def do_sum(tb, range):
def parse_formula(tb, cell_row, cell_col, formula):
def value_eval(tb, cell_row, cell_col, value):
def rec_sort(id1, id2):
def cmp_rev(a,b):
def cmp_int(a,b):
def cmp_rev_int(a,b):
def set_sort_col_list(tb, sort_col_spec_str):
def gen_row_output_list(tb, sortby_spec):
def setup_conf_and_db(req, block=""):
def macro_get_table(req, args):
def get_table(req, content):
def add_record_form(req):
def query_form(req):
def edit_table(req):
def edit_table_in_place(req):
def parse_moin_table(tb, data, source_spec):
def read_page_or_block(req, spec, data_dir=""):
def write_block(req, spec, data_dir, data):
def parse_attrdb_data(data, record_id_name):
def read_attrdb_file(file_path, source_spec):
def get_filelist(data_dir, source_spec):
def db_from_attrdb_files(tb, data_dir, source_spec):
def db_from_parsed_files(tb, data_dir, source_spec):
def save_attrs_to_file(tb, record):
def remove_attrdb_file(tb, record_id):
def convert_table_to_dict(tb, convert_nums=0):
def render_moin_table(tb):
def get_table_type(conf, source_spec):
def get_table_data(req, data_dir, source_spec, page_name, conf):
def action(req):
def test():

Classes details [edit section]

class form_fields_generator_class:
	def __init__(self, tb, record, col_map, field_type_hints=None):
	def __getitem__(self, key):

class range_class:
	def __init__(self, start_row, start_col, end_row, end_col):
	def get_direction(self):
	def __repr__(self):

class io_handler_base:
	def __init__(self, req, tb, source_spec):
	def read(self):
	def get_record(self, record_id):
	def add_record(self, record_id):
	def update_record(self, record_id):
	def remove_record(self, record_id):
	def write(self):

class table_conf_class:
        def __init__(self):
        def set_color_lists(self):
        def get_conf(self, req, data=""):

class table_class:
	def __init__(self, req, conf, source_spec, page_name="(no page name)"):
	def lookup(self, cell_row, cell_col, ref_addr):
	def set_value(self, row, col, value):
	def get_value(self, row, col):
	def add_or_edit_numbered_record(self, record, record_id=""):
	def remove_numbered_record(self, record_id):
	def set_col_output_list(self, order=None):
	def set_row_output_list(self, order=None):
	def set_row_filter(self, filter):
	def filter_match(self, record):
	def show(self):
	def add_to_message(self, message):
	def html_string(self):
	def get_default_edit_form_spec(self):
	def show_record_edit_form(self, form_spec=None, record_id=None):
	def show_edit_table_form(self, form_spec=None):
	def get_default_line_edit_form_spec(self):
	def show_edit_table_in_place_form(self, form_spec=None):
	def edit_links(self):
	def show_query_form(self):

data_scan.py [edit section]

vgchart.py [edit section]

TBWiki engine 1.9.1 by Tim Bird