|
From: <jgr...@us...> - 2003-11-10 20:33:17
|
Update of /cvsroot/popfile/engine/POPFile
In directory sc8-pr-cvs1:/tmp/cvs-serv8191/POPFile
Modified Files:
Loader.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: Loader.pm
===================================================================
RCS file: /cvsroot/popfile/engine/POPFile/Loader.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Loader.pm 10 Nov 2003 20:15:15 -0000 1.14
--- Loader.pm 10 Nov 2003 20:33:13 -0000 1.15
***************
*** 51,60 ****
$self->{components__} = {};
- $self->{disabled_components__} = {};
-
- # Do not allow disabling of the following components (group or name)
-
- $self->{required_components__} = qr/^(core|html|bayes)$/;
-
# A handy boolean that tells us whether we are alive or not. When this is set to 1 then the
# proxy works normally, when set to 0 (typically by the aborting() function called from a signal)
--- 51,54 ----
***************
*** 65,69 ****
# This must be 1 for POPFile::Loader to create any output on STDOUT
! $self->{debug__} = 0;
# This stuff lets us do some things in a way that tolerates some window-isms
--- 59,63 ----
# This must be 1 for POPFile::Loader to create any output on STDOUT
! $self->{debug__} = 1;
# This stuff lets us do some things in a way that tolerates some window-isms
***************
*** 91,94 ****
--- 85,92 ----
$self->{version_string__} = '';
+ # Where POPFile is installed
+
+ $self->{popfile_root__} = './';
+
bless $self, $type;
***************
*** 107,110 ****
--- 105,112 ----
my ( $self ) = @_;
+ if ( defined( $ENV{POPFILE_ROOT} ) ) {
+ $self->{popfile_root__} = $ENV{POPFILE_ROOT};
+ }
+
# These anonymous subroutine references allow us to call these important
# functions from anywhere using the reference, granting internal access
***************
*** 120,124 ****
# POPFile version number
! my $version_file = 'POPFile/popfile_version';
if ( -e $version_file ) {
--- 122,126 ----
# POPFile version number
! my $version_file = $self->root_path__( 'POPFile/popfile_version' );
if ( -e $version_file ) {
***************
*** 314,318 ****
# hash getting the name from the module by calling name()
! opendir MODULES, $directory;
while ( my $entry = readdir MODULES ) {
--- 316,320 ----
# hash getting the name from the module by calling name()
! opendir MODULES, $self->root_path__( $directory );
while ( my $entry = readdir MODULES ) {
***************
*** 371,375 ****
my $mod;
! if ( open MODULE, "<$module" ) {
my $first = <MODULE>;
close MODULE;
--- 373,377 ----
my $mod;
! if ( open MODULE, '<' . $self->root_path__( $module ) ) {
my $first = <MODULE>;
close MODULE;
***************
*** 377,381 ****
if ( $first =~ /^# POPFILE LOADABLE MODULE/ ) {
require $module;
!
$module =~ s/\//::/;
$module =~ s/\.pm//;
--- 379,383 ----
if ( $first =~ /^# POPFILE LOADABLE MODULE/ ) {
require $module;
!
$module =~ s/\//::/;
$module =~ s/\.pm//;
***************
*** 509,512 ****
--- 511,520 ----
$self->{components__}{proxy}{$name}->classifier( $self->{components__}{classifier}{bayes} );
}
+
+ # TODO Clean this up so that the Loader doesn't have to know so much about
+ # Bayes.
+
+ $self->{components__}{classifier}{bayes}->{parser__}->mangle(
+ $self->{components__}{classifier}{wordmangle} );
}
***************
*** 611,648 ****
#---------------------------------------------------------------------------------------------
#
- # CORE_enabled_check
- #
- # Prevents calling of start and service of disabled optional modules
- #
- #---------------------------------------------------------------------------------------------
- sub CORE_enabled_check
- {
- my ( $self ) = @_;
-
- # Check all currently enabled components
-
- foreach my $type (keys %{$self->{components__}}) {
- unless ( $type =~ $self->{required_components__} ) {
- foreach my $name (keys %{$self->{components__}{$type}}) {
- unless ( ( $name =~ $self->{required_components__} )
- || ( defined($self->{components__}{$type}{$name}->config_( 'enabled' ) )
- && $self->{components__}{$type}{$name}->config_( 'enabled' ) ) ) {
-
- # If the component is optional and is disabled, move it to a holding
- # hash. This is done this way to allow recovery/re-enabling of objects
- # (eg, HUP) and to leave them intact for interface plugin configuration.
- $self->{disabled_components__}{$type}{$name} = $self->{components__}{$type}{$name};
- delete $self->{components__}{$type}{$name};
- }
- }
- }
- }
-
- # Re-enable any disabled components that are now enabled
- # TODO: implement this when POPFile needs to be able to handle a HUP.
- }
-
- #---------------------------------------------------------------------------------------------
- #
# CORE_service
#
--- 619,622 ----
***************
*** 819,822 ****
--- 793,815 ----
delete($self->{components__}{$type}{$name});
+ }
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # root_path__
+ #
+ # Joins the path passed in with the POPFile root
+ #
+ # $path RHS of path
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub root_path__
+ {
+ my ( $self, $path ) = @_;
+
+ $self->{popfile_root__} =~ s/[\/\\]$//;
+ $path =~ s/^[\/\\]//;
+
+ return "$self->{popfile_root__}/$path";
}
|