PreshBlog

Dancer web framework

Dancer::Plugin::SimpleCRUD 0.03 and Dancer::Plugin::Database 1.24

by on May.09, 2011, under Dancer web framework, Perl

A busy evening’s hacking on Dancer plugins tonight. I’ve released Dancer::Plugin::SimpleCRUD 0.03, which incorporates a new search feature kindly contributed by Alberto Simões which I’ve been meaning to release for a while, along with removing the dependency on SQL::Abstract in favour of the convenience methods provided by Dancer::Plugin::Database, which will make D::P::SimpleCRUD work correctly with PostgreSQL databases too – thanks to Jonathan Barber for reporting this issue in RT #68040.

(I should point out that the problem was not with SQL::Abstract, but with D::P::SimpleCRUD setting the quote_char param to a backtick, which is good for MySQL and SQLite, but not so much for PostgreSQL. The code in D::P::Database uses the quote() / quote_identifer() methods provided by DBI, so should Do The Right Thing for any DBI-supported database engine.)

Also released is version 1.24 of Dancer::Plugin::Database, fixing a bug with the log_queries setting reported today on IRC by Martin P Evans (mpe) – thanks Martin!

As soon as time permits, I intend to add more features and refinement to Dancer::Plugin::SimpleCRUD to make it even more useful. Any contributions would be very welcome indeed – you can fork the Dancer::Plugin::SimpleCRUD repository on GitHub and submit pull requests, or contact me with patches.

(You can also find Dancer::Plugin::Database on GitHub, and if you’re interested in my other projects or “following” me, see my GitHub profile.)

Leave a Comment more...

Dancing in the cloud – deploying Dancer apps to dotcloud

by on Apr.30, 2011, under Dancer web framework

Marco Fontani wrote up an excellent blog post on deploying Dancer apps to DotCloud’s beta.

DotCloud is a PaaS (platform as a service) hosting platform currently in beta, running on Amazon EC2. It promises dead-easy deployment of Perl web applications. (DotCloud announced Perl support as CaaS (Camel as a Service) recently.)

Marco’s write-up shows that it is indeed simple; push your Dancer app to DotCloud, and it figures out the dependencies, installs them, and starts it up. As the little meerkat would say, “simples!”.

Leave a Comment more...

Dancer::Plugin::Database 1.20 released

by on Feb.24, 2011, under Dancer web framework, Perl

I released version 1.20 of Dancer::Plugin::Database to CPAN last night.

Changes include a couple of minor bug fixes, including fixing test failures on Windows systems, and automatically enabling UTF-8 support if the app’s charset setting is UTF-8, so that UTF-8 data in your database should Just Work.

Leave a Comment more...

Dancer::Plugin::Database 1.00 released

by on Jan.14, 2011, under Dancer web framework, Perl, Programming

I’ve just released Dancer::Plugin::Database 1.00 to CPAN. This includes Alan Haggai’s patch to supply runtime configuration info to the database keyword as a hashref (thanks, Alan!) which was already released as a developer release, 0.91_01.

I’ve bumped the version to 1.00 to indicate that I consider it stable and ready for use in production, for those users who mistrust any module with a 0.xx version number.

Leave a Comment more...

Dancer::Plugin::MPD released

by on Nov.10, 2010, under Dancer web framework, Perl, Programming

I recently wrote Dancer::Plugin::MPD, a simple plugin to make it easy to talk to MPD (Music Player Daemon) from Dancer-powered webapps in Perl.

It uses Jerome Quelin’s excellent Audio::MPD – it simply provides an mpd keyword which returns a connected Audio::MPD object (connecting first, if we didn’t have a connection or it went away, otherwise keeping the connected object cached).

It makes for code as simple as this example from DancerJukebox:

get '/control/skip' => sub { mpd->next; redirect '/'; };
Leave a Comment more...

Dancer::Plugin::DebugDump released

by on Nov.09, 2010, under Dancer web framework, Perl, Programming

I recently released a dead-simple plugin for Dancer – Dancer::Plugin::DebugDump.

During development, I fairly often find myself using Data::Dump to dump stuff to the debug log (which I usually have set to ‘console’, so it appears in the terminal I’m running the app from), with code like:

use Data::Dump qw(dump);
debug("Random hashref: " . dump($hashref) );

I got fed up with writing that, so I wrote Dancer::Plugin::DebugDump, which lets you say:

# give it a label and a reference/object:
debug_dump("Random hashref:" => $hashref);
# or just give it a reference/object:
debug_dump($someobject);

It’s not much of a saving, but it scratched an itch, and might possibly be useful to others.

Leave a Comment more...

DancerJukebox – music queuing Perl webapp powered by Dancer

by on Nov.08, 2010, under Dancer web framework, Perl, Programming

I spent some of Friday night hacking on rewriting my music queuing webapp from Catalyst (which I wrote it in ages ago, before I discovered Dancer).

It only took a couple of hours of easy and actually fairly enjoyable coding to get it all ported over, and in the process I released two Dancer plugins – Dancer::Plugin::MPD to handle easily getting a working MPD connection, and Dancer::Plugin::DebugDump to easily dump objects and data structures to the debug log to simplify development.

This time round, the code is up on GitHub – DancerJukebox on GitHub. I never released the previous code, it was developed in a private Subversion repository, and I was never happy enough with it to release it.

The basic idea is that you fill the playlist with decent music and leave MPD playing on random. If people want to hear specific songs, they can use the web app to search for whatever they want and add them to a queue.

(continue reading…)

Leave a Comment : more...

Dancer::Plugin::Database – easy DB connections for Dancer apps

by on Apr.15, 2010, under Dancer web framework, Perl

Last night I finished and released the first version of Dancer::Plugin::Database, a plugin for the Dancer web framework to provide easy database connections using the venerable DBI.

It takes the database connection details from the app config file, and provides a database keyword which will return you a connected database handle (taking care of ensuring that the DB connection is still alive, etc).

So, usage can be as simple as:

my $books = database->selectall_arrayref(
    'select * from books where author = ?', 
    { Slice => {}}, $author
);

(Calling database() simply returns a DBI database handle, so you can obviously do anything you can do with DBI).

Also, at the moment, if a database connection could not be established for any reason, database() will just return undef, so you will need to handle errors appropriately. After considering whether it’s wise, I may tweak it to die, so that Dancer will handle the failure with a pretty 500 error for you (in which case, I’ll make it possible to disable that via the config).

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!