ProDBWiki/DeveloperDocumentation/copyDB

From BRF-Software
Revision as of 10:20, 27 May 2005 by imported>NicoleChaux
Jump to navigation Jump to search

CopyDB.cgi

Overview

CopyDB.cgi is a script at the mascot server. It handles the setting and getting from a database. To write this script had two different reasons. First the function reduce_search_space ProDBWiki/DeveloperDocumentation/reduceSearchSpace from msanalysis.cgi needed to send a database to mascot, so that it can make a search against the database. Therefore you can use the function set_database. Second, the search tool emowse needed to get the selected databases, from the search form, from mascot to submit his searches to the databases. For this problem you can use the function get_database.

A request is send via HTTP to this script. To use one of the functions you need to set different attributes set = 1 for set_database and get = 1 for get_database. You'll find further informations in the sections to the funtions.

set_database

To call this function, you need to include the packages HTTP::Request, HTTP::Request::Common and HTTP::Response. Here is an example for the request:

# header for the Mascot request
my $browser = 'Mozilla/4.77C-CCK-MCD  [en] (X11; U; SunOS 5.8 sun4u; Nav)';
my @request_data = (Connection => 'Keep-Alive',
    Accept => 'image/gif, image/jpeg, image/png, */*',
    Accept_Charset  => 'iso-8859-1,*,utf-8',
    Accept_Encoding => 'gzip',
    Accept_Language => 'de, en',
    Host => 'mascot',
    User_Agent => $browser,
    Content_Type => "multipart/form-data",
    );

# creates a new User Agent
my $ua = LWP::UserAgent::->new();

# create the URL object
my $url = new URI::URL("http://mascot/cgi/copyDB.cgi");

# sends the temporary database to mascot
my $resp = $ua->request(POST $url, @request_data, Content => [file   => ["$file"], name => 'Super', set => '1'],);

It is important, that the attribute Content_Type in @request_data is "multipart/form-data". You need this to send a file.

get_database

Author: Nicole de la Chaux