changeset 93:efce6cdc8237

script/maint/modified_systemitems cli script replaces macro EditedSystemPages
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 07 Mar 2011 20:45:28 +0100
parents 5ff01f07c67c
children 990fdbe2d52c
files MoinMoin/macro/EditedSystemPages.py MoinMoin/script/__init__.py MoinMoin/script/maint/modified_systemitems.py
diffstat 3 files changed, 45 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/EditedSystemPages.py	Mon Mar 07 20:40:19 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright: 2004 Nir Soffer <nirs@freeshell.org>
-# Copyright: 2008,2011 MoinMoin:ThomasWaldmann
-# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
-
-"""
-EditedSystemPages - list system pages that has been edited in this wiki.
-"""
-
-
-from flask import flaskg
-
-from MoinMoin.macro._base import MacroPageLinkListBase
-from MoinMoin.items import IS_SYSITEM
-from MoinMoin.storage.error import NoSuchRevisionError
-
-class Macro(MacroPageLinkListBase):
-    def macro(self, content, arguments, page_url, alternative):
-        edited_sys_items = []
-        for item in flaskg.storage.iteritems():
-            try:
-                rev = item.get_revision(-1)
-            except NoSuchRevisionError:
-                continue
-            is_sysitem = rev.get(IS_SYSITEM, False)
-            if is_sysitem:
-                version = rev.get(SYSITEM_VERSION)
-                if version is None:
-                    # if we don't have the version, it was edited:
-                    edited_sys_items.append(item.name)
-
-        # Format as numbered list, sorted by item name
-        edited_sys_items.sort()
-
-        return self.create_pagelink_list(edited_sys_items, ordered=True)
-
--- a/MoinMoin/script/__init__.py	Mon Mar 07 20:40:19 2011 +0100
+++ b/MoinMoin/script/__init__.py	Mon Mar 07 20:45:28 2011 +0100
@@ -32,6 +32,8 @@
     manager.add_command("maint_set_meta", Set_Meta())
     from MoinMoin.script.maint.create_item import Create_Item
     manager.add_command("maint_create_item", Create_Item())
+    from MoinMoin.script.maint.modified_systemitems import Modified_SystemItems
+    manager.add_command("maint_modified_systemitems", Modified_SystemItems())
     from MoinMoin.script.maint.xml import XML
     manager.add_command("maint_xml", XML())
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/maint/modified_systemitems.py	Mon Mar 07 20:45:28 2011 +0100
@@ -0,0 +1,43 @@
+# Copyright: 2004 Nir Soffer <nirs@freeshell.org>
+# Copyright: 2008,2011 MoinMoin:ThomasWaldmann
+# Copyright: 2011 MoinMoin:ReimarBauer
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+    MoinMoin - list system items that has been edited in this wiki.
+
+"""
+
+
+from flask import current_app as app
+from flaskext.script import Command
+from MoinMoin.items import IS_SYSITEM, SYSITEM_VERSION
+from MoinMoin.storage.error import NoSuchRevisionError
+
+class Modified_SystemItems(Command):
+    description = 'This command can be used to list system items that has been edited in this wiki.'
+
+    def run(self):
+        storage = app.unprotected_storage
+        edited_sys_items = []
+        for item in storage.iteritems():
+            try:
+                rev = item.get_revision(-1)
+            except NoSuchRevisionError:
+                continue
+            is_sysitem = rev.get(IS_SYSITEM, False)
+            if is_sysitem:
+                version = rev.get(SYSITEM_VERSION)
+                if version is None:
+                    # if we don't have the version, it was edited:
+                    edited_sys_items.append(item.name)
+
+        # Format as numbered list, sorted by item name
+        edited_sys_items.sort()
+        if edited_sys_items:
+            print "Edited system items:"
+            for item_name in edited_sys_items:
+                print item_name
+        else:
+            print "Not any modified system items found!"
+