http://qs321.pair.com?node_id=113504


in reply to Re: Re: HowTo build and distribute a PPMed module for Win32
in thread HowTo build and distribute a PPMed module for Win32

I have ActivePerl 629 - which I compiled, so PPM would be the one that comes with build 628.

I'll try on some other machines and see what happens. But I was looking through the PPM.pm source and it implies that repositories can have "Summary" files. These summaries somehow aid the search routines. I am guessing that PPM::SOAPServer is a SOAP service that acts as the repository and searches the PPD files returning descriptions etc that match the search. But maybe I have the wrong end of the stick!

Simon Flack ($code or die)
$,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
=~y'_"' ';eval"die";print $_,lc substr$@,0,3;

Replies are listed 'Best First'.
Re: Re: Re: Re: HowTo build and distribute a PPMed module for Win32
by idnopheq (Chaplain) on Sep 20, 2001 at 04:13 UTC
    IIRC, this bit of magic is done via XML::Simple and a simple looking for ppd files fuzzily matching the file name based on the search criteria and the listed repositories. I'm on a Win95 box <sympathy is appreciated> w/o anything remotely perlish installed, so I cannot show the output of my PPM.

    I would not, however, deny that the modules I have or the site is w/o flaws. If it is, lemme know. I claim to be no expert, tho I play one on TV.

    Oh! You know what! I have "multi-threaded" in the ppd files, which I dunno if the Siemen's port compiles as such. Thus, you may not see it! Hmmmmm ... Try grabbing the ppd and tar.gz and edit the ppd file - removing the line w/ "multi-threaded" on it ... wonder if it will search that way ( using the --location path or URL in the search command ) ...

    UPDATE: I have heard a while back that ActiveState was ditching SOAP in PPM, but I see now that that is incorrect. SOAP is used in the search capability, so no I head out and find how to set up the SOAP server piece ... MY BAD!

    HTH
    --
    idnopheq
    Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

      Right, I have been re-reading PPM.pm and understand how the search command works.

      When you do search Module-Name, it run's the function list_available(). This function returns a list of .ppd files in the repository. It does it differently depending on what type of repository it is, e.g.: file://, UNC, SOAP, or http://. We're interested in the last bit of the function concerning http.

      If the repository is an http:// repository (not soap), then it calls the function read_href() which returns the text on the page. list_available() expects either a directory listing (Apache or IIS format) or a default.prk format file - ActiveState's Visual Package Manager that's part of the Perl Dev Kit.

      For the search to work properly (without implimenting a SOAP interface or .prk) your repository must return something that resembles a directory listing, which PPM.pm parses.

      Thankfully, PPM.pm keeps the "libwww-perl/" part of the user agent. So we can write a small script that will return a directory listing for ppm and a nicely formatted page for regular browsers. This is a small working example of what to do:
      use strict; use CGI qw( :all ); my $user_agent = user_agent(); my $html_redirection = 'http://127.0.0.1/index.htm'; if ($user_agent =~ m#libwww-perl/#) { # it's a perl bot - probably ppm, so return a # compatible directory listing print_dir_listing(); } else { # it's probably a regular browser, redirect... print redirect(-uri => $html_redirection); } sub print_dir_listing { # Get the current directory, (cwd doesn't necessarily work in IIS) (my $cwd = $0) =~ s[\\][/]g; $cwd =~ s[/([^/]*)$][]; print header({-type => "text/plain"}); opendir FOLDER, $cwd or die "I don't have permission $!"; print a({-href => $_}, $_ ), "\n" for grep { /\.ppd$/ } readdir FO +LDER; closedir FOLDER; }
      Save this to index.pl or something and make sure it's the default document. Then change $html_redirection variable to the URL where you want your actual users to go to and you're set. You can of course do something more dynamic for the actual users page, such as parse the XML in the PPD files to give user's full information on the modules (version, description, author etc) without having to edit an html file every time you change a package or add a new one. I leave that as an exercise for the reader :)

      Simon Flack ($code or die)
      $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
      =~y'_"' ';eval"die";print $_,lc substr$@,0,3;