Tags:
create new tag
, view all tags

Question

I have problem with saving of topics in my perl script.

reading of topics (no problem...) :
$text = TWiki::Func::ReadTopicText($web,$topic);

$text modified somehow...

and saving :
TWiki::Func::saveTopicText($web,$topic,$text,'1');
> Access to CHANGE ... for TwikiGuest ... is Denied

1) How twiki functions find out the name of user which operate with Twiki::func functions ? I anticipate that $session variable do this but i would like to see some pieces of code... how initialize $session in perl script ?

alternative - 2) Is possible use some Twiki function which is able to save topics and ignore permission settings (and using RCS system) ?

This script will start every night and actualize some topics (user topics&groups - ldap synchronize, and topics on the Project web - synchronize some data from database etc..).

thank you

Environment

TWiki version: TWikiRelease04x00x05
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: debian etch
Web server: apache
Perl version:  
Client OS:  
Web Browser:  
Categories: Permissions, Documentation, Contributing code

-- MartinVich - 30 Jan 2007

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

If you can, then use the TWiki::Func API from the context of a plugin, which sets up the session for you.

If you are writing a stand-alone script, you can take inspiration from a range of Contribs that build sessions (such as MailInContrib, PublishContrib etc) or simply review the code of tick_twiki.pl in the tools directory. The API of the Store module provides methods for reading and writing topics. However i strongly recommend you do not use internal APIs, as they are subject to change.

If you want to use TWiki::Func methods from a perl script, then you have to fool TWiki into thinking you are callling them from a Plugin. You can so this by setting $TWiki::Plugins::SESSION to point to the TWiki object, e.g.

   my $session = new TWiki();
   $TWiki::Plugins::SESSION = $session;
   ... can now call TWiki::Func methods ...

-- CrawfordCurrie - 21 Feb 2007

I got the same problem but for Twiki03. But can't do my $session = new TWiki(); what tips do you have for me?

-- JonathanDorling - 22 Nov 2007

How about "upgrade to TWiki 4.0" (bet you saw that one coming wink )

-- CrawfordCurrie - 24 Nov 2007

Closing this support question after more than 30 days of inactivity. Please feel free to re-open if needed.

-- PeterThoeny - 01 Jan 2008

If you want your external script to execute as if it was run by the authorized user you can initialize your session like this:

   my $session = new TWiki( "TWikiName");
   $TWiki::Plugins::SESSION = $session;
   ... can now call TWiki::Func methods ...

-- AndrewTutolmin - 24 Jan 2008

 
Change status to:
Topic revision: r6 - 2008-01-24 - AndrewTutolmin
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.