--- trunk/Estraier.pm 2006/01/06 02:07:10 48 +++ trunk/Estraier.pm 2006/01/06 12:40:23 49 @@ -692,6 +692,7 @@ use URI; use MIME::Base64; use IO::Socket::INET; +use URI::Escape qw/uri_escape/; =head1 Search::Estraier::Node @@ -928,6 +929,40 @@ } +=head2 get_doc_attr + +Retrieve the value of an atribute from object + + my $val = $node->get_doc_attr( document_id, 'attribute_name' ) or + die "can't get document attribute"; + +=cut + +sub get_doc_attr { + my $self = shift; + my ($id,$name) = @_; + return unless ($id && $name); + return $self->_fetch_doc( id => $id, attr => $name ); +} + + +=head2 get_doc_attr_by_uri + +Retrieve the value of an atribute from object + + my $val = $node->get_doc_attr_by_uri( document_id, 'attribute_name' ) or + die "can't get document attribute"; + +=cut + +sub get_doc_attr_by_uri { + my $self = shift; + my ($uri,$name) = @_; + return unless ($uri && $name); + return $self->_fetch_doc( uri => $uri, attr => $name ); +} + + =head2 etch_doc Exctract document keywords @@ -936,7 +971,7 @@ =cut -sub erch_doc { +sub etch_doc { my $self = shift; my $id = shift || return; return $self->_fetch_doc( id => $id, etch => 1 ); @@ -987,6 +1022,10 @@ my $doc = $node->_fetch_doc( id => 42, etch => 1 ); my $doc = $node->_fetch_doc( uri => 'file:///document/uri/42', etch => 1 ); + # to get document attrubute add attr + my $doc = $node->_fetch_doc( id => 42, attr => '@mdate' ); + my $doc = $node->_fetch_doc( uri => 'file:///document/uri/42', attr => '@mdate' ); + # more general form which allows implementation of # uri_to_id my $id = $node->_fetch_doc( @@ -1016,6 +1055,12 @@ confess "unhandled argument. Need id or uri."; } + if ($a->{attr}) { + $path = '/get_doc_attr'; + $arg .= '&attr=' . uri_escape($a->{attr}); + $a->{chomp_resbody} = 1; + } + my $rv = $self->shuttle_url( $self->{url} . $path, 'application/x-www-form-urlencoded', $arg,