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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm' What am I doing wrong? -- Puneet Kishor
On Tue, Aug 24, 2010 at 9:14 AM, P Kishor <punk.kish@gmail.com> 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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
What am I doing wrong?
This is because of the auto-capitalization Dancer does to decide what the name of the session engine is called. In order to provide users the ability to simply write in lowercase in the config files, we auto-capitalize ourselves. SQLite cannot be covered by auto-capitalization. However, if you call your module Dancer::Session::Sqlite, it will work.
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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
When Dancer parses your config file, it uses Dancer::ModuleLoader to load the session engine you chose. Hence it does internally a `use Dancer::Session::SQLite'. 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: YourApp/ ... lib/ YourApp.pm YourApp/ Dancer/ Session/ SQLite.pm 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. 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. -- Alexis
On Tue, Aug 24, 2010 at 9:33 AM, Alexis Sukrieh <sukria@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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
Whoops, missed the set command!
Thanks Alexis, for your advice. However... On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria@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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
When Dancer parses your config file, it uses Dancer::ModuleLoader to load the session engine you chose. Hence it does internally a `use Dancer::Session::SQLite'.
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:
YourApp/ ... lib/ YourApp.pm YourApp/ Dancer/ Session/ SQLite.pm
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 package Dancer::Session::SQLite; use DBI; my $dbh = setting('dbh'); init() create() session_db() destroy() flush() 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.
-- Alexis _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- 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 =======================================================================
Hello, can you try Dancer-Plugin-Database?? http://search.cpan.org/~bigpresh/Dancer-Plugin-Database-0.06/lib/Dancer/Plug... It's very simple method to connect DBI and use in Dancer.
------------ Původní zpráva ------------ Od: P Kishor <punk.kish@gmail.com> Předmět: Re: [Dancer-users] Dancer::Session::SQLite Datum: 24.8.2010 17:52:17 ---------------------------------------- Thanks Alexis, for your advice. However...
On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria@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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
When Dancer parses your config file, it uses Dancer::ModuleLoader to load the session engine you chose. Hence it does internally a `use Dancer::Session::SQLite'.
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:
YourApp/ ... lib/ YourApp.pm YourApp/ Dancer/ Session/ SQLite.pm
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
package Dancer::Session::SQLite; use DBI; my $dbh = setting('dbh');
init() create() session_db() destroy() flush()
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.
-- Alexis _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- 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 ======================================================================= _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
2010/8/24 <igor.bujna@post.cz>:
Hello, can you try Dancer-Plugin-Database?? http://search.cpan.org/~bigpresh/Dancer-Plugin-Database-0.06/lib/Dancer/Plug... It's very simple method to connect DBI and use in Dancer.
Quoting from my earlier email --- 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.
------------ Původní zpráva ------------ Od: P Kishor <punk.kish@gmail.com> Předmět: Re: [Dancer-users] Dancer::Session::SQLite Datum: 24.8.2010 17:52:17 ---------------------------------------- Thanks Alexis, for your advice. However...
On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria@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 /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Engine.pm'
When Dancer parses your config file, it uses Dancer::ModuleLoader to load the session engine you chose. Hence it does internally a `use Dancer::Session::SQLite'.
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:
YourApp/ ... lib/ YourApp.pm YourApp/ Dancer/ Session/ SQLite.pm
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
package Dancer::Session::SQLite; use DBI; my $dbh = setting('dbh');
init() create() session_db() destroy() flush()
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.
-- Alexis
-- 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 =======================================================================
On Tuesday 24 August 2010 16:52:10 P Kishor wrote:
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);
With current Dancer versions, keywords defined by a plugin are exported only to the Dancer app which loaded the plugin, not to other plugins (or other scripts loaded by the app). This is an annoying bug, and one which I hope to fix soon, if it hasn't been sorted already (I've been on holiday for two weeks, so don't yet know what's changed while I was away).
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.
Actually, it doesn't change anything about DBI other than taking away the work of connecting to the database. Calling the database() keyword simply returns a connected, ready to use DBI connection handle. It may have been freshly connected, or it may be re-using the existing connection, but either way, you'll get a DBI connection handle to use as normal, so you might write something like: my $sth = database()->prepare('select * from table....'); $sth->execute(); .... This is all documented in the documentation for D::P::Database. I'm considering adding a few utility methods to D::P::Database to simplify some operations, but it will never prevent you from doing things in the usual DBI way, other than the initial connection to the database, which is what the plugin is designed to simplify.
2. This is more of a show-stopper. I am getting a lock on my database everytime a new session is inserted.
That's to be expected with SQLite; the entire database is contained in a single file, which is locked when you connect to it.
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 [...]
In order to avoid it being locked, you'd probably need to disconnect in flush() after storing the session data, and probably in retrieve() right after fetching the session data too. This could result in many repeated connection & disconnections, but may be the only way to reliably use SQLite without incurring locking problems. Cheers Dave P -- David Precious <davidp@preshweb.co.uk> http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
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.
May I suggest to create Dancer::Session::DBI instead. So it's possible to use SQLite while in development, and Postgresql for production. I'm not sure SQLite for production would be good, since it's a single file with a lock system.
On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria@sukria.net> wrote:
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.
Wheeeeee! I created my first Perl module... it bodes well for Dancer that my first module was something that enables happy dancing! I have never done this... so, please let awkwardly ask... Now, how on earth do I release this? -- 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 =======================================================================
On Tue, Aug 24, 2010 at 11:52 AM, P Kishor <punk.kish@gmail.com> wrote:
On Tue, Aug 24, 2010 at 1:33 AM, Alexis Sukrieh <sukria@sukria.net> wrote:
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.
Wheeeeee! I created my first Perl module... it bodes well for Dancer that my first module was something that enables happy dancing!
I have never done this... so, please let awkwardly ask... Now, how on earth do I release this?
So, the PAUSE server is broken. I get a 500 error everytime I try to register myself. I have sent an email to the admin, but in the meantime, I have http://github.com/punkish/Dancer--Session--SQLite woohoo! Please let me know how to make this better. -- 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 =======================================================================
participants (6)
-
Alexis Sukrieh -
David Precious -
franck -
igor.bujna@post.cz -
P Kishor -
sawyer x