=end testing
=cut
+use Text::Tradition::TypeMap::Entry;
has +typemap => (
- is => 'rw',
- isa => 'KiokuDB::TypeMap',
- default => sub {
- KiokuDB::TypeMap->new(
- isa_entries => {
- "Graph" => KiokuDB::TypeMap::Entry::Naive->new,
- "Graph::AdjacencyMap" => KiokuDB::TypeMap::Entry::Naive->new,
- }
- );
- },
+ is => 'rw',
+ isa => 'KiokuDB::TypeMap',
+ default => sub {
+ KiokuDB::TypeMap->new(
+ isa_entries => {
+ "Text::Tradition" =>
+ KiokuDB::TypeMap::Entry::Naive->new(),
+ "Graph" => Text::Tradition::TypeMap::Entry->new(),
+ "Graph::AdjacencyMap" => Text::Tradition::TypeMap::Entry->new(),
+ }
+ );
+ },
);
# Push some columns into the extra_args
};
## These checks don't cover store($id, $obj)
-before [ qw/ store update insert delete / ] => sub {
+# before [ qw/ store update insert delete / ] => sub {
+before [ qw/ delete / ] => sub {
my $self = shift;
my @nontrad;
foreach my $obj ( @_ ) {
# TODO Garbage collection doesn't work. Suck it up and live with the
# inflated DB.
-# after delete => sub {
-# my $self = shift;
-# my $gc = KiokuDB::GC::Naive->new( backend => $self->directory->backend );
-# $self->directory->backend->delete( $gc->garbage->members );
-# };
+after delete => sub {
+ my $self = shift;
+ my $gc = KiokuDB::GC::Naive->new( backend => $self->directory->backend );
+ $self->directory->backend->delete( $gc->garbage->members );
+};
sub save {
my $self = shift;
my $password = $userinfo->{password};
my $role = $userinfo->{role} || 'user';
- return unless ($username =~ /^https?:/
- || ($username && $self->validate_password($password))) ;
+ throw( "No username given" ) unless $username;
+ throw( "Invalid password - must be at least " . $self->MIN_PASS_LEN
+ . " characters long" )
+ unless ( $self->validate_password($password) || $username =~ /^https?:/ );
my $user = Text::Tradition::User->new(
id => $username,
my $password = $userinfo->{password};
my $role = $userinfo->{role};
- return unless $username;
- return if($password && !$self->validate_password($password));
+ throw( "Missing username or bad password" )
+ unless $username && $self->validate_password($password);
my $user = $self->find_user({ username => $username });
- return unless $user;
+ throw( "Could not find user $username" ) unless $user;
if($password) {
$user->password(crypt_password($password));
my ($self, $userinfo) = @_;
my $username = $userinfo->{username};
- return if !$username;
+ throw( "Need to specify a username for deactivation" ) unless $username;
my $user = $self->find_user({ username => $username });
- return if !$user;
+ throw( "User $username not found" ) unless $user;
$user->active(0);
foreach my $tradition (@{ $user->traditions }) {
my ($self, $userinfo) = @_;
my $username = $userinfo->{username};
- return if !$username;
+ throw( "Need to specify a username for reactivation" ) unless $username;
my $user = $self->lookup(Text::Tradition::User->id_for_user($username));
- return if !$user;
+ throw( "User $username not found" ) unless $user;
return $user if $user->active;
my ($self, $userinfo) = @_;
my $username = $userinfo->{username};
- return if !$username;
+ throw( "Need to specify a username for deletion" ) unless $username;
my $user = $self->find_user({ username => $username });
- return if !$user;
+ throw( "User $username not found" ) unless $user;
## Should we be using Text::Tradition::Directory for this bit?
$self->delete( @{ $user->traditions });