[cgi-wiki-dev] making nodes first-class objects

Jonathan Swartz cgi-wiki-dev@earth.li
Tue, 9 Sep 2003 19:46:02 -0700

Hi all,

A few days ago I started a conversation with Kake about one unsatisfying
aspect of CGI::Wiki's API: that the object-orientedness is not extended to
nodes and other concepts in the system. Returning nodes as hashes exposes
the internal elements of your implementation, makes it harder for folks to
extend nodes via subclasses, and just feels wrong in today's object-oriented

I'd love to see CGI::Wiki::Node as a first class object. Then,

* content(), last_modified(), metadata(), etc. are accessor/mutator methods
on CGI::Wiki::Node (zero arguments gets the value, one argument sets the
* verify_checksum() and delete() are methods on CGI::Wiki::Node
* retrieve_node() returns an CGI::Wiki::Node object (or undef if it doesn't
exist - it is bad form to assume an empty node, IMO)
* list_backlinks(), list_dangling_links(), etc. return a list of
CGI::Wiki::Node objects

There are some nice utility classes that can help construct the
CGI::Wiki::Node class, like Class::Accessor and Class::DBI.

Obviously for backwards compatibility we'd want to keep both APIs around for
a while. Kake suggested that we use an api_version parameter in the

  my $wiki = CGI::Wiki->new(
                             api_version => 2,   # 1 is hash-based, 2 is

What do people think?