DBIx::Class and Koha

I did some work today with DBIx::Class and Koha, and got opac-account.pl partially using it.

You can see the schema here and I had to make a few changes to C4::Context, and a few to opac-account.pl.

Here is what they were.

diff --cc C4/Context.pm
index 7ba57fb,4dab9a9..cafc0ca
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@@ -18,6 -18,6 +18,8 @@@ package C4::Context
use strict;
use warnings;
++use Koha::Schema;
++
use vars qw($VERSION $AUTOLOAD $context @context_stack);
BEGIN {
@@@ -191,6 -191,6 +193,27 @@@ $context = undef;        # Initially, n
=cut
++sub schema {
++    my $self = shift;
++    my $db_driver;
++    if ($context->config("db_scheme")){
++        $db_driver=db_scheme2dbi($context->config("db_scheme"));
++    }
++    else {
++        $db_driver="mysql";
++    }
++
++    my $db_name   = $context->config("database");
++    my $db_host   = $context->config("hostname");
++    my $db_port   = $context->config("port") || '';
++    my $db_user   = $context->config("user");
++    my $db_passwd = $context->config("pass");
++    my $schema = Koha::Schema->connect( "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
++      $db_user, $db_passwd);
++    return $schema;
++}
++
++
sub KOHAVERSION {
my $cgidir = C4::Context->intranetdir;
diff --cc opac/opac-account.pl
index 43a1e0c,43a1e0c..376ae98
--- a/opac/opac-account.pl
+++ b/opac/opac-account.pl
@@@ -17,16 -17,16 +17,20 @@@
# wrriten 15/10/2002 by finlay@katipo.oc.nz
# script to display borrowers account details in the opac
++# Edited by chrisc@catalyst.net.nz
use strict;
use CGI;
use C4::Members;
++use C4::Context;
use C4::Circulation;
use C4::Auth;
use C4::Output;
use C4::Dates qw/format_date/;
++use DBIx::Class::ResultClass::HashRefInflator;
use warnings;
++
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
@@@ -40,9 -40,9 +44,16 @@@
);
# get borrower information ....
--my $borr = GetMemberDetails( $borrowernumber );
++# my $borr = GetMemberDetails( $borrowernumber );
++my $context = C4::Context->new;
++my $schema = $context->schema;
++my $rs = $schema->resultset('Borrowers')->search({ borrowernumber => $borrowernumber });
++$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
++my $borr = $rs->first;
++use Data::Dumper;
++warn Dumper $borr;
my @bordat;
--$bordat[0] = $borr;
++push @bordat,$borr;
$template->param( BORROWER_INFO => @bordat );

So not many changes at all, i’ll work on changing some more, but it looks like adding DBIx::Class can be done in a gradual way.

Unsung Koha Heroes – Part 14

Rob Weir

On the 13 of December 2002, Rob Weir posted the first link to his windows packages for Koha. This begun countless volunteer hours spent packaging and testing windows installs. Packages were created all the way up to version 2.2.9. There is a current perl module dependency that is uninstallable on windows, which is blocking the packages for 3.0.x. I’m sure as soon as that is fixed, Rob will be hard at work creating packages again.

Windows users around the world thank you Rob.

Unsung Koha Heroes – Part 13

Andrew Arensburger

Anyone who has ever looked at the Koha code will have noticed there is one module everything else uses, C4::Context. Back in September of 2002, this was not the case until Andrew wrote this neat module.

It has been poked at by a lot of people since then, but 269 lines of it are still the lines that Andrew wrote. It still retains the purpose it was written for to provide a single place to get things like config variables, system preferences and to implement database connection pooling.

With 163 commits to his name this was not all Andrew did, but it is probably the one that has had the longest lastest influence.

If you read this, stop by #koha on irc.katipo.co.nz and say hi sometime.

Koha in the Code4lib Journal

The article written by the wonderful Joann Ransom, with help from Rosalie Blake and I has been published in the latest edition of the code4lib journal.

In 2000 a small public library system in New Zealand developed and released Koha, the world’s first open source library management system. This is the story of how that came to pass and why, and of the lessons learnt in their first foray into developing in open source.

Have a read, and let us know what you think.

What’s in a name?

So we all have names. Some of us like ours, and some hate them. I’m somewhere in between. Laurel isn’t super unusual though I know it shocked my family when I was given it. Laurel and Hardy?… What’s her nickname going to be? Hippie parents? In school the kids could only come up with stupid rhymes comparatively. Floral. Rural. and Doral cigarettes. And big giggles when every year we were reminded that the state flower was the Mountain Laurel. I can’t help but think that the name still doesn’t suit me (too pretty for such a lifelong blunt slob of a tomboy), but it was well considered by my parents and I like that there was only one other Laurel at our school and that my middle name has a family connection. In NZ it is a bit more common I think – but with the octogenerians.

Kahurangi’s name was pretty much decided pretty early on – at least by me, and Chris wasn’t a hard sell. I loved all the various meanings, the shortened version, the sound of it, and wanted to give him an out by giving him middle names that had family meaning and English should he find the Maori to unusual or complicated to deal with (like I sometimes do when ordering and give the name “Laura” to save having to spell out/explain in loud venues). Currently he call himself Kah-foof or Ka-woo-nan-gee. But he does know his full name of Kahurangi James Lee Barr Cormack and tells it to people. Not too bad for a 2 year old. Maybe someday he’ll call himself Jim.

I’ve always loved that Chris’s name partiallly came from Christopher Robin from Winnie the Pooh, as somehow even the Shephard drawings from the books remind me of him.

So when looking at names for #2, we still weren’t sure he was going to be a boy officially. I was about 99% sure, so had erred on the side of boys names. Library trips for baby name books yielded little. Nothing seemed to sound right to me. There were a few factors in choosing one, and I was becoming increasingly stubborn which meant less and less options.
1. must like the name
2. must like sound of the name
3. must like meaning of the name
4. probably a maori name to go with Kahu’s
5. probably one that would be moderately easy to pronounce for even the American family
6. probably a shortened nickname easy to give when ordering coffees
7. no bad kiddie rhymes in Maori or in English (yes, we get Yahoo with Kahu… but if that’s the worst it gets, I’m cool with it)
8. Barr as a middle (not hyphenated) name to avoid dramas with immigration and not having the same name
9. Cormack as last name for consistency with brother

So after many hours of toiling dictionaries, websites, books, consulting people to make sure I wouldn’t offend anyone that left about 10 names and meanings, plus a list of family names for middles. In creating the list, I looked particularly at words relating to the moon. Kahu had a few very cute discussions with his in utero brother through my belly button. The baby told him “need more nappies” (which coincidently has proven true!) and that his name was “Moon Turtle” – which he then named his baby doll.

When I looked at the original due date for the baby, I saw that it was a full moon and my parent’s wedding anniversary. Maori have extensive star knowledge (which is how they navigated to NZ and engineered their planting schedules etc) and being a fan of astronomy myself, it just seemed right to look in this direction. Kahurangi’s name was ultimately chosen in my eyes for the connection it had to the skies that brought Chris and I together.

Atarau came as a potential – meaning moonlight. With further investigation, I found that many in older generations in both the US and here know the War song “Po Atarau” or “Now is the Hour”
http://folksong.org.nz/poatarau/index.html

Po atarau
e moea iho nei
e haere ana
koe ki paamamao

Haere ra
ka hoki mai ano
ki i te tau
e tangi atu nei

on a moonlit night
i see in a dream
you going away
to a distant land

farewell,
but return again
to your loved one
weeping here

It just seemed to connect all the research that both Chris and I have done on World Wars, honour those in our families that had served, and those who stayed home. And the lullaby like song in it’s various creations of lyrics remind me that even though my family is spread all over the world, that we all return back to one another.

Pronunciation especially for Americans is a bit tricky. Have a listen to the songs for help.
http://www.youtube.com/watch?v=uPYeJM89Twc
http://www.youtube.com/watch?v=Xzmg-_XPp0Q&feature=related&pos=6
http://www.youtube.com/watch?v=XgTRrrekaMo&feature=related&pos=7
http://www.youtube.com/watch?v=CXTjqxgjRBA

Otherwise an American close pronunciation is
Te           teh
Po          pole or pohl or pol (like in Poland) with soft “l”
Atarau    ah-tah roeh

Chris put up his earlier blog post based on cryptic notes I had made of family lineage. Subsequent corrections of family connections to middle names have been made.

So Te Po Atarau William Creed Barr Cormack, I hope that sometime you’ll ask me why we chose this name for you, and we can sit down and tell you about the long hours we spent making it just right for you. A special name for a special boy.

…and then you can call yourself Bill.