David Winters > Persistent-Base-0.52 > Persistent::Base

Download:
Persistent-Base-0.52.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.52   Source  

NAME ^

Persistent::Base - An Abstract Persistent Base Class

SYNOPSIS ^

  ### we are a subclass of ... ###
  use Persistent::Base;
  @ISA = qw(Persistent::Base);

ABSTRACT ^

This is an abstract class used by the Persistent framework of classes to implement persistence with various types of data stores. This class provides the methods and interface for implementing Persistent classes. Refer to the Persistent documentation for a very thorough introduction to using the Persistent framework of classes.

This class is part of the Persistent base package which is available from:

  http://www.bigsnow.org/persistent
  ftp://ftp.bigsnow.org/pub/persistent

DESCRIPTION ^

Before we get started describing the methods in detail, it should be noted that all error handling in this class is done with exceptions. So you should wrap an eval block around all of your code. Please see the Persistent documentation for more information on exception handling in Perl.

ABSTRACT METHODS THAT NEED TO BE OVERRIDDEN IN THE SUBCLASS ^

datastore -- Sets/Returns the Data Store Parameters

  eval {
    ### set the data store ###
    $person->datastore(@args);

    ### get the data store ###
    $href = $person->datastore();
  };
  croak "Exception caught: $@" if $@;

Returns (and optionally sets) the data store of the object. This method throws Perl execeptions so use it with an eval block.

Setting the data store can involve anything from initializing a connection to opening a file. Getting a data store usually means returning information pertaining to the data store in a useful form, such as a connection to a database or a location of a file.

This method requires implementing.

Parameters:

Varies by implementation.

Returns:

Varies by implementation.

insert -- Insert an Object into the Data Store

  eval {
    $person->insert();
  };
  croak "Exception caught: $@" if $@;

Inserts an object into the data store. This method throws Perl execeptions so use it with an eval block.

This method requires implementing.

Parameters:

None.

Returns:

None.

See the Persistent documentation for more information.

delete -- Delete an Object from the Data Store

  eval {
    $person->delete();
  };
  croak "Exception caught: $@" if $@;

Deletes an object from the data store. This method throws Perl execeptions so use it with an eval block.

This method requires implementing.

Parameters:

@id

Values of the Identity attributes of the object. This argument is optional and will default to the Identifier values of the object as the default.

Returns:

$flag

A true value if the object previously existed in the data store (it was deleted), and a false value if not (nothing to delete).

See the Persistent documentation for more information.

restore_where -- Conditionally Restoring Objects

  use Persistent::File;

  eval {
    my $person = new Persistent::File('people.txt', '|');
    $person->restore_where(
      "lastname = 'Flintstone' and telnum =~ /^[(]?650/",
      "lastname, firstname, telnum DESC"
    );
    while ($person->restore_next()) {
      print "Restored: ";  print_person($person);
    }
  };
  croak "Exception caught: $@" if $@;

Restores objects from the data store that meet the specified conditions. The objects are returned one at a time by using the restore_next method and in a sorted order if specified. This method throws Perl execeptions so use it with an eval block.

Since this is a Perl implemented Persistent class, the restore_where method expects all patterm matching to use Perl regular expressions.

This method requires implementing.

Parameters:

$where

Conditional expression for the requested objects. The format of this expression is similar to a SQL WHERE clause. This argument is optional.

$order_by

Sort expression for the requested objects. The format of this expression is similar to a SQL ORDER BY clause. This argument is optional.

Returns:

$num_of_objs

The number of objects that match the conditions.

See the Persistent documentation for more information.

SEE ALSO ^

Persistent, Persistent::Base, Persistent::DBM, Persistent::File, Persistent::Memory

BUGS ^

This software is definitely a work in progress. So if you find any bugs please email them to me with a subject of 'Persistent Bug' at:

  winters@bigsnow.org

And you know, include the regular stuff, OS, Perl version, snippet of code, etc.

AUTHORS ^

  David Winters <winters@bigsnow.org>

COPYRIGHT ^

Copyright (c) 1998-2000 David Winters. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: