Reference

Zim::Repository::Base(3pm)

Zim::Repository::Base - Repository base class This is a base class for modules implementing handlers for Zim::Repository. It documents the interface expected to handle page objects. It provides a number of stub methods and some logic that is common to most repository handlers. When implementing a new handler start with "get_page()". Note that when a page name is given it is always given fully-specified, so you need to take into account your own namespace prefix. All methods except for "get_page()" and "resolve_page" take page objects as arguments. Therefor when you have to do an expensive lookup to locate the contents of a page, like a recursive case-insensitive filename lookup, this lookup should be done only once and then the result is stored in the page object. The page object can be considered a pointer for the contents. It is good practice to throw an exception when a method fails. This way the GUI knows that something went wrong and can alert the user. Simple object constructor. PARENT can be a parent repository object or undef. NAMESPACE is the prefix for all pages managed by this repository. Extra arguments are passed on to "init()". Simple init function, to be overloaded.

The default expects a hash with attributes which are stored in the object hash. This method should return boolean if NAMESPACE exists. This method should return a list of pages in NAMESPACE. The list is used by the gui to produce a hierarchical index, it does not tell anything about the actual existence of the pages.

The default returns an empty list. This method is expected to return a page object for NAME. Page objects should inherit from Zim::Page. See Zim::Page::Text for an example.

When a page does not exist an empty object should be returned that can be used to create this page by saving to it. The status of this object should be set to 'new'. When a page does not exists and can not be created undef should be returned.

The default does nothing. This method is a frontend for "get_page()" that is used when NAME is user input. This means that it should probably do a case-insensitive lookup and should expect things like typing errors, characters that are not allowed etc.

This stub just calls "get_page()". Copy contents of object SOURCE to object TARGET. Both page objects should belong to this repository.

Make sure to update the page objects correctly. For example set status and update or flush the parse tree. Move the content of object SOURCE to object TARGET. Both page objects should belong to this repository.

Make sure to update the page objects correctly. For example set status and update or flush the parse tree.

The default just calls "copy_page()" and "delete_page()". Delete object PAGE and returns the page object. Be aware that although the content is deleted the PAGE object goes on living and should be updated accordingly. The status of the object should be set to 'deleted'.

The default method fails silently. Returns a page name for a link. The link might be relative to the page. This method calls "root->resolve_page()" automaticly.

The logic implemented here is a sensible default which does an "intelligent" upward lookup.
Utility methods These methods are commonly used methods in repository objects. They do not need to be overloaded. Returns the top parent repository object. This is used to get pages when we are not sure these pages belong to our repository. Removes double items from the array refered to by ref. Please mail the author if you find any bugs. Jaap Karssenberg || Pardus [Larus] <[email protected]> Copyright (c) 2006 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Zim, Zim::Repository