From: Tara L Andrews Date: Tue, 28 Feb 2012 22:07:33 +0000 (+0100) Subject: try to fix encoding issues in Directory name trawl X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a90079324146b05a46fadc49999d423e7d93db3;p=scpubgit%2Fstemmatology.git try to fix encoding issues in Directory name trawl --- diff --git a/lib/Text/Tradition/Collation/RelationshipStore.pm b/lib/Text/Tradition/Collation/RelationshipStore.pm index 47d384e..2f8784c 100644 --- a/lib/Text/Tradition/Collation/RelationshipStore.pm +++ b/lib/Text/Tradition/Collation/RelationshipStore.pm @@ -271,7 +271,6 @@ sub add_relationship { my $rel = $self->get_relationship( @$v ); if( $rel && $rel ne $relationship ) { if( $rel->nonlocal ) { - $DB::single = 1; throw( "Found conflicting relationship at @$v" ); } else { warn "Not overriding local relationship set at @$v"; diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index 8783b96..2fa8fc5 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Moose; use DBI; +use Encode qw/ decode_utf8 /; use KiokuDB::GC::Naive; use KiokuDB::TypeMap; use KiokuDB::TypeMap::Entry::Naive; @@ -231,18 +232,20 @@ sub traditionlist { # If we are using DBI, we can do it the easy way; if not, the hard way. # Easy way still involves making a separate DBI connection. Ew. my @tlist; - if( $self->dsn =~ /^dbi/ ) { - $DB::single = 1; + if( $self->dsn =~ /^dbi:(\w+):/ ) { + my $dbtype = $1; my @connection = @{$self->directory->backend->connect_info}; # Get rid of KiokuDB-specific arg pop @connection if scalar @connection > 4; - $connection[3]->{'sqlite_unicode'} = 1 if $connection[0] =~ /^dbi:SQLite/; - $connection[3]->{'mysql_enable_utf8'} = 1 if $connection[0] =~ /^dbi:mysql/; - $connection[3]->{'pg_enable_utf8'} = 1 if $connection[0] =~ /^dbi:Pg/; + $connection[3]->{'sqlite_unicode'} = 1 if $dbtype eq 'SQLite'; + $connection[3]->{'pg_enable_utf8'} = 1 if $dbtype eq 'Pg'; my $dbh = DBI->connect( @connection ); my $q = $dbh->prepare( 'SELECT id, name from entries WHERE class = "Text::Tradition"' ); $q->execute(); while( my @row = $q->fetchrow_array ) { + my( $id, $name ) = @row; + # Horrible horrible hack + $name = decode_utf8( $name ) if $dbtype eq 'mysql'; push( @tlist, { 'id' => $row[0], 'name' => $row[1] } ); } } else { diff --git a/stemmaweb/lib/stemmaweb/Controller/Root.pm b/stemmaweb/lib/stemmaweb/Controller/Root.pm index c33b9f0..6610705 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Root.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Root.pm @@ -69,7 +69,7 @@ sub variantgraph :Local :Args(1) { my $collation = $tradition->collation; my $needsave = !$collation->has_cached_svg; $c->stash->{'result'} = $collation->as_svg; - $m->save( $tradition ); + $m->save( $tradition ); # to save generate SVG in the cache $c->forward('View::SVG'); } @@ -96,7 +96,6 @@ sub alignment :Local :Args(1) { @{$alignment->{'alignment'}}; push( @$rows, { 'rank' => $i+1, 'readings' => \@rankrdgs } ); } - $c->log->debug( Dumper( $rows ) ); $c->stash->{'witnesses'} = $wits; $c->stash->{'table'} = $rows; $c->stash->{'template'} = 'alignment.tt';