SID-01492: Calling TWiki::Func functions from outside of TWiki
| Status: |
Answered |
TWiki version: |
5.1.1 |
Perl version: |
Perl 5.10.1 from OpenCSW |
| Category: |
CategoryAPI |
Server OS: |
Oracle Solaris 10, 8/11 u10 |
Last update: |
13 years ago |
Hi,
Is there any way I can call functions in the
TWikiFuncDotPm class from an external script? In particular, some seem to require a session variable (ie. TWiki::Func::getTopicList), and I can't see how to call that function from a script that's run outside of TWiki, ie. via cron job on the server.
Thanks!
- John
--
JohnIRoberts - 2012-06-25
Discussion and Answer
You need to initialize the command line script properly. Study
twiki/bin/statistics which runs in CLI (command line interface) and CGI mode. The action of the script is done by module
TWiki/UI/Statistics.pm.
There is one detail you need to take care of: You need to tie the script to the module. In the statistics case it is defined in
TWiki/UI.pm:
$TWiki::cfg{SwitchBoard}{statistics} =
[ 'TWiki::UI::Statistics', 'statistics', { statistics => 1 } ];
For your own script you can define this in your own script before you call
$TWiki::engine->run();
--
PeterThoeny - 2012-06-26
Ah excellent, I've got it working now. Thank you very much!
--
JohnIRoberts - 2012-06-26
Good. Please consider contributing code back to the community. You could package this as an add-on, see
AddOnPackageHowTo.
--
PeterThoeny - 2012-06-26
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.