Web admins

If there are many webs, it may not be easy to get hold of people responsible for a web.
So it's handy if all webs have their admins clearly defined.
Given that, let's assume we define admins for each web and store as a part of web metadata.

Site metadata and web metadata fields

The following fields are needed in a site metadata record to implement the federation shown above.

mdrepo add TABLERECORD_IDFIELD_NAME=VALUE ...

Adds a new record. It returns nothing. If the specified record already exists, it complains.

Example:

$ ./mdrepo add webs WebFour admin=HofstadterGroup master=am

mdrepo updt TABLERECORD_IDFIELD_NAME=VALUE ...

Update an existing record. It returns nothing. If the specified record does not exist, it complains.

Example:

$ ./mdrepo updt webs WebFour admin=GardnerGroup master=am

mdrepo del TABLERECORD_ID

Deletes an existing record. It returns nothing. If the specified record does not exist, it complains.

Example:

$ ./mdrepo del webs WebFour admin=GardnerGroup master=am

mdrep load TABLEFILE

Loads records to the specified table from the specified file. The file content is in the same format as the list command's output.
Nonexistent records are created.
Existing records are updated.

Example:

$ ./mdrepo load /var/tmp/temp-webs

mdrepo rset TABLE

Makes the specified table empty. It returns nothing.

Example:

$ ./mdrepo rset sites

mdrepo script from browser

Restrictions

Compared with command line use, browser use of mdrepo script is restricted for risk mitigation.

Only the users having ALLOWROOTCHANGE permission can use it.

Only tables allowed to be modified from browser explicitly can be manipulated. See Configuration for detail.

Site metadata is only rarely updated hence update from browser is not highly convenient. Still, if it's modified in a wrong manner, the damage damage can be huge. As such, many people would think that site metadata is not suitable for browser update.

Only the following commands are available: add, updt, del

show and list commands are not needed because %MDREPO{...}% does those jobs.

load and rset are rather dangerous.

URL parameters

mdrepo script checks

if the _add parameter is true (a string other than "0" or "" (zero length string)

otherwise checks if the _updt parameter is true

otherwise checks if _del is true

The command is determined this way.

The table and the record ID are specified by the _table and _recid parameters.

Field values are specified by parameters of the =__FIELD_NAME format.

For example, submitting the following form has the same effect as the command line shown further below.

Output

By default, the script's output is in the text/plain MIME type.
If the command succeeds, it returns nothing.
When something goes wrong, an error message is returned.

If redirectto URL parameter is provided, the script returns HTTP redirect to the specified URL.
If the redirectto parameter contains %RESULT%, it's replaced by the message to be shown when redirectto is not specified.

Configuration

To turn on the metadata repository, you need to have the following three settings.

Specifies a path to a directory where the MdrepoStore class have files.

$TWiki::cfg{Mdrepo}{Tables}

Specifies the names of the tables used. A table name may be followed by a colon and options. "b" is currently the only option recognized, which means the table can be updated from browser.

By the following setting, each web required to have its metadata record.

$TWiki::cfg{Mdrepo}{WebRecordRequired} = 1;

For a large site having thousands of webs, this is handy for site management.
Specifically this brings the following behaviors.

A web not having a web metadata record regarded as nonexistent. Existence of a directory under $TWiki::cfg{DataDir} isn't enough.

A web creation by ManagingWebs is rejected if the corresponding web metadata is not present. Similarly, a web cannot be renamed to a web whose top level web doesn't have its web metadata record.

%WEBLIST{...}% gets faster referring to web metadata rather than traversing a directory hiearchy. For practicality, only top level webs are listed except with the current web -- the current web's ancestors and decendants are listed.

Audit trail

When the mdrepo script is used either from command line or browser, if the command is either add, updt, del, or rset, it's recorded on the log file in the same manner as other scripts. Specifically, the activity is put on the 5th column.