# HG changeset patch # User Paul Boddie # Date 1383754830 -3600 # Node ID d8385e3c215f82801cfc63e19599244fdf035acb # Parent ca135dc4597085da04e7db4ae615ea9855fb7315 Added usage of MoinSupport for common extension functionality. diff -r ca135dc45970 -r d8385e3c215f ApproveChangesSupport.py --- a/ApproveChangesSupport.py Tue Nov 05 23:19:02 2013 +0100 +++ b/ApproveChangesSupport.py Wed Nov 06 17:20:30 2013 +0100 @@ -18,6 +18,7 @@ from MoinMoin.Page import Page from MoinMoin.PageEditor import PageEditor from MoinMoin.wikiutil import escape +from MoinSupport import Form, ActionSupport, get_form, escattr, groupHasMember import re __version__ = "0.2" @@ -44,7 +45,7 @@ def is_reviewer(request): return request.user.valid and ( - has_member(request, get_page_reviewers_group(request), request.user.name) or \ + groupHasMember(request, get_page_reviewers_group(request), request.user.name) or \ request.user.isSuperUser()) def is_approved(request): @@ -53,7 +54,7 @@ request.user.isSuperUser()) def user_is_approved(request, username): - return has_member(request, get_approved_editors_group(request), username) + return groupHasMember(request, get_approved_editors_group(request), username) def is_queued_changes_page(request, pagename): @@ -206,57 +207,4 @@ page.saveText(body, 0, comment=_("Added %s to the approved editors group.") % username) -# Utility classes and associated functions. -# NOTE: These are now present in MoinSupport which should be used in future. - -class Form: - - """ - A wrapper preserving MoinMoin 1.8.x (and earlier) behaviour in a 1.9.x - environment. - """ - - def __init__(self, form): - self.form = form - - def get(self, name, default=None): - values = self.form.getlist(name) - if not values: - return default - else: - return values - - def __getitem__(self, name): - return self.form.getlist(name) - -class ActionSupport: - - """ - Work around disruptive MoinMoin changes in 1.9, and also provide useful - convenience methods. - """ - - def get_form(self): - return get_form(self.request) - -def get_form(request): - - "Work around disruptive MoinMoin changes in 1.9." - - if hasattr(request, "values"): - return Form(request.values) - else: - return request.form - -def escattr(s): - return escape(s, 1) - -# More Moin 1.9 compatibility functions. - -def has_member(request, groupname, username): - if hasattr(request.dicts, "has_member"): - return request.dicts.has_member(groupname, username) - else: - return username in request.groups.get(groupname, []) - # vim: tabstop=4 expandtab shiftwidth=4 diff -r ca135dc45970 -r d8385e3c215f README.txt --- a/README.txt Tue Nov 05 23:19:02 2013 +0100 +++ b/README.txt Wed Nov 06 17:20:30 2013 +0100 @@ -131,6 +131,8 @@ Recommended Software -------------------- +See the "Dependencies" section below for essential software. + The moinsetup tool is recommended for installation since it aims to support all versions of MoinMoin that are supported for use with this software. @@ -152,6 +154,17 @@ Copyright and licence information can be found in the docs directory - see docs/COPYING.txt and docs/LICENCE.txt for more information. +Dependencies +------------ + +ApproveChanges has the following basic dependencies: + +Packages Release Information +-------- ------------------- + +MoinSupport Tested with 0.4.2 + Source: http://hgweb.boddie.org.uk/MoinSupport + New in ApproveChanges 0.2 (Changes since ApproveChanges 0.1.1) -------------------------------------------------------------- @@ -159,6 +172,7 @@ * Removed the special ApprovalQueueUser. This user can be removed from existing installations since the software no longer needs it to perform the queuing of unapproved contributions. + * Added usage of MoinSupport for common extension functionality. New in ApproveChanges 0.1.1 (Changes since ApproveChanges 0.1) --------------------------------------------------------------