Brent Royal-Gordon > WWW-Kontent > WWW::Kontent::Store

Download:
WWW-Kontent-0.02.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

WWW::Kontent::Store - Base classes for Kontent stores

SYNOPSIS ^

        class MySavedPage is WWW::Kontent::SavedPage { ... }
        class MyDraftPage is WWW::Kontent::DraftPage { ... }
        class MySavedRev is WWW::Kontent::SavedRevision { ... }
        class MyDraftRev is WWW::Kontent::DraftRevision { ... }
        
        say "$page.path() ('$page.cur.attributes<kontent:title>') has {+$page.revisions} revisions.";

DESCRIPTION ^

WWW::Kontent::Store contains the classes defining Kontent pages and revisions. The classes in this module are abstract, and are usually inherited from by store modules.

WWW::Kontent::Page

This is a base class for a Kontent page. A store will not usually derive directly from this class; rather, it will derive its child classes, SavedPage and DraftPage.

Methods

name

Returns the name of the page. In DraftPages, this should be writable. Store authors must override this method to give it a body.

parent

Returns the page's parent page. Note that this must be the parent as seen by Kontent, which may be different from the parent reflected in the store if a special page class is bridging between two stores. Hence, it's probably best to have parent pages pass themselves into the constructors of their children. Store authors must override this method to give it a body.

path

Returns the path from the root page to this page. This method has a default implementation using name and parent, but store authors may want to override it for efficiency.

WWW::Kontent::SavedPage

SavedPage represents a page retrieved from whatever backing store the store module interfaces with. SavedPages are basically immutable.

Methods

revisions

Returns an array of SavedRevision objects representing the page's revisions.

cur

Returns a SavedRevision object representing the page's current revision. This method defaults to simply calling revisions and extracting the last element, but store authors may want to override it with a more efficient implementation.

children

Returns an array containing the names of the page's children.

XXX should probably be one of the default_ methods

default_resolve

Finds the child page of the given name and returns it. Page classes will typically use this method to resolve a page, but may override it to implement a bridge.

default_create

Creates a child page of the given name and returns a draft of its first revision. Page classes will typically use this method to resolve a page, but may override it to implement a bridge or simply set a default page class.

pool($module)

Returns a pool in the current store with the module name $module.

WWW::Kontent::DraftPage

DraftPages represent a page which has been created in the Kontent store, but has not yet been committed. Each DraftPage has a single DraftRevision; committing the DraftRevision should also save the DraftPage. The name field in a DraftPage should be mutable.

Methods

draft_revision

Returns the draft revision associated with this draft page.

WWW::Kontent::Revision

This is a base class for a Kontent page. A store will not usually derive directly from this class; rather, it will derive its child classes, SavedPage and DraftPage.

Methods

page

Returns the page this revision belongs to.

attributes

Returns a hash containing all attributes of this revision.

revno

Returns the revision number of this revision; this number is 1-based, increasing by 1 in each revision.

driver

Calls the page class's driver method.

A class's driver should implement any complex behavior the page class requires, such as database updates, querying for information, or complex calculations. A WWW::Kontent::Request object must be passed in to this method.

adapter

Calls the page class's adapter method.

The adapter is called by the renderer when it wants to retrieve the page's content; it should return a WWW::Kontent::Skeleton object containing content appropriate for the current mode. A WWW::Kontent::Request object must be passed in to this method.

modelist

Calls the page class's modelist method. The modelist method should return an array containing all the modes supported by the class.

WWW::Kontent::SavedRevision

Represents a revision retrieved from the database. Store authors should write a class which inherits from this. Its attributes should be assumed to be immutable.

Methods

revise

Returns a Draft object with the same attributes as this revision, except with the rev: attributes omitted. The draft should have the revision number passed into this method.

resolve

Calls the page class's resolve method, which by default calls the page's default_resolve method. This method takes a page name and returns the child page with that name.

create

Calls the page class's create method, which by default calls the page's default_create method. This method takes a page name and returns a DraftPage object for it. The DraftPage's revision must be committed before it will appear in the backing store.

pool($module)

Returns a pool in the current store with the module name $module.

WWW::Kontent::DraftRevision

This class represents an uncommitted draft revision. Store authors should inherit from this class.

Methods

commit

Writes the draft revision (and the page, if it is also a draft) into the backing store.

WWW::Kontent::Pool

This class represents a pool of unversioned data tied to a particular store. Store authors should inherit from this class.

SEE ALSO ^

WWW::Kontent

syntax highlighting: