File: AttachList.py

package info (click to toggle)
moin 1.9.8-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 75,060 kB
  • ctags: 43,795
  • sloc: python: 118,348; java: 10,704; php: 2,374; perl: 1,572; xml: 371; makefile: 213; sh: 79; sed: 5
file content (27 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
    MoinMoin - AttachList Macro

    A macro to produce a list of attached files

    Usage: <<AttachList([pagename,mime_type])>>

    If pagename isn't set, the current pagename is used.
    If mime_type isn't given, all files are listed.

    @copyright: 2004 Jacob Cohen, Nigel Metheringham,
                2006-2013 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""

import re

from MoinMoin.action.AttachFile import _build_filelist

def macro_AttachList(macro, pagename=None, mime_type=u'*', search_term=u'.+'):
    # defaults if we don't get anything better
    if not pagename:
        pagename = macro.formatter.page.page_name
    filterfn = re.compile(search_term, re.U).search
    return _build_filelist(macro.request, pagename, 0, 1, mime_type=mime_type, filterfn=filterfn)