Mercurial > moin > 1.9
changeset 4050:6f6eed3818ed
merged moin/1.7 repo
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sun, 31 Aug 2008 01:14:34 +0200 |
parents | 0f1886933f80 (current diff) 49f330e9831a (diff) |
children | 63fbadea490e |
files | MoinMoin/request/__init__.py docs/CHANGES |
diffstat | 5 files changed, 114 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/request/__init__.py Sat Aug 30 22:56:01 2008 +0200 +++ b/MoinMoin/request/__init__.py Sun Aug 31 01:14:34 2008 +0200 @@ -1621,12 +1621,21 @@ # only execute finishers once self._finishers = [] - try: - #del self.user # keeping this is useful for testing - del self.theme - del self.dicts - except: - pass + for attr_name in [ + 'editlog', # avoid leaking file handles for open edit-log + 'theme', + 'dicts', + 'user', + 'rootpage', + 'page', + 'html_formatter', + 'formatter', + 'cfg', + ]: + try: + delattr(self, attr_name) + except: + pass def add_finisher(self, method): self._finishers.append(method)
--- a/MoinMoin/script/old/xmlrpc-tools/UpdateGroupTest.py Sat Aug 30 22:56:01 2008 +0200 +++ b/MoinMoin/script/old/xmlrpc-tools/UpdateGroupTest.py Sun Aug 31 01:14:34 2008 +0200 @@ -1,46 +1,83 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- +# -*- coding: iso-8859-1 -*- """ -This script is just an example how to update a group definition page using xmlrpc. + MoinMoin - client side of xmlrpc UpdateGroup functionality. + + You can use this code to update a group page in a target wiki via xmlrpc. + Of course you need to enable the xmlrpc service in the target wiki, see + your actions_excluded settings (by default, it contains 'xmlrpc')! -GPL software, 2005 Thomas Waldmann + @copyright: 2006-2008 MoinMoin:ThomasWaldmann + @license: GNU GPL, see COPYING for details. """ -def run(): - import sys - sys.path.insert(0, '../../..') +# convenience: fixup python path so script can be started from here: +import sys +sys.path.insert(0, '../../../..') + +import xmlrpclib - import xmlrpclib - from MoinMoin.support.BasicAuthTransport import BasicAuthTransport +# we have a fixed xmlrpc multicall implementation (in py 2.3 it was broken): +from MoinMoin.support.multicall import MultiCall + - user = "XmlRpc" - password = "wrong" - dsttrans = BasicAuthTransport(user, password) - mywiki = xmlrpclib.ServerProxy("http://master.moinmo.in/?action=xmlrpc2", transport=dsttrans) +def updateGroup(server_url, username, password, groupname, groupdesc, groupmembers, acl=''): + """ + Update a Wiki Group Page named <groupname> with a list of <groupmembers> via xmlrpc. + Contact the target wiki xmlrpc service at <server_url> and use <username> + and <password> to authenticate as wiki user there. - groupname = "TestGroup" - groupdesc = "This is just a test." - groupmembers = ["TestUser1", "TestUser2", ] - print mywiki.UpdateGroup(groupname, groupdesc, groupmembers) + @param server_url: xmlrpc service url of target wiki (str) + @param username: username used to authenticate at server_url wiki (unicode) + @param password: password of <username> (unicode) + @param groupname: group page name (unicode) + @param groupdesc: group description (unicode) + @param groupmembers: group member names (list of unicode) + @param acl: Access Control List value (optional, unicode) + @return: + """ + wiki = xmlrpclib.ServerProxy(server_url) + auth_token = wiki.getAuthToken(username, password) + assert auth_token, 'Invalid username/password' - groupname = "TestAclGroup" - groupdesc = "This is just a test." - groupmembers = ["TestUser3", ] - print mywiki.UpdateGroup(groupname, groupdesc, groupmembers, "All:read,write,delete,revert") + # Verify that the token is valid by using it + # and checking that the result is 'SUCCESS'. + # The token should be valid for 15 minutes. + assert wiki.applyAuthToken(auth_token) == 'SUCCESS' - del mywiki - del dsttrans + try: + # build a multicall object that + mcall = MultiCall(wiki) + # first applies the token and + mcall.applyAuthToken(auth_token) + # then creates/updates the group page + mcall.UpdateGroup(groupname, groupdesc, groupmembers, acl) + # now execute the multicall + results = mcall() - user = "XmlRpc" - password = "completelywrong" - dsttrans = BasicAuthTransport(user, password) - mywiki = xmlrpclib.ServerProxy("http://master.moinmo.in/?action=xmlrpc2", transport=dsttrans) - - groupname = "TestGroup" - groupdesc = "This is just a test." - groupmembers = ["WrongUser1", "WrongUser2", ] - print mywiki.UpdateGroup(groupname, groupdesc, groupmembers) + # everything should have worked + # instead of the asserts you can have anything else + # but you should definitely access all the results + # once so that faults are checked and raised + assert results[0] == 'SUCCESS' + # TODO: process other results / xmlrpc faults + finally: + # be nice to the server and clean up the token + # regardless of what happened + assert wiki.deleteAuthToken(auth_token) == 'SUCCESS' if __name__ == "__main__": - run() + # xmlrpc url of target wiki, where the group pages shall get created + server_url = "http://master.moinmo.in/?action=xmlrpc2" + # user and password of a wiki user of the target wiki with enough priviledges + username = "ThomasWaldmann" + password = "wrong" + # data for the group page: + groupname = u"TestGroup" + groupdesc = u"Just a test group" + groupmembers = [u'JoeDoe', u'JaneDoe', ] + acl = "All:read,write,delete" # optional, can be empty + + updateGroup(server_url, username, password, groupname, groupdesc, groupmembers, acl) +
--- a/MoinMoin/support/tarfile.py Sat Aug 30 22:56:01 2008 +0200 +++ b/MoinMoin/support/tarfile.py Sun Aug 31 01:14:34 2008 +0200 @@ -1053,22 +1053,21 @@ can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ - self.name = os.path.abspath(name) - if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") self._mode = mode self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] if not fileobj: - fileobj = file(self.name, self.mode) + fileobj = file(name, self.mode) self._extfileobj = False else: - if self.name is None and hasattr(fileobj, "name"): - self.name = os.path.abspath(fileobj.name) + if name is None and hasattr(fileobj, "name"): + name = fileobj.name if hasattr(fileobj, "mode"): self.mode = fileobj.mode self._extfileobj = True + self.name = name and os.path.abspath(name) or None self.fileobj = fileobj # Init datastructures
--- a/MoinMoin/xmlrpc/UpdateGroup.py Sat Aug 30 22:56:01 2008 +0200 +++ b/MoinMoin/xmlrpc/UpdateGroup.py Sun Aug 31 01:14:34 2008 +0200 @@ -55,7 +55,7 @@ logging.debug("saveText msg: %s" % msg) #we need this to update pagelinks cache: - self.request.args = self.request.form = self.request.setup_args({}) + self.request.args = self.request.form = self.request.setup_args() self.request.redirectedOutput(page.send_page, content_only=1) return xmlrpclib.Boolean(1)
--- a/docs/CHANGES Sat Aug 30 22:56:01 2008 +0200 +++ b/docs/CHANGES Sun Aug 31 01:14:34 2008 +0200 @@ -88,6 +88,31 @@ by a autocreate=<boolean> parameter of the auth objects that support user profile auto creation. + +Version 1.7.current: + Fixes: + * Fix leakage of edit-log file handles (leaked 1 file handle / request!). + * Wiki parser: avoid IndexError for empty #! line + * MonthCalendar macro: fix parameter parsing / url generation + * Xapian indexing filters (MoinMoin/filter/ or data/plugin/filter/): + Some indexing filter scripts (e.g. for MS Word documents or PDF files) + failed on windows because of the single-quote quoting we used (that + works on Linux and other Posix systems). The fix introduces platform- + dependant automatic quoting, using double-quotes on win32 and single- + quotes on posix. + HINT: if you use own filter plugins based on execfilter, you have to + update them as the filename quoting (was '%s') is now done automatically + and must not be part of the command string any more (now just use %s). + See MoinMoin/filter/ for some up-to-date code (esp. the PDF filter). + * Prevent CategoryTemplate being listed as a category (it is a Template, + but matched also the category regex) - added to sample wikiconfig. + * LDAP auth: fix processing of TLS options + * UpdateGroup xmlrpc server side: fix wrong arg count error + * UpdateGroup client: use multicall / auth_token, refactor code so that + updateGroup function is reusable. + * Improve Python 2.3 compatibility, add notes where 2.4 is required. + + Version 1.7.1: New features: * New 'cache' action (see developer notes).