]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/Model/Base.pm
Use Maypole::Application so we can test even without Apache
[maypole.git] / lib / Maypole / Model / Base.pm
index 12bb71d24e614cd0e66d87043c2bc6b4108fcbfb..6e60aea7f9c3f4505b93263eaa31fcef4dc240d2 100644 (file)
@@ -8,9 +8,17 @@ sub edit :Exported { }
 
 sub process {
     my ($class, $r) = @_;
-    $r->template( my $method = $r->action );
-    $r->objects([ $class->retrieve(shift @{$r->{args}}) ]);
-    $class->$method($r);
+    my $method = $r->action;
+    return if $r->{template}; # Authentication has set this, we're done.
+
+    $r->{template} = $method;
+    $r->objects([]);
+    my $obj = $class->retrieve( $r->{args}->[0] );
+    if ($obj) {
+        $r->objects([ $obj ]);
+        shift @{$r->{args}};
+    }
+    $class->$method($r, $obj, @{$r->{args}});
 }
 
 sub display_columns { 
@@ -115,7 +123,10 @@ Return a hash mapping column names with human-readable equivalents.
 
 =cut
 
-sub column_names { my $class = shift; map { $_ => ucfirst $_ } $class->columns }
+sub column_names { my $class = shift; map { 
+        my $col = $_;
+        $col =~ s/_+(\w)?/ \U$1/g;
+        $_ => ucfirst $col } $class->columns }
 
 =head2 description