rev 1934 - in trunk/buscador: bin lib

[prev] [thread] [next] [lurker] [Date index for 2005/02/22]

From: richardc
Subject: rev 1934 - in trunk/buscador: bin lib
Date: 00:10 on 22 Feb 2005
Author: richardc
Date: 2005-02-22 00:10:35 +0000 (Tue, 22 Feb 2005)
New Revision: 1934

Modified:
   trunk/buscador/bin/buscador
   trunk/buscador/lib/Buscador.pm
Log:
only specify the database in one place, and specify it as being AutoCommit

Modified: trunk/buscador/bin/buscador
===================================================================
--- trunk/buscador/bin/buscador	2005-02-21 13:56:29 UTC (rev 1933)
+++ trunk/buscador/bin/buscador	2005-02-22 00:10:35 UTC (rev 1934)
@@ -1,6 +1,7 @@
 #!perl -w
-
 use strict;
+use warnings;
+use Buscador;
 use Buscador::Root;
 use Email::Folder;
 use File::NCopy;
@@ -9,10 +10,8 @@
 use Text::Unidecode;
 
 $|++;
-    
 
 
-
 goto SKIP unless @ARGV;
 # die "You must pass in at least one argument\n" unless @ARGV;
 
@@ -24,41 +23,31 @@
 } elsif ($ARGV[0] =~ /-where/) {
     print "$0\n";
     exit 0;
+} elsif ($ARGV[0] =~ /-setup/)  {
+    print "Setting up ... ";
+    Email::Store->setup;
+    print " done\n";
+    exit 0;
 }
 
-
 SKIP:
 
-require Buscador::Config; 
-require Email::Store;
-require Email::Store::Mail;
 
-Buscador::Config->import;
-Email::Store->import(Buscador::Config->dsn);
-
-# hmm there's no arguments ... check to see there's anything on STDIN
+# Hmm there's no arguments ... check to see there's anything on STDIN
 unless (@ARGV) {
     my $data = join '', <>;
     # chomp out From_ lines from naughty MTAs
     $data =~ s/^From .+$//m;
-    Email::Store::Mail->store($data);    
+    Email::Store::Mail->store($data);
     exit 0;
-}    
+}
 
-
-if ($ARGV[0] =~ /-setup/)  {            
-    print "Setting up ... "; 
-    Email::Store->setup;
-    print " done\n";
-    shift;
-} 
-
 # nothing to do now
 exit 0 unless @ARGV;
 
 
 
-print "Preparing to import ...\n"; 
+print "Preparing to import ...\n";
 
 foreach my $folder (@ARGV) {
     print "\nImporting $folder\n";
@@ -68,7 +57,7 @@
         print "\t FAILED!\n";
         next;
     }
-    while (my $message = $f->next_message) 
+    while (my $message = $f->next_message)
     {
         print "\tStoring ",unidecode($message->header('subject'))," - ", $message->header('message-id')," ...";
         Email::Store::Mail->store($message->as_string);
@@ -82,17 +71,19 @@
 
 # copy all the files across and generate a config file
 sub init {
-    
+
 # find our hostname (almost certainly wrong but it gives people an idea)
 my $host = hostname;
 
-print "Copying files from $root ... ";    
+print "Copying files from $root ... ";
 # and get ready to copy ...
 my $file = File::NCopy->new( recursive => 1 );
 
 # copy over the chrome and templates dirctory
-$file->copy("$root/chrome",".")          or die "Couldn't copy chrome across from $root/chrome\n";
-$file->copy("$root/templates",".")    or die "Couldn't copy templates across from $root/templates\n";
+$file->copy("$root/chrome", ".")
+  or die "Couldn't copy chrome across from $root/chrome\n";
+$file->copy("$root/templates", ".")
+  or die "Couldn't copy templates across from $root/templates\n";
 
 print "done\n";
 
@@ -140,7 +131,7 @@
 
     % buscador /path/to/mail/folder
 
-Or you can cat mails into buscador-import in order to add them. 
+Or you can cat mails into buscador-import in order to add them.
 This is useful as an entry into an alias file
 
     my_archiver: "|/path/to/buscador"

Modified: trunk/buscador/lib/Buscador.pm
===================================================================
--- trunk/buscador/lib/Buscador.pm	2005-02-21 13:56:29 UTC (rev 1933)
+++ trunk/buscador/lib/Buscador.pm	2005-02-22 00:10:35 UTC (rev 1934)
@@ -14,36 +14,38 @@
 our $home;
 sub debug() {0}
 
-BEGIN { 
+BEGIN {
     require Email::Store;
 
-    Email::Store->import(Buscador::Config->dsn, verbose => 1 );
+    Email::Store->import({ verbose => 1 }, Buscador::Config->dsn, '', '',
+                         { RaiseError => 1, AutoCommit => 1 });
+    die Email::Store::DBI->db_Main->{AutoCommit} ;
 
     use Module::Pluggable           search_path => [ "Email::Store" ], sub_name => 'stores', require => 1;
     use Module::Pluggable::Ordered  search_path => [ "Buscador" ];
-    
+
     $home = Buscador::Config->home;
     Buscador->config->{cache_options}{class} = "Cache::FileCache";
     Buscador->config->{model} = "Maypole::Model::CDBI::Plain";
 
-    
+
     # this is a bit of an egregious hack
     # perhaps plugins should specifically state whether they
     # are capable of being set up or not
     my @stores = sort grep { !/(DBI|Addressing)$/ }
-                      grep { !/SUPER$/ } 
-                      grep { $_->can("table") } 
+                      grep { !/SUPER$/ }
+                      grep { $_->can("table") }
                       Buscador->stores;
 
 
-    
+
     # not needed any more
     #@stores =  sort qw/ Email::Store::Mail Email::Store::List  Email::Store::Date
     #Email::Store::Entity Email::Store::Entity::Name Email::Store::Attachment
     #Email::Store::Entity::Address Email::Store::NamedEntity Email::Store::Vote /;
 
 
-    Buscador->setup([ @stores ]); 
+    Buscador->setup([ @stores ]);
 };
 
 Buscador->config->{rows_per_page}         = 10;
@@ -59,7 +61,6 @@
 $Plucene::QueryParser::DefaultOperator    = "AND";
 
 
-
 sub parse_path {
     my $self = shift;
 
@@ -76,14 +77,14 @@
 
 =head1 DESCRIPTION
 
-Buscador is web based mail archival and retrieval tool based 
+Buscador is web based mail archival and retrieval tool based
 around the concept of Intertwingle :
 
     http://www.mozilla.org/blue-sky/misc/199805/intertwingle.html
 
 In essence it provides a variety of different views on the mail
 using a system of plugins. Plugins provided include ones to
-show thread views, date views, seperation into mailing lists, 
+show thread views, date views, seperation into mailing lists,
 extraction of named entities and Atom feeds for recent mails,
 per thread, per list and per person and for handling mailing.
 
@@ -91,7 +92,7 @@
 =head1 WARNING!
 
 Buscador is distinctly B<ALPHA> level software and details of its
-architecture could change at anytime. Be prepared for DB changes 
+architecture could change at anytime. Be prepared for DB changes
 and plugin system gutting and rebuilding by reading the safety
 card in the pocket in front of you and bracing you hands over your head
 in the event of catastrophic architecture rethinking.
@@ -104,8 +105,8 @@
 
     http://thegestalt.org/simon/perl/Bundle-Buscador-0.1.tar.gz
 
-however some people have had problems installing some of these. 
-Namely 
+however some people have had problems installing some of these.
+Namely
 
     Apache::Request
     Class::DBI::AsForm
@@ -113,11 +114,11 @@
     Email::MIME::Attachment::Stripper
     Mail::ListDetector
 
-And, in particular C<SQL::Translator>. C<SQL::Translator> 
-installs a lot of weird things such as C<GD>, C<Graphviz> 
+And, in particular C<SQL::Translator>. C<SQL::Translator>
+installs a lot of weird things such as C<GD>, C<Graphviz>
 and C<Spreadsheet::ParseExcel>.
 
-A cut down version of C<SQL::Translator> without these 
+A cut down version of C<SQL::Translator> without these
 dependencies is available from
 
      http://thegestalt.org/simon/perl/SQL-Translator-0.05-lite.tar.gz
@@ -128,12 +129,12 @@
 
     % buscador -init
 
-this will copy some templates and some images into the directory and 
+this will copy some templates and some images into the directory and
 then generate a sample config file. You should edit the config file.
 
-You might want to move your chrome directory outside your new buscador 
-directory and alter your config accordingly. That way Maypole (which 
-Buscador is based on) doesn't try and first see if there's a table 
+You might want to move your chrome directory outside your new buscador
+directory and alter your config accordingly. That way Maypole (which
+Buscador is based on) doesn't try and first see if there's a table
 called 'chrome' before passing through to the actual chrome directory
 and also won't fill your logs with errors.
 
@@ -176,24 +177,24 @@
     package Buscador::Foo;
 
     # we're middling important
-    sub parse_path_order { 13 }     
+    sub parse_path_order { 13 }
 
     sub parse_path {
         my ($self, $buscador) = @_;
 
         # buscador is an alias for search
         $buscador->{path} =~ s!/buscador/!/search/!;
-        
+
     }
 
     1;
 
-however they don't have to touch the path at all and can simply 
+however they don't have to touch the path at all and can simply
 install methods in other namespaces;
 
 
     package Buscador::Bar;
-    
+
     # this is where path parsing methods would go
 
     package Email::Store::Mail;
@@ -208,7 +209,7 @@
     1;
 
 
-And now, if we write a 'fortune' template and go to 
+And now, if we write a 'fortune' template and go to
 
     http://example.com/buscador/mail/bar
 
@@ -216,7 +217,7 @@
 
 =head1 BUGS
 
-Lots and lots. And then some more 
+Lots and lots. And then some more
 
 =over 4
 

Generated at 01:00 on 22 Feb 2005 by mariachi 0.52