Tags:
create new tag
view all tags
Why does my webName variable include the path to the "view" script?

My install of Twiki (from the December 2000 zip) appears to have trouble extracting the correct webName from the URL - it includes the path to the view script too. I've a feeling I might have made a stupid error, or that it's connected with the $scriptSuffix - due to my hosting, I'm unable to test with out the suffix ".pl".

For example, the web "Main" comes out as "twiki/bin/view.pl/Main". This is then suffixed to $dataDir ("/home/sites/site4/users/andypryke/twiki/data") to give a filepath of "/home/sites/site4/users/andypryke/twiki/data/twiki/bin/view.pl/Main".

Any ideas why?

I've included all the details I could gather below. I'm no perl expert though.

  • TWiki version: "Version: 01 Dec 2000"
  • Web server: Apache
  • Server OS: "Cobalt Linux release 5.0 (Pacifica) Kernel 2.2.14C5 on an i586"
  • Perl version: "version 5.005_03 built for i386-linux"

My Variables

# variables that need to be changed when installing on a new server:
# ==================================================================
#                   /cgi-bin/view/Main/WebHome : link of TWiki icon in upper left corner :
# $wikiHomeUrl      = "http://your.domain.com/twiki";
$$wikiHomeUrl      = "http://www.AndyPryke.com/twiki";
#                   Host of TWiki URL :    (Example "http://myhost.com:123")
#$defaultUrlHost   = "http://your.domain.com";
$defaultUrlHost   = "http://www.andypryke.com";
#                   /cgi-bin : cgi-bin path of TWiki URL:
$scriptUrlPath    = "/twiki/bin";
#                   /p/pub : Public data path of TWiki URL (root of attachments) :
$pubUrlPath       = "/twiki/pub";
#                   Public data directory, must match $pubUrlPath :
#$pubDir           = "/home/httpd/twiki/pub";
$pubDir           = "/home/sites/site4/web/twiki/pub";

#                   Template directory :
#$templateDir      = "/home/httpd/twiki/templates";
$templateDir      = "/home/sites/site4/users/andypryke/twiki/templates";
#                   Data (topic files) root directory :
#$dataDir          = "/home/httpd/twiki/data";
$dataDir          = "/home/sites/site4/users/andypryke/twiki/data";

# variables that might need to be changed:
# ==================================================================
#                    : Suffix of TWiki Perl scripts (i.e. ".pl") :
$scriptSuffix     = ".pl";


Modifications to the view.pl main sub for debug output:
sub main
{
    my $thePathInfo = $query->path_info();
    my $theRemoteUser = $query->remote_user();
    my $theTopic = $query->param( 'topic' );
    my $theUrl = $query->url;
# ANP - remove this debug output
        print "Content-type: text/html\n\n";
    print "\$thePathInfo   =\"$thePathInfo\"
\n"; print "\$theRemoteUser =\"$theRemoteUser\"
\n"; print "\$theTopic =\"$theTopic\"
\n"; print "\$theUrl =\"$theUrl\"
\n"; ( $topic, $webName, $scriptUrlPath, $userName ) = &wiki::initialize( $thePathInfo, $theRemoteUser, $theTopic, $theUrl ); # ANP - Debug print block print "\$topic = \"$topic\"
\n"; print "\$webName = \"$webName\"
\n"; print "\$scriptUrlPath = \"$scriptUrlPath\"
\n"; print "\$userName = \"$userName\"
\n";

Results of debug output for http://www.andypryke.com/twiki/bin/view.pl/Main/WebHome

$thePathInfo ="/twiki/bin/view.pl/Main/WebHome"
Use of uninitialized value at /home/sites/site4/web/twiki/bin/view.pl line 41. $theRemoteUser =""
Use of uninitialized value at /home/sites/site4/web/twiki/bin/view.pl line 42. $theTopic =""
$theUrl ="http://www.andypryke.com"
$topic = "WebHome"
$webName = "twiki/bin/view.pl/Main"
$scriptUrlPath = "/twiki/bin"
$userName = "guest"
webName was"twiki/bin/view.pl/Main" 

(note webName is forced to "Main" just after this output in order that I actually get some web-page appearing).

-- AndyPryke - 11 Feb 2001

Answer

I managed to fix this by making the following modification (hack) to the wiki.pm script, I'd still like to know why I needed to do this, so we can give advice or a better fix to other new installers of Twiki.

Because this is a hack and I don't understand the underlying problem, I've left the SupportStatus Category as AskedQuestions.

*** wiki.pm.original     Wed Nov 15 01:22:14 2000
--- wiki.pm   Wed Feb 14 10:55:23 2001
***************
*** 137,142 ****
--- 137,146 ----
      # test if $thePathInfo is "/Webname/SomeTopic" or "/Webname/"
      if( ( $thePathInfo =~ /[\/](.*)\/(.*)/ ) && ( $1 ) ) {
          $webName = $1;
+         # Hack by AndyPryke@hotmail.com to remove "/twiki/bin/view.pl/" compon
ent.
+         $webName =~ /(.*)[\/](.*)/;
+         $webName = $2;
+
      } else {
          # test if $thePathInfo is "/Webname" or "/"
          $thePathInfo =~ /[\/](.*)/;

-- AndyPryke - 14 Feb 2001

> Results of debug output for
> http://www.andypryke.com/twiki/bin/view.pl/Main/WebHome
>
> $thePathInfo ="/twiki/bin/view.pl/Main/WebHome"

This should be "/Main/WebHome". Not sure why you get the full path. Is your /twiki/bin set as script executable? In case not I can imagine that you get the full path and not the script path info.

-- PeterThoeny - 24 Feb 2001

Just encountered the same problem again, this time with the 01-Sep-2001 release. The same hack fixed the problem, though the file to edit is now lib/TWiki.pm

The directory in question isn't script executable, my host uses cgi-wrap instead, and scripts such as "/bin/view" have been renamed "/bin/view.pl"

-- AndyPryke - 13 Nov 2001

I've posted a patch that should fix this, over on CobaltRaqInstall - let me know if it works.

-- RichardDonkin - 26 Feb 2002

Thanks Richard, I'll try it with my next install.

-- AndyPryke - 08 Mar 2002

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2002-03-08 - AndyPryke
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.