[Bps-public-commit] r16292 - in Prophet/trunk/lib/Prophet: Replica
jesse at bestpractical.com
jesse at bestpractical.com
Tue Oct 14 17:54:51 EDT 2008
Author: jesse
Date: Tue Oct 14 17:54:51 2008
New Revision: 16292
Modified:
Prophet/trunk/lib/Prophet/App.pm
Prophet/trunk/lib/Prophet/DatabaseSetting.pm
Prophet/trunk/lib/Prophet/Replica/prophet.pm
Log:
ore database setting fixups
Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm (original)
+++ Prophet/trunk/lib/Prophet/App.pm Tue Oct 14 17:54:51 2008
@@ -134,20 +134,21 @@
sub setting {
my $self = shift;
- my %args = validate( @_, { uuid => 0, default => 1, label => 0 } );
+ my %args = validate( @_, { uuid => 0, default => 0, label => 0 } );
require Prophet::DatabaseSetting;
- my $uuid;
+ my ($uuid, $default);
if ( $args{uuid} ) {
$uuid = $args{'uuid'};
+ $default = $args{'default'};
} elsif ( $args{'label'} ) {
- $uuid = $self->database_settings->{ $args{'label'} };
+ ($uuid, $default) = @{ $self->database_settings->{ $args{'label'} }};
}
return Prophet::DatabaseSetting->new(
handle => $self->handle,
uuid => $uuid,
- default => $args{default},
+ default => $default,
label => $args{label}
);
Modified: Prophet/trunk/lib/Prophet/DatabaseSetting.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/DatabaseSetting.pm (original)
+++ Prophet/trunk/lib/Prophet/DatabaseSetting.pm Tue Oct 14 17:54:51 2008
@@ -15,14 +15,15 @@
sub new {
- shift->SUPER::new( type => '__prophet_db_settings', @_);
-}
+ my $self = shift->SUPER::new( type => '__prophet_db_settings', @_);
+
+ $self->initialize unless ($self->handle->record_exists(uuid => $self->uuid, type => $self->type) );
+ return $self;
+ }
sub initialize {
my $self = shift;
- warn "My default is ".$self->default;
- warn "My uuid is ". $self->uuid;
$self->set($self->default);
}
@@ -47,7 +48,11 @@
sub get {
my $self = shift;
- my $entry = from_json($self->prop('content') , { utf8 => 1 });
+
+
+ $self->initialize() unless $self->load(uuid => $self->uuid);
+ my $content = $self->prop('content');
+ my $entry = from_json($content , { utf8 => 1 });
return $entry;
# XXX TODO do we really want to just get the first one?
Modified: Prophet/trunk/lib/Prophet/Replica/prophet.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/prophet.pm (original)
+++ Prophet/trunk/lib/Prophet/Replica/prophet.pm Tue Oct 14 17:54:51 2008
@@ -530,7 +530,6 @@
my ($seq,$key) = $self->_read_record_index_entry( type => $args{'type'}, uuid => $args{'uuid'});
-
return undef unless ($key and ($key ne '0'x40));
# XXX: deserialize the changeset content from the cas with $key
my $casfile = file(
More information about the Bps-public-commit
mailing list