OpenInteract::SampleStash - Default stash class and an example of what one looks like


 # Define your stash class in the base.conf file
 StashClass    MyApp::Stash


Note: This class template is used when generating a new website via 'oi_manage' and is not meant to be used directly.

The existence of the 'stash class' is necessitated by the fact that we can have more than one application running at the same time. Certain aspects of that application -- such as the cache, configuration, database handle, template object and more -- must be kept absolutely separate.

To do this, we keep them in separate classes. When the OpenInteract::Request object is initialized, it sets the 'stash_class' key of the request object to the package name of the stash class, and all requests for config objects, database handles and the like are handed off to it.

The stash itself is incredibly simple. We could even keep the methods in a superclass and inherit them; however, we are currently keeping the stashed information in a lexical hash, and to access it from a separate class we would need to write an accessor method, and by the time that happens what is the point?

Note that a stash class should be automatically created for you when you run the scripts packaged with OpenInteract to create a new application.


get_stash( $key )

Retrieve a value from the stash matching up to $key. Note that this is case-insensitive, so the following are equivalent:

 $class->get_stash( 'DB' );
 $class->get_stash( 'db' );
 $class->get_stash( 'Db' );

set_stash( $key, $item )

Save a value into the stash. Replaces any value previously left there.


Cleans up any information in the stash that is not persistent from request to request. To ensure that your information sticks around, put the key into the lexical %KEEP hash with a true value.




Copyright (c) 2001-2002, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Chris Winters <>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 92:

=back without =over