From: Frank Brehm Date: Thu, 13 May 2010 07:59:21 +0000 (+0000) Subject: Sinnvollen Anfang gefunden X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=a4b309d9b0cced1f9a2c7d750709ff8c689cf320;p=my-stuff%2Fperl.git Sinnvollen Anfang gefunden git-svn-id: http://svn.brehm-online.com/svn/my-stuff/Perl@63 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- diff --git a/lib/FrBr/Common/MooseX/App.pm b/lib/FrBr/Common/MooseX/App.pm index 04fd651..c7fef5d 100644 --- a/lib/FrBr/Common/MooseX/App.pm +++ b/lib/FrBr/Common/MooseX/App.pm @@ -32,7 +32,7 @@ use FindBin; use Encode qw( decode_utf8 encode_utf8 ); use Data::Dump; -use Carp (); +use Carp; with 'FrBr::Common::MooseX::Role::CommonOpts'; @@ -330,7 +330,7 @@ before BUILD => sub { after 'BUILD' => sub { my $self = shift; - $self->init_app() unless $self->app_initialized; + $self->_init_app() unless $self->app_initialized; $self->debug( "Anwendungsobjekt: ", $self ) if $self->verbose >= 3; $self->debug( "Bereit zum Kampf - äh - was auch immer." ); @@ -339,22 +339,58 @@ after 'BUILD' => sub { #--------------------------------- -=head2 init_app( ) +=head2 _init_app( ) Initialisiert nach dem BUILD alles. =cut -sub init_app { +sub _init_app { my $self = shift; $self->debug( "Initialisiere Anwendung ..." ); + $self->init_app(); $self->app_initialized(1); } #--------------------------------- +=head2 init_app( ) + +Initialisierung als Haken für andere Rollen und Objekte + +=cut + +sub init_app { + + my $self = shift; + + $self->debug( "Initialisierung beginnt ..." ) if $self->verbose >= 2; + +} + +#--------------------------------- + +=head2 run( ) + +Dummy-Funktion zum Start der Anwendung nach der Initialisierung. + +Muss in abgeleiteten Objekten überschrieben werden. + +=cut + +sub run { + + my $self = shift; + + $self->error( "run() im " . __PACKAGE__ . "-Objekt ist nur eine Dummy-Funktion." ); + confess( "Dummy-Funktion." ); + +} + +#--------------------------------- + sub _init_log { my $self = shift; diff --git a/lib/FrBr/Common/MooseX/Role/Config.pm b/lib/FrBr/Common/MooseX/Role/Config.pm index a170f4e..0310f01 100644 --- a/lib/FrBr/Common/MooseX/Role/Config.pm +++ b/lib/FrBr/Common/MooseX/Role/Config.pm @@ -281,6 +281,9 @@ after 'init_app' => sub { my $self = shift; + return if $self->app_initialized; + + $self->debug( "Initialisiere ..." ); $self->read_config_file(); $self->evaluate_config(); diff --git a/lib/FrBr/Common/MooseX/Role/FtpClient.pm b/lib/FrBr/Common/MooseX/Role/FtpClient.pm index 5d64019..788325f 100644 --- a/lib/FrBr/Common/MooseX/Role/FtpClient.pm +++ b/lib/FrBr/Common/MooseX/Role/FtpClient.pm @@ -510,6 +510,8 @@ after 'init_app' => sub { my $self = shift; + return if $self->app_initialized; + $self->debug( "Initialisiere ..." ); if ( $self->verbose >= 2 ) { @@ -605,16 +607,19 @@ sub login_ftp { } my $ftp = $self->ftp; - if ( $ftp->login( $self->ftp_user, $self->ftp_password ) ) { - $self->debug( "FTP-Login erfolgreich." ); - $self->_set_ftp_connected(1); - return 1; - } - else { + unless ( $ftp->login( $self->ftp_user, $self->ftp_password ) ) { $self->warn( sprintf( "FTP-Login misslungen: %s", $ftp->message ) ); + return undef; } - return undef; + $self->debug( "FTP-Login erfolgreich." ); + $self->_set_ftp_connected(1); + + $self->debug( sprintf( "Wechsele in das FTP-Verzeichnis '%s' ...", $self->ftp_remote_dir->stringify ) ); + my $result = $ftp->cwd( $self->ftp_remote_dir->stringify ); + $self->error( sprintf( "Konnte nicht in das FTP-Verzeichnis '%s' wechseln: %s", $self->ftp_remote_dir->stringify, $ftp->message ) ) unless $result; + + return $result; }