Re: [Cgi-session-user] help needed with writing singleton class
Brought to you by:
sherzodr
From: Mark S. <ma...@su...> - 2006-07-21 13:22:47
|
Sergey Brutsky wrote: > Hi, mark. I can't write Test::More test. Why not? The module is free, easy to use and well documented. Here's a first test to get you started: use Test::More 'no_plan'; my $session; { ok((not defined $session), "session starts out undefined"); } > The problem is: > If I use this construction --> my $session = CGI::Session->new( undef, > undef, { Directory => "/tmp/sessions" } ); > it works fine. > > But if I use this --> my $session = SessionSingleton->getInstance(); > it doesn't work. It doesn't create session and doesn't store it. > > Why ? I can't say for sure, but it's not clear that's a bug in CGI::Session, either. Why not study the working singleton example code in the module I mentioned below? Clearly it's possible to write one. Mark >> >> >> Sergey, >> >> The subject says that the module is not working correctly, but I'm not >> sure exactly which bug you reporting. Could just share a failing >> Test::More-style test case that clearly illustrates the issue? >> >> As for your singleton package, you may which to model it after >> CGI::Application::Plugin::Session, which does this successfully: >> >> http://search.cpan.org/src/CEESHEK/CGI-Application-Plugin-Session-1.02/lib/CGI/Application/Plugin/Session.pm |