punk.kish at gmail.com
Tue Aug 24 17:52:10 CEST 2010
Thanks Alexis, for your advice. However...
On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria at sukria.net> wrote:
> On 24/08/2010 08:14, P Kishor wrote:
>> Using Dancer::Session::YAML and Dancer::Session::Storable as
>> templates, I created a Dancer::Session::SQLite module. I put it in
>> /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Session/SQLite.pm and set
>> session => 'SQLite'. Yet, I get an error saying 'Error while loading
>> /Users/punkish/Sites/lca/app.psgi: unknown session engine 'SQLite',
>> perhaps you need to install Dancer::Session::SQLite? at
> When Dancer parses your config file, it uses Dancer::ModuleLoader to load
> the session engine you chose. Hence it does internally a `use
> The error message you report tends to show that Dancer::Session::SQLite is
> not in @INC (or the use fails for another reason).
> First, I'd suggest to do the following to test your module without
> installing it:
> Then try to do the following:
> $ perl -Ilib -MDancer::Session::SQLite -e 'print 1, "\n"'
> Maybe you'll see here the source of the error.
So, I debugged my module, and got the session working. Dancer creates
a session properly, and retrieves session values properly. There are
two issues that are blocking me from converting this into a
distributable module. Perhaps someone can help me with them --
1. Getting db settings. Initially, I thought I could use
Dancer::Plugin::Database, so the same method could be used in the main
Dancer application as well as in my session plugin. However, I have
the following problems with D::P::Database -- (1) it doesn't really
work in D::Session::SQLite. I get the error that database method is
not declared (or something like that); and (2) it changes the regular,
more familiar DBI methods. In fact, I am not even sure how I would do
more DBI-ish things with it, such as transactions, etc. So, this is a
different issue, but for now, I am tabling Dancer::Plugin::Database.
2. This is more of a show-stopper. I am getting a lock on my database
everytime a new session is inserted. Essentially, since I am running
my application via Plack::Handler::Apache2, the entire application is
being loaded in the web server's memory. It is creating a lock on the
db, and not letting go. If I restart the web server, the lock is
released, only to be created again when the session is updated.
So, I am trying to figure out where to disconnect the db manually, but
I don't really understand the sequence of actions that Dancer::Session
takes. I have the following methods in my module
my $dbh = setting('dbh');
How and where should I call the $dbh->disconnect method?
> When you're happy with it, I suggest you create a real CPAN distribution
> (with Module::Starter). I'm sure other Dancer users could find
> Dancer::Session::SQLite interesting.
> Good luck.
> Dancer-users mailing list
> Dancer-users at perldancer.org
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
Assertions are politics; backing up assertions with evidence is science
More information about the Dancer-users