[prev] [thread] [next] [lurker] [Date index for 2005/02/06]
Author: richardc Date: 2005-02-06 17:56:12 +0000 (Sun, 06 Feb 2005) New Revision: 1825 Modified: trunk/Email-Store-Thread/lib/Email/Store/Thread.pm Log: make the containers a little saner by allowing the containers to not hold messages Modified: trunk/Email-Store-Thread/lib/Email/Store/Thread.pm =================================================================== --- trunk/Email-Store-Thread/lib/Email/Store/Thread.pm 2005-02-06 17:04:44 UTC (rev 1824) +++ trunk/Email-Store-Thread/lib/Email/Store/Thread.pm 2005-02-06 17:56:12 UTC (rev 1825) @@ -34,7 +34,7 @@ # Is it under this one? use base qw(Mail::Thread::Container Email::Store::DBI); __PACKAGE__->table("container"); -__PACKAGE__->columns(All => qw[id message parent child next root]); +__PACKAGE__->columns(All => qw[id messageid message parent child next root]); __PACKAGE__->has_a(message => "Email::Store::Mail"); __PACKAGE__->has_a(parent => "Email::Store::Thread::Container"); __PACKAGE__->has_a(child => "Email::Store::Thread::Container"); @@ -55,21 +55,24 @@ my %container_cache = (); sub new { my ($class, $id) = @_; - $container_cache{$id} - ||= $class->find_or_create({ message => $id }); + my $container = $container_cache{$id} + ||= $class->find_or_create({ messageid => $id }); + return $container; } sub flush { (delete $container_cache{$_})->update for keys %container_cache; } -# Thread::Container wants chained accessors +# Thread::Container wants regular accessors { no strict 'refs'; no warnings 'redefine'; for my $method (qw/parent child next/) { *$method = sub { my $self = shift; + # ensure we're in the container cache too + $container_cache{ $self->messageid } = $self; my $methname = "_${method}_accessor"; $self->$methname(@_) if @_; $self->$methname(); @@ -132,7 +135,8 @@ __DATA__ CREATE TABLE container ( id integer NOT NULL PRIMARY KEY AUTO_INCREMENT, - message varchar(255) NOT NULL, + messageid varchar(255) NOT NULL, + message varchar(255), parent integer, child integer, next integer,
Generated at 22:00 on 06 Feb 2005 by mariachi 0.52