Shouldn't you be using the database itself to store the
state? Will Apache::Singleton instance replicate itself if
you were to run your application on multiple servers behind
load balancers (for scalability and fail-over purposes)?
If yes, you probably should usw Storage Module to save your
SQL object and retrieve in each request. That would be
'true' singleton, in my opinion.
--- "Tesfaiesus, Mesel" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to write an application, that allows the user
> to generate
> complex SQL Queries step by step.
> Therefore I need to make the same SQL-object available
> over many
> requests.
>
> I'm using the Aapache::Singleton Module and mod_perl
> 2.x/Apache2.x but I
> always seem to get a new Object as the properties are set
> to default
> every time.
>
>
> My Testcode is printing out a $counter - which it saved
> as an attribute
> of the object - that's supposed to increment with every
> request:
>
> ############### MyClass Module ###################
>
> package MyClass;
>
> use base qw (Apache::Singleton);
>
> {
> Sub _new_instance {
> my $class = shift;
>
> my $self = {};
> bless $self, $class;
>
> $self->setProperty( 'counter', 1);
>
> }
> }
>
> #####################################################
>
>
>
>
> ################ Script: index.pl ################
>
> Use MyClass;
>
> my $instance = MyClass->instance();
>
> my $counter = 0;
>
> $counter = $instance->getProperty('counter');
>
> print $counter;
>
> $counter++;
>
> $instance->setProperty('counter', $counter);
>
> ######################################################
>
>
>
> The result is always 1. it doesn't increment. What am I
> doing wrong?
>
> Any comment is appreciated.
>
> Cheers,
> mesel
>
- Praveen
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com