• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5378: Allow filtering of attachments by pattern

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension AttachmentListPlugin Enhancement Closed   n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


I find it very useful to restrict the list of files based on a pattern, which I pass via a parameter call regexp:
my $regexp = $params->{'regexp'};

This pattern is used to drop out of the main loop. I currently force case-insensitivity, but maybe this should be parameterized.

if (defined $regexp){

next unless ($filename=~/$regexp/i );


Could this, or something similar, be added to the standard plugin?

-- TWiki:Main/JohnFitzpatrick - 20 Feb 2008

Implemented with version 1.2, but without case-insensitive attribute, because people might want to search on case (for instance all files starting with an uppercase).

Changes: Added parameter includefilepattern and formatting parameter $fileExtension. When using parameter sort the files are now secondary sorted on filename. Added decoding of format tokens.

-- TWiki:Main.ArthurClemens - 20 Feb 2008

Thanks Arthur!

A quick google search has taught me how to specify case-insensitivity within the regular expression: I just have to add a (?i) to the start of the expression. Perhaps you could add this as an example: very useful for people like me who work in a Windows environment!

-- TWiki:Main.JohnFitzpatrick - 21 Feb 2008

Hmm, I'm getting this error:

Undefined subroutine &TWiki::Plugins::AttachmentListPlugin::_expandStandardEscapes called

Do I need to be using TWiki 4.2?

-- TWiki:Main.JohnFitzpatrick - 21 Feb 2008

Thanks for the regex tip. I have included it in an example and fixed the bug.

-- TWiki:Main.ArthurClemens - 21 Feb 2008


I'm getting the following error on 4.1.2 and on 4.2. Any ideas what I'm doing wrong?

Bad index while coercing array into hash at /compnew/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154.
 at /compnew/lib/TWiki/Plugins/AttachmentListPlugin.pm line 154
 TWiki::Plugins::AttachmentListPlugin::handleFileList('TWiki=HASH(0x10030e4c)', 'TWiki::Attrs=HASH(0x113f89b4)', 'AutolivIcons', 'Main', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki/Func.pm line 2231
 TWiki::Func::__ANON__('TWiki=HASH(0x10030e4c)', 'TWiki::Attrs=HASH(0x113f89b4)', 'AutolivIcons', 'Main', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki.pm line 2661
 TWiki::_expandTagOnTopicRendering('TWiki=HASH(0x10030e4c)', 'FILELIST', ..., 'AutolivIcons', 'Main', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki.pm line 2582
 TWiki::_processTags('TWiki=HASH(0x10030e4c)', '   * CompOrg-16.gif: <br />\x{a}     <img src="%ATTACHURLPATH%/Co...', 'CODE(0x102e4e00)', 16, 'AutolivIcons', 'Main', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki.pm line 2506
 TWiki::expandAllTags('TWiki=HASH(0x10030e4c)', 'SCALAR(0x102f56ac)', 'AutolivIcons', 'Main', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki.pm line 2858
 TWiki::handleCommonTags('TWiki=HASH(0x10030e4c)', '   * CompOrg-16.gif: <br />\x{a}     <img src="%ATTACHURLPATH%/Co...', 'Main', 'AutolivIcons', 'TWiki::Meta=HASH(0x1103f10c)') called at /compnew/lib/TWiki/UI/View.pm line 396
 TWiki::UI::View::_prepare('   * CompOrg-16.gif: <br />\x{a}     <img src="%ATTACHURLPATH%/Co...', 'TWiki=HASH(0x10030e4c)', 'Main', 'AutolivIcons', 'TWiki::Meta=HASH(0x1103f10c)', 0) called at /compnew/lib/TWiki/UI/View.pm line 377
 TWiki::UI::View::view('TWiki=HASH(0x10030e4c)') called at /compnew/lib/TWiki/UI.pm line 159
 TWiki::UI::__ANON__() called at /usr/lib/perl5/5.8/Error.pm line 387
 eval {...} called at /usr/lib/perl5/5.8/Error.pm line 379
 Error::subs::try('CODE(0x10030e1c)', 'HASH(0x11090e68)') called at /compnew/lib/TWiki/UI.pm line 197
 TWiki::UI::run('CODE(0x1036d1d4)', 'view', 1) called

I can't reproduce this error, but I will change back the way the array of FileData objects is referenced.

-- TWiki:Main.ArthurClemens - 21 Feb 2008

Another try, version 1.2.3.

-- TWiki:Main.ArthurClemens - 21 Feb 2008

Thanks Arthur! I've opened another enhancement request, due to some problems putting ATTACHMENTLIST in a table. I think I know why: see Item5378

-- TWiki:Main.JohnFitzpatrick - 22 Feb 2008

Summary Allow filtering of attachments by pattern
ReportedBy TWiki:Main.JohnFitzpatrick
Codebase 4.1.2
SVN Range TWiki-5.0.0, Wed, 23 Jan 2008, build 16283
AppliesTo Extension
Component AttachmentListPlugin
Priority Enhancement
CurrentState Closed

Checkins TWikirev:16432 TWikirev:16434 TWikirev:16437 TWikirev:16438
TargetRelease n/a

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2008-02-22 - JohnFitzpatrick
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback