Chapter 4. Design Outline

YakTrack is itself simply a modular command-line program which "builds itself" by adding subcommands on execution. Essentially, the main YakTrack application is a composite (as per the design pattern of the same name) which maintains a dictionary of children indexed by command name; each of the children is itself a composite. When executed, then, the main composite_command object is created and fleshed out with standard commands. To add local commands (commands local to the repository), the file in the yaktrack-options repository subdirectory is loaded and executed; this allows local extensions (subclasses of composite_command) to be created and added to the base "skeleton" at run-time. Commands added with the same name as an existing command override that behaviour (so it is very possible to replace standard commands with derived versions), and adding commands to the basic application is encouraged. One useful end-user command, for example, might be an add-history command which entered a short text note with the user's name in the HISTORY field of a given report, saving the user the trouble of querying to get a copy of the report, editing it, and refiling it.

The command line is parsed by taking the first token, finding the subcommand indexed by that subtoken, and passing the rest of the command line to that subcommand; if no subcommand can be found, the current command is executed with the given command line. In other words, for the command yaktrack file -f sample.xml, the root composite_command gets the command line "file -f sample.xml" and finds its child named "file", which is passed the command line "-f sample.xml". The "file" command has no subcommand "-f", and so interprets the command line as arguments to itsef. This sort of modularity of commands makes for a very insular design, and also encourages a straightforward scripting style through Python (where each command is treated as a distinct object and is passed a command line for execution).

The XML parsing will be handled through the existing Python XML libraries by creating a SAX-compliant parser; in reality, the basic YakTrack application will not do much XML transformation, focusing mostly on loading a file and searching it (for queries).

The default web gateway should be simple and not involve external software such as Zope, probably falling back on simple CGI scripts (probably just calling YakTrack with a command line generated via the target URL). More elegant designs using Zope or similar application frameworks would be welcome, but should not be part of the core submission.