View on
MetaCPAN
Barry King > Apache-Wyrd > Apache::Wyrd::Site::WidgetIndex

Download:
Apache-Wyrd-0.98.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.98   Source  

NAME ^

Apache::Wyrd::Site::WidgetIndex - Wrapper class to support Widget Class

SYNOPSIS ^

Typical BASENAME::WidgetIndex Implementation:

  package BASENAME::WidgetIndex;
  use strict;
  use base qw(Apache::Wyrd::Site::WidgetIndex);
  
  1;

Typical BASENAME::Widget Implementation:

  package BASENAME::Widget;
  use base qw(Apache::Wyrd::Site::Widget);
  use BASENAME::WidgetIndex;
  
  sub index {
    my ($self) = @_;
    return BASENAME::WidgetIndex->new;
  }
  
  1;

DESCRIPTION ^

Provides a simple interface to a MySQL table for storing data about widgets.

BUGS/CAVEATS ^

Not the most efficient way to store Widget information, but quick to implement. No BDB backend has been offered for this class, but a Widget's index can be implemented for a non-mysql environment using an instance of the Apache::Wyrd::Services::Index class with the following code:

  package BASENAME::WidgetIndex;
  use base qw(Apache::Wyrd::Services::Index);
  
  sub new {
    my ($class) = @_;
    my $init = {
      file => '/var/www/BASENAME/db/widgetindex.db',
      strict => 1
    };
    return Apache::Wyrd::Services::Index::new($class, $init);
  }
  
  sub update_entry {
    my ($self, $entry) = @_;
    my $changed = 0;
    my $index = $self->read_db;
    my ($id, $id_is_new) = $self->get_id($entry->index_name);
    $index->db_get("\x02\%$id", my $digest);
    if ($digest ne $entry->index_digest) {
      $index = $self->write_db;
      $self->update_key($id, $entry->index_name);
      $self->update_key("\x00%" . $entry->index_name, $id);
      $self->update_key("\x02%" . $id, $entry->index_digest);
      $changed = 1;
    }
    $self->close_db;
    return $changed;
  }

1;

AUTHOR ^

Barry King <wyrd@nospam.wyrdwright.com>

SEE ALSO ^

Apache::Wyrd

General-purpose HTML-embeddable perl object

Apache::Wyrd::Site::Widget

Base object for Widgets - semi-independent objects which enrich the content of a page

LICENSE ^

Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.

See LICENSE under the documentation for Apache::Wyrd.

syntax highlighting: