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
--
BramVanOosterhout - 06 Nov 2006
Answer
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
- a perl function defined
- 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