View on
Brent Royal-Gordon > WWW-Kontent > WWW::Kontent::Path


Annotate this POD

View/Report Bugs


WWW::Kontent::Path - Classes for navigating Kontent stores


        my $path =;
        $path.resolve(:in($root), :request($r));
        say $path.components[0].name;                   # foo
        say $path.components[1].revno;                  # 42
        say ref $path.components[3].revision;   # WWW::Kontent::Store::NarrowDBI::SavedRev
        say $path.format;                                               # pdf


WWW::Kontent::Path is a class representing a path to a Kontent page. Besides the Path object itself, it also defines WWW::Kontent::Component, a single part of a path.

Paths in Kontent

A path is the portion of the URL which Kontent examines to determine which page it should operate on, which mode that page should be processed in, and which format it should be rendered in. Expressed as a Perl 6 grammar, it might look something like this:

        grammar Grammar::Kontent::Path {
                rule name   {      \w+     }
                rule revno  { \[   \d+  \] }
                rule format { \. <name>    }
                rule mode   { \{ <name> \} }
                rule component { <name> <revno>? }
                rule path {
                 /? [ <revno> | <component> ]
                    [ / <component> ]*
                     <format>?  <mode>?

In somewhat simpler terms, all of these are valid:


As well as most similar combinations.


Component objects contain two accessors, name and revno, representing the name and revision number of that particular part of the path. name is undefined in the first component, representing the root node; if revno is undefined it means that the current revision should be used.

After resolve has been called on the WWW::Kontent::Path object it belongs to, two additional fields become available. page and revision contain the page and revision, respectively, associated with the component.

A component can be stringified, yielding a string something like bar[42], but intelligent enough to omit missing parts of the component.

Component objects should never be allocated by user code; only WWW::Kontent::Path should create them.


Represents a full path (set of components). Once a Path object has been allocated, a string path must be given to the parse method; later, a call to resolve (with the root node and request passed in) will find the pages and revisions associated with those path components.

The components accessor, filled in by parse, contains an array of Component objects. The mode accessor contains the mode, while the format accessor contains the format. The page and revision accessors retrieve the page and revision, respectively, of the last component, and are only useful after resolve has been called.



syntax highlighting: