Attachment 'AllPagesWithACL.py'

Download

   1 # -*- coding: utf-8 -*-
   2 """
   3     MoinMoin - AllPagesWithACL Macro
   4 
   5     @copyright: 2007 Alexander "Loki" Agibalov
   6     @license: GNU GPL, see COPYING for details.
   7 
   8     changes:
   9         12.2007 - conversion to new syntax by Bolesław Kulbabiński
  10 """
  11 
  12 import os
  13 import re
  14 from MoinMoin.Page import Page
  15 from MoinMoin import wikiutil
  16 
  17 def getAcl(request, pagename):
  18     pg = Page(request, pagename)
  19     pi = pg.get_pi()
  20     ret = pi["acl"].getString()
  21     if ret == '':
  22         ret = "not defined"
  23     return ret
  24 
  25 
  26 def macro_AllPagesWithACL(macro, args):
  27     html = "<p><b>All pages:</b><br>"
  28     all = {}
  29     pages = macro.request.rootpage.getPageList()
  30 #   pages = macro.request.rootpage.getPageList(filter = re.compile("^WikiSandBox").match)
  31     html += "Total: %s pages </p>" % str(len(pages))
  32 
  33     for pagename in pages:
  34         all[Page(macro.request, pagename).link_to(macro.request)] = getAcl(macro.request, pagename)
  35 
  36     html += "<table>"
  37     all1 = sorted(all.items())
  38     for pg, ac in all1:
  39         html += "<tr><td>%s</td>" % pg
  40         html += "<td>%s</td></tr>" % ac
  41     html += "</table>"
  42 
  43     return macro.formatter.rawHTML(html)
  44 
  45 
  46 def execute(macro, args):
  47     try:
  48         return wikiutil.invoke_extension_function(
  49                    macro.request, macro_AllPagesWithACL, args, [macro])
  50     except ValueError, err:
  51         return macro.request.formatter.text(
  52                    "<<AllPagesWithACL: %s>>" % err.args[0])

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-12-22 23:47:40, 1.4 KB) [[attachment:AllPagesWithACL.py]]
  • [get | view] (2007-12-22 23:26:11, 2.2 KB) [[attachment:LostSoulsInGroups.py]]
  • [get | view] (2007-12-22 23:47:25, 3.9 KB) [[attachment:ManageUsers.py]]
  • [get | view] (2008-11-01 08:08:30, 3.0 KB) [[attachment:WikiLog.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.