Question: Where should perl scripts be placed if I want to access them through AJAX?
I was thinking of developing a plugin using
AJAX. If I wanted to call a perl script on the server, where should I put it? I was assuming it would be under /lib/TWiki/Plugins/MyPlugin/..., but access is forbidden. Have I got my server set up wrong or is there a better place to put it, like under bin/?
--
Contributors: AndrewRJones - 30 Mar 2007
Discussion
Only the
twiki/bin/ directory is cgi-bin enabled, so that is a logical choice. We have a recommended places to store plugin internal data (see
TWikiPlugins, and for plugin code (in/below
twiki/lib/TWiki/Plugins/), but we do not yet have a standard for additional cgi-bin scripts. I think the important part is make the script identifyable. For example, if you work on a
CoolPlugin, your scripts could be in
twiki/bin/CoolPlugin/.
--
PeterThoeny - 30 Mar 2007
I think that the
REST interface of TWiki can be used for that purpose while not requiring a separate file in
twiki/bin - just use
twiki/bin/rest/YourPlugin/..., implement the corresponding plugin handler, and in your plugin's
initPlugin routine register it with
TWiki::Func::registerRESTHandler('example', \&restExample);. However, the documentation at
TWikiScripts is not really what I'd call inviting (the example fails with a code 500).
For simple uses,
MiniAhah is using the
view script to do
AJAX stuff with the help of auxiliary topic (which could be simplified since TWiki 4.1 where
section can be used as a parameter to
view).
--
HaraldJoerg - 30 Mar 2007
Using the
bin/rest script is a very good option. We really need a good supplemental document called
RestScriptCookbook that explains how to create
REST enabled apps in TWiki.
If you use the
view script, make sure to use the
viewauth script instead for sites that use basic authentication.
The desired action via
viewauth script can be achieved with URL parameters to the current topic (such as saving a table when using the
EditTablePlugin), or with auxiliary topics as Harald pointed out (such as creating a new tag in the
TagMePlugin).
--
PeterThoeny - 30 Mar 2007