NAME

DefaultSchema.pm - Local schema-specific routines for Verdad


SYNOPSIS

In verdad.conf, add "schema-check = DefaultSchema"

In Verdad.pm, they get called as such:

        @err = itemLint($dbh, $itemRef);
        if (scalar(@err) == 0) {
                foreach (@err) {
                        warn($_ . "\n");
                }
                exit 1;
        }
        
        itemExpand($dbh, $itemRef);
        hasPerms($dbh, $user, $type, $name, $action);


DESCRIPTION

This module enforces local conventions on the syntax and structure of the data in a Verdad database.

To use it, edit Verdad.pm to include a schema module for your site. Replace "DefaultSchema" with the name of your local schema file, for instance "TellmeSchema".

Before accepting a new or edited item, Verdad.pm will run itemLint() on it. If itemLint() returns errors, the item will not be accepted, and the user will be required to fix the errors before getting the item entered into the database. itemLint() may not modify the item (and in fact, might be working on a copy of the item, for all it knows).

When a caller requests an item, itemExpand() will have a chance to edit the item. Generally, this should be used to add tags that can be computed from other tags in the item.

If itemExpand() discovers an error, it should die(). If the caller wants to catch errors, they can use eval.

The function hasPerms() is called at various times to check whether or not an action is permitted. The current user, the type of element ("item" or "tag"), the name of the element, and the type of action ("add", "delete", "modify", "write", or "read") are passed in. The function should return either true or false (1 or 0). "write" is a generic writeability check where "add", "delete", and "modify" are considered sub-classes of the generic "write" check.


SEE ALSO

See Verdad.pm's documentation for more info on the $itemRef structure.


AUTHOR

Jeff R. Allen <jra@nella.org>