Tags:
create new tag
view all tags

Question

I am writing an add on. And Ihave a problem getting the parameters from the url.

I use

$TWiki::Plugins::SESSION = new TWiki();

early in the script. And things like template and page retrieval work fine.

If I use

$query = new CGI();

the parameters are retrieved properly and the addon runs successfully.

But I expected to be able to use

$query = TWiki::Func::getCgiQuery();

. However, that construct does not return anything in the $query.

I am missing something obvious, but I don't see it. An earlier question (DocumentationHowToWriteAddOnInTWiki4) is related and mostly resolved. Please help.

Environment

TWiki version: TWikiRelease04x00x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Linux: Debian
Web server: Apache/1.3.27 (Unix) Debian GNU/Linux PHP/4.3.3RC3 mod_ssl/2.8.14 OpenSSL/0.9.7b
Perl version: 5.8...4
Client OS: Linux debian
Web Browser: Firefox 1...5
Categories: Add-Ons

-- BramVanOosterhout - 06 Nov 2006

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

If your add on is running in a CGI environment then you need to explicitly pass the CGI query when creating the TWiki object. Otherwise TWiki.pm will create an empty query for you.

Try something like:

$TWiki::Plugins::SESSION = new TWiki($ENV{REMOTE_USER},CGI->new());
...
$query = TWiki::Func::getCgiQuery();

-- HaraldJoerg - 06 Nov 2006

the other option is to avoid writing yet another cgi script that creates another security attack point, and instead make a RestHandler. This can then be called from the rest cgi script.

-- SvenDowideit - 07 Nov 2006

Haralds suggestion worked for me.

Sven: I am too much of a novice to understand what you mean. I had a look at the doco at: TWiki.TWikiScripts#rest.

Is there more documentation about this?

-- BramVanOosterhout - 08 Nov 2006

Unfortunately not at this time. We need a SupplementalDocument on how to use the REST interface in TWiki.

-- PeterThoeny - 08 Nov 2006

Bram, the most detailed docco for rest is actuall in the EmptyPlugin stub - you need 2 things

  1. a perl function defined
  2. to call registerRestHandler from your initPlugin.
see the example in the EmptyPlugin for correct spellings and function prototypes.

-- SvenDowideit - 08 Nov 2006

Peter and Sven,

Thanks for the pointers. I think I see enough to give the rest handler a shot. And it looks as if it will be a lot neater.

-- BramVanOosterhout - 09 Nov 2006

Change status to:
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2006-11-09 - BramVanOosterhout
 
  • 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.