You are not logged in Log in Join
You are here: Home » Members » Ty Sarna's Zope.Org Page » TinyTable

Log in
Name

Password

 
 

Folder icon TinyTable

TinyTable is a product designed to manage a small amount of tabular data. It's intended to fill the gap between a Z Table or an Z SQL Methods accessed SQL table, which are overkill for many tasks, and folder token properties, which allow only a single "column". TinyTable also makes it possible to look up an item within the list, or to return a subset of the list rows where columns equal particular values.

TinyTable Properties

Columns

Columns is a list of one or more column names separated by spaces. Columns are string-typed by default, but may optionally be integers, long integers, floating-point, or DateTime if the column name is suffixed with :int, :long, :float, or :date or :datetime respectively. :date and :datetime both store Zope DateTime values, but :date values are forced to be date-only, with no time-of-day information.

The first column is special. An index will be built on this column for "lookup" use (see below). The index built is unique. That is, if there are multiple rows with the same first-column value, only one row will appear in the index, and only one row will be returned from an index query. If this is a problem, use a filter on the first row instead (see below).

Data

The data consists of newline-separated rows containing columns separated by commas. Any input data will be adjusted to conform to the column specification. If the row contains too many columns the excess will be trimmed. If the row contains to few columns, columns containing NULL will be added. String values in a column specified to take a number will be replaced by 0.

The form of values is similar to Python syntax. Strings are enclosed in single or double quotes, and backslash escapes are possible. Numbers may be entered just as in Python. Full Python syntax for floating point numbers is supported, including exponent notation. Dates and Date-Times are represented by strings in any of the formats thet the Zope DateTime class understands. Missing (NULL) may also be given as a value for a cell, by using NULL or None, or by simply omitting the value (for example, 1,,3' is treated as 1,NULL,3)

Python comments (#) and line continuations may also be used. Note, however, that once TinyTables extracts the data from the input text, the text is thrown away. When visiting the management edit interface again, the text will be regenerated from the stored data. Comments, blank lines, line continuations, and such will all be lost since they don't alter the data itself.

Querying a TinyTable

Assume you have a table named MyTable. It has these properties:

Columns:

      last first middle n:int x:long

and the following data:

      "smith", "john", "x", 0, 0L
      "smith", "bob", "x", 0, 0L
      "smith", "bob", "z", 0, 0L
      "jones", "bob", "y", 0, 0L
      "jones", "john", "y", 0, 0L
      "jones", "john", "z", 0, 0L 

The data can be queried from DTML in several ways:

Full Query:

        <!--#in MyTable-->

        Iterates through all rows of the TinyTable. Within the
        region contained by 'in' tag, the column names will be
        available as variables and so can be insterted. For
        example on the first iteration, '<!--#var first-->' will
        be replaced with 'john'.

Index Query:

        <!--#in "MyTable('jones')"-->

        The passed argument will be looked up in the table's
        index of the first column. Because the index is unique,
        either zero (if no matching rows) or one (if any
        matching rows) rows will be iterated through. In this
        case, any *one* of the three rows with a last name of
        'jones' could be returned. The choice of which row is
        returned when multiple rows have the same index value is
        unspecified.

Filter Query:

        <!--#in "MyTable(last='jones')"-->
        <!--#in "MyTable(first='john')"-->
        <!--#in "MyTable(last='jones', middle='y')"-->

        When one or more named arguments is given, a filter
        query is performed. Each argument name must be the name
        of a column, and the corresponding value is compared
        against that column in each row. Only matching rows are
        returned. The first example above, in contrast with the
        index query example, returns *all three* rows where the
        last name is 'jones'.

        While an Index Query operates only on the first column,
        a filter query can operate on any column. In the second
        exmple above, all three rows with the first name 'john'
        are returned.

        Finally, multiple filters may be specified. In this
        case only rows matching all contraints are iterated
        through. In the third example above, only the two rows
        where the last name is 'jones' and the middle initial is
        'y' will be returned.

 Title   Type   Size   Modified   Status 
 TinyTable Edit object Software Release   1999-09-21 published
 TinyTable (Obsolete) Edit object Software Release   1999-09-21 published