|
From: <jgr...@us...> - 2003-11-10 20:48:20
|
Update of /cvsroot/popfile/engine/POPFile
In directory sc8-pr-cvs1:/tmp/cvs-serv13702/POPFile
Modified Files:
Configuration.pm Module.pm
Log Message:
Multi-user Phase #1
-------------------
Make POPFile work relative to two special environment variables:
POPFILE_ROOT The location where popfile.pl is installed
POPFILE_USER The location where this user's config is kept
POPFile/Module.pm:
Add two methods
get_root_path_
get_user_path_
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER. This two helpers simply
call the relevant public interface in POPFile/Configuration.pm.
POPFile/Configuration.pm:
Add two methods
get_root_path
get_user_path
that convert passed in relative paths to absolute paths relative
to either POPFILE_ROOT or POPFILE_USER.
Classifer/WordMangle.pm:
Make this a PLM (with name 'wordmangle') so that it can get access
to the POPFILE_USER variable so that stopwords are per user.
Classifier/Bayes.pm:
Remove unused Classifier::WordMangle object.
Change all path usage to call get_user_path_ to set the path
correctly relative to the current user.
UI/HTML.pm:
Change path usage to call get_root_path_ or get_user_path_ to get
the path relative to the current root or user. The root is used to
access skins, manual and language files. Everything else is in the
user directory.
POPFile/Module.pm:
Use the POPFILE_ROOT to control the loading of modules.
popfile.pl:
If POPFILE_ROOT is defined the add it to @INC so that we can load
the POPFile::Loader module.
tests/TestWordMangle.tst:
Since Classifier::WordMangle is now a PLM the tests need to be
updated to load the mangler correctly and link it in with the
other POPFile modules that is depends on.
tests/TestPOP3.tst
tests/TestMailParse.tst
tests/TestBayes.tst:
Since Classifier::WordMangle is now a PLM test suites that relied
upon Classifier::MailParse creating the mangler needed updating to
actually create and pass in the mangler object.
tests/TestHTTP.tst:
Make tests work on non-Windows systems. One test was relying on
\n being \r\n.
TODO
Write tests for get_user_path and get_root_path, is_absolute_path,
root_path and path_join
Write tests for POPFILE_ROOT and POPFILE_USER
Make HTML test suite run on Linux
Debug MailParse test suite, fix Japanese handling (026).
Debug POP3 suite/TOP handling
Index: Configuration.pm
===================================================================
RCS file: /cvsroot/popfile/engine/POPFile/Configuration.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** Configuration.pm 10 Nov 2003 20:15:15 -0000 1.30
--- Configuration.pm 10 Nov 2003 20:48:16 -0000 1.31
***************
*** 71,74 ****
--- 71,79 ----
$self->{save_needed__} = 0;
+ # Local copies of POPFILE_ROOT and POPFILE_USER
+
+ $self->{popfile_root__} = '';
+ $self->{popfile_user__} = '';
+
bless $self, $type;
***************
*** 89,92 ****
--- 94,100 ----
my ( $self ) = @_;
+ $self->{popfile_root__} = $ENV{POPFILE_ROOT};
+ $self->{popfile_user__} = $ENV{POPFILE_USER};
+
# This is the location where we store the PID of POPFile in a file
# called popfile.pid
***************
*** 146,150 ****
# may be running, warn the user and terminate
! $self->{pid_file__} = $self->config_( 'piddir' ) . 'popfile.pid';
if (defined($self->live_check_())) {
--- 154,158 ----
# may be running, warn the user and terminate
! $self->{pid_file__} = $self->get_user_path_( $self->config_( 'piddir' ) . 'popfile.pid' );
if (defined($self->live_check_())) {
***************
*** 477,481 ****
my ( $self ) = @_;
! if ( open CONFIG, "<popfile.cfg" ) {
while ( <CONFIG> ) {
s/(\015|\012)//g;
--- 485,489 ----
my ( $self ) = @_;
! if ( open CONFIG, '<' . $self->get_user_path_( 'popfile.cfg' ) ) {
while ( <CONFIG> ) {
s/(\015|\012)//g;
***************
*** 511,515 ****
}
! if ( open CONFIG, ">popfile.cfg" ) {
$self->{save_needed__} = 0;
--- 519,523 ----
}
! if ( open CONFIG, '>' . $self->get_user_path_( 'popfile.cfg' ) ) {
$self->{save_needed__} = 0;
***************
*** 520,523 ****
--- 528,578 ----
close CONFIG;
}
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # get_user_path, get_root_path
+ #
+ # Resolve a path relative to POPFILE_USER or POPFILE_ROOT
+ #
+ # $path The path to resolve
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub get_user_path
+ {
+ my ( $self, $path ) = @_;
+
+ return $self->path_join__( $self->{popfile_user__}, $path );
+ }
+
+ sub get_root_path
+ {
+ my ( $self, $path ) = @_;
+
+ return $self->path_join__( $self->{popfile_root__}, $path );
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # path_join__
+ #
+ # Join two paths togther
+ #
+ # $left The LHS
+ # $right The RHS
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub path_join__
+ {
+ my ( $self, $left, $right ) = @_;
+
+ if ( ( $right =~ /^\// ) || ( $right =~ /^[A-Z]:\/\\/ ) ) {
+ return $right;
+ }
+
+ $left =~ s/\/$//;
+ $right =~ s/^\///;
+
+ return "$left/$right";
}
Index: Module.pm
===================================================================
RCS file: /cvsroot/popfile/engine/POPFile/Module.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Module.pm 10 Nov 2003 20:15:16 -0000 1.14
--- Module.pm 10 Nov 2003 20:48:17 -0000 1.15
***************
*** 424,427 ****
--- 424,450 ----
}
+ # ---------------------------------------------------------------------------------------------
+ #
+ # get_user_path_, get_root_path_
+ #
+ # Wrappers for POPFile::Configuration get_user_path and get_root_path
+ #
+ # $path The path to modify
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub get_user_path_
+ {
+ my ( $self, $path ) = @_;
+
+ return $self->{configuration__}->get_user_path( $path );
+ }
+
+ sub get_root_path_
+ {
+ my ( $self, $path ) = @_;
+
+ return $self->{configuration__}->get_root_path( $path );
+ }
+
# GETTER/SETTER methods. Note that I do not expect documentation of these unless they
# are non-trivial since the documentation would be a waste of space
|