Attachment 'purge.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Purge Action
4
5 Deletes a page completely form disc. You need be superuser
6 to call this action. Superuser is assumed to be a trusted
7 user which has read, write, delete, revert and admin rights.
8
9 @copyright: 2006 by Oliver Siemoneit
10 @license: GNU GPL, see COPYING for details.
11
12 Changes:
13
14 Version 1.1 by Oliver Siemoneit
15 * Macro now supports multilang if translations for
16 'Purge: "%s"'
17 'You cannot purge existing pages. You have to delete them first.'
18 'Page has not been removed.'
19 'Page successfully removed.'
20 'Page does not exist.'
21 are provided elsewhere.
22
23 """
24
25 import os
26 from MoinMoin.Page import Page
27 from MoinMoin import wikiutil
28
29
30 def execute(pagename, request):
31 _ = request.getText
32
33 # Check if user is superuser
34 if not request.user.isSuperUser():
35 result = _('You are not allowed to perform this action.')
36
37 # Check if page exists
38 elif Page(request, pagename).exists() == True:
39 result = _('You cannot purge existing pages. You have to delete them first.')
40
41 else:
42 pagedir = Page(request, pagename).getPagePath(use_underlay=0, check_create=0)
43 if os.path.exists(pagedir):
44 import shutil
45 try:
46 shutil.rmtree(pagedir)
47 except EnvironmentError:
48 result = _('Page has not been removed.')
49 else:
50 result = _('Page successfully removed.')
51 else:
52 result = _('Page does not exist.')
53
54 Page(request, pagename).send_page(request, result)
55
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.You are not allowed to attach a file to this page.