Tags:
create new tag
view all tags

Question

I'm writing a script (for TWiki 3.x) which will be run each month to generate some reports on user groups.

The first step in the process is to compile a list of all the Groups. I'm trying to use only the Func module, here's what I've got so far:

#!/usr/bin/perl
use TWiki;

print ".\n";
print &getListOfGroups;

sub getListOfGroups
{
    my $text = &TWiki::Func::expandCommonVariables('%SEARCH{"GROUP" topic="*Group" casesensitive="on" nosummary="on" nosearch="on" nonoise="on" noheader="on" nototal="on" format="\$web.\$topic"}%');

    my ( @list ) =  split ( /\n/, $text );
    return @list;
}

However, when I run this script, I receive the following error: Can't call method "replacePreferencesTags" on an undefined value at TWiki/Prefs.pm line 672.

I tried adding

$TWiki::Plugins::SESSION = new TWiki();
which gives me Can't locate object method "new" via package "TWiki" at ./UserVerificationEmailer.pl line 3.

Any ideas?

Thanks,

Brendan.

Environment

TWiki version: 3.x
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Linux
Web server: Apache
Perl version: 5.8.5
Client OS: Mixed
Web Browser: Firefox, IE
Categories: Search, Add-Ons

-- BrendanMarshall - 15 May 2007

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.

You need the proper initialization. Look for example at the bin/mailnotify script. Relevant part of Sep 2004 release:

BEGIN {
    # Set library paths in @INC at compile time
    unshift @INC, '.';
    require 'setlib.cfg';
}
use TWiki;
TWiki::basicInitialize();

-- PeterThoeny - 15 May 2007

Thanks for the quick response Peter.

After adding the appropriate initialization, I unfortunately still have the same error. The code is now:

#!/usr/bin/perl
BEGIN {
    # Set library paths in @INC at compile time
    unshift @INC, '.';
    require 'setlib.cfg';
}
use TWiki;

&TWiki::basicInitialize();

print &getListOfGroups;

sub getListOfGroups
{
    my $text = &TWiki::Func::expandCommonVariables('%SEARCH{"GROUP" topic="*Group" casesensitive="on" nosummary="on" nosearch="on" nonoise="on" noheader="on" nototal="on" format="\$web.\$topic"}%');

    my ( @list ) =  split ( /\n/, $text );
    return @list;
}

Error returned is:

Can't call method "replacePreferencesTags" on an undefined value at /var/www/html/twiki/lib/TWiki/Prefs.pm line 672.

-- BrendanMarshall - 16 May 2007

You might need to initialize it further. Again from mailnotify:

    my ( $topic, $webName, $dummy, $userName, $dataDir ) = 
        TWiki::initialize( "/Main", "nobody" );

-- PeterThoeny - 16 May 2007

Ah excellent it works now. Thanks for your help smile

-- BrendanMarshall - 16 May 2007

Change status to:
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2007-05-16 - BrendanMarshall
 
  • 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.