X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FInflateColumn%2FFile.pm;h=951b76e35a3141aa8671b9e44c94f5e3850c75a5;hb=3814fdaddf1c49d2a8055c6da60cd93a1b513ad7;hp=d462bccb7d06adc587ef40ef1982c88f8c0fa2fe;hpb=26ddc864d0c6b21a64c1c390f4c4b5e031aed2b2;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/InflateColumn/File.pm b/lib/DBIx/Class/InflateColumn/File.pm index d462bcc..951b76e 100644 --- a/lib/DBIx/Class/InflateColumn/File.pm +++ b/lib/DBIx/Class/InflateColumn/File.pm @@ -7,6 +7,17 @@ use File::Path; use File::Copy; use Path::Class; +use Carp::Clan qw/^DBIx::Class/; +carp 'InflateColumn::File has entered a deprecation cycle. This component ' + .'has a number of architectural deficiencies that can quickly drive ' + .'your filesystem and database out of sync and is not recommended ' + .'for further use. It will be retained for backwards ' + .'compatibility, but no new functionality patches will be accepted. ' + .'Please consider using the much more mature and actively maintained ' + .'DBIx::Class::InflateColumn::FS. You can set the environment variable ' + .'DBIC_IC_FILE_NOWARN to a true value to disable this warning.' +unless $ENV{DBIC_IC_FILE_NOWARN}; + __PACKAGE__->load_components(qw/InflateColumn/); sub register_column { @@ -58,7 +69,7 @@ sub delete { sub insert { my $self = shift; - + # cache our file columns so we can write them to the fs # -after- we have a PK my %file_column; @@ -95,8 +106,10 @@ sub _save_file_column { my $fs_file = $self->_file_column_file($column, $value->{filename}); mkpath [$fs_file->dir]; - - File::Copy::copy($value->{handle}, $fs_file); + + # File::Copy doesn't like Path::Class (or any for that matter) objects, + # thus ->stringify (http://rt.perl.org/rt3/Public/Bug/Display.html?id=59650) + File::Copy::copy($value->{handle}, $fs_file->stringify); $self->_file_column_callback($value, $self, $column); @@ -105,14 +118,26 @@ sub _save_file_column { =head1 NAME -DBIx::Class::InflateColumn::File - map files from the Database to the filesystem. +DBIx::Class::InflateColumn::File - DEPRECATED (superseded by DBIx::Class::InflateColumn::FS) + +=head2 Deprecation Notice + + This component has a number of architectural deficiencies that can quickly + drive your filesystem and database out of sync and is not recommended for + further use. It will be retained for backwards compatibility, but no new + functionality patches will be accepted. Please consider using the much more + mature and actively supported DBIx::Class::InflateColumn::FS. You can set + the environment variable DBIC_IC_FILE_NOWARN to a true value to disable + this warning. =head1 SYNOPSIS In your L table class: - __PACKAGE__->load_components( "PK::Auto", "InflateColumn::File", "Core" ); - + use base 'DBIx::Class::Core'; + + __PACKAGE__->load_components(qw/InflateColumn::File/); + # define your columns __PACKAGE__->add_columns( "id", @@ -134,7 +159,7 @@ In your L table class: size => 255, }, ); - + In your L class: @@ -150,15 +175,15 @@ name as name. body => '....' }); $c->stash->{entry}=$entry; - + And Place the following in your TT template - + Article Subject: [% entry.subject %] Uploaded File: File Body: [% entry.body %] - + The file will be stored on the filesystem for later retrieval. Calling delete on your resultset will delete the file from the filesystem. Retrevial of the record automatically inflates the column back to the set hash with the @@ -172,7 +197,7 @@ InflateColumn::File =head2 _file_column_callback ($file,$ret,$target) -method made to be overridden for callback purposes. +Method made to be overridden for callback purposes. =cut