--- trunk/Estraier.pm 2006/05/09 14:03:36 136 +++ trunk/Estraier.pm 2006/05/10 13:45:08 139 @@ -20,7 +20,10 @@ my $node = new Search::Estraier::Node( url => 'http://localhost:1978/node/test', user => 'admin', - passwd => 'admin' + passwd => 'admin', + create => 1, + label => 'Label for node', + croak_on_error => 1, ); # create document @@ -874,6 +877,8 @@ url => 'http://localhost:1978/node/test', user => 'admin', passwd => 'admin' + create => 1, + label => 'optional node label', debug => 1, croak_on_error => 1 ); @@ -894,6 +899,14 @@ password for authentication +=item create + +create node if it doesn't exists + +=item label + +optional label for new node if C is used + =item debug dumps a B of debugging output @@ -937,6 +950,22 @@ size => -1.0, }; + if ($self->{create}) { + eval { + $self->name; + }; + if ($@) { + my $name = $1 if ($self->{url} =~ m#/node/([^/]+)/*#); + croak "can't find node name in '$self->{url}'" unless ($name); + my $label = $self->{label} || $name; + $self->master( + action => 'nodeadd', + name => $name, + label => $label, + ) || croak "can't create node $name ($label)"; + } + } + $self ? return $self : return undef; }