--- lib/PXElator/CouchDB.pm 2009/08/12 23:59:01 208 +++ lib/PXElator/CouchDB.pm 2009/08/13 12:00:38 210 @@ -80,11 +80,19 @@ $rev->{$url} = $json->{_rev} = $old if defined $old; } - $json = unbless dclone $json if blessed $json; + my $data = dclone $json; + $data = unbless $data if blessed $data; - $json = JSON->new->utf8->encode( $json ) if $json; + warn dump( $data ); - $self->request(PUT => $url, $json); + $json = JSON->new->utf8->encode( $data ); + + warn $json; + + do { + eval { $self->request(PUT => $url, $json) }; + $rev->{$url} = $self->get( $url )->{_rev} if $@; + } until ! $@; } sub post { @@ -99,11 +107,11 @@ my $data = pop @_; my $url = join(' ', @_); - $url =~ s/-\S+//g; + $url =~ s/\s+-\S+//g; # remove command line options $url =~ s/\W+/-/g; my ( $package, $file, $line, $sub ) = caller(1); - ( $package, undef, $line ) = caller(0) if $package eq 'main'; +# ( $package, undef, $line ) = caller(0) if $package eq 'main'; my $time = time(); @@ -113,6 +121,7 @@ $time = int($time); # reduce granularity $audit->put( "pxelator/$time.$package.$url", $data ); + } 1;