[Jifty-commit] r665 -

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Mar 5 03:41:21 EST 2006


Author: jesse
Date: Sun Mar  5 03:41:20 2006
New Revision: 665

Modified:
   /   (props changed)
   jifty/trunk/lib/Jifty/Record.pm

Log:
 r25582 at truegrounds:  jesse | 2006-03-04 22:55:00 -0800
 Re-enable memcached support


Modified: jifty/trunk/lib/Jifty/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Record.pm	(original)
+++ jifty/trunk/lib/Jifty/Record.pm	Sun Mar  5 03:41:20 2006
@@ -15,7 +15,7 @@
 =cut
 
 use base qw/Jifty::Object/;
-use base qw/Jifty::DBI::Record::Cachable/;
+use base qw/Jifty::DBI::Record::Memcached/;
 
 sub _init {
     my $self = shift;
@@ -53,30 +53,33 @@
 sub create {
     my $self    = shift;
     my %attribs = @_;
-    
-    unless ($self->check_create_rights(@_)) {
-        $self->log->error($self->current_user->id. " tried to create a ", ref $self, " without permission");
-        wantarray ? return (0, 'Permission denied') : return(0);
-    }
 
+    unless ( $self->check_create_rights(@_) ) {
+        $self->log->error( $self->current_user->id . " tried to create a ",
+            ref $self, " without permission" );
+        wantarray ? return ( 0, 'Permission denied' ) : return (0);
+    }
 
     foreach my $key ( keys %attribs ) {
         my $method = "validate_$key";
         next unless $self->can($method);
-        my ($val, $msg ) = $self->$method( $attribs{$key} );
+        my ( $val, $msg ) = $self->$method( $attribs{$key} );
         unless ($val) {
             $self->log->error("There was a validation error for $key");
-            return ($val, $msg);
+            return ( $val, $msg );
         }
+
         # remove blank values. We'd rather have nulls
-        if (exists $attribs{$key} and (not defined $attribs{$key} or $attribs{$key} eq "")) {
+        if ( exists $attribs{$key}
+            and ( not defined $attribs{$key} or $attribs{$key} eq "" ) )
+        {
             delete $attribs{$key};
         }
     }
 
     my $id = $self->SUPER::create(%attribs);
-    $self->load_by_cols(id => $id) if ($id);
-    return wantarray  ? ($id, "Record created") : $id;
+    $self->load_by_cols( id => $id ) if ($id);
+    return wantarray ? ( $id, "Record created" ) : $id;
 }
 
 
@@ -305,5 +308,17 @@
     return $object;
 }
 
+=head2 cache_key_prefix
+
+Returns a unique key for this application for the Memcached cache.
+This should be global within a given Jifty application instance.
+
+=cut
+
+
+sub cache_key_prefix {
+    Jifty->config->framework('Database')->{'Database'};
+}
+
 1;
 


More information about the Jifty-commit mailing list