changeset 529:db71033db140

xmlrpc.getPackage: This plugin gets a page and all its attachments as MoinMoin Package file.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 21 May 2010 19:12:49 +0200
parents a39542a85f10
children 78ca2464edf9
files data/plugin/xmlrpc/getPackage.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/xmlrpc/getPackage.py	Fri May 21 19:12:49 2010 +0200
@@ -0,0 +1,25 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - get a page with attachments as MoinMoin Package
+
+    @copyright: 2010 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import cStringIO
+from MoinMoin import wikiutil
+from MoinMoin.action.PackagePages import PackagePages
+from MoinMoin.packages import unpackLine
+
+def execute(xmlrpcobj, pagename, include_attachments = True):
+    """
+    gets a Package from a page(s) with all attachments
+    @param pagename: name of page(s)
+    @param include_attachments: with attachments
+    """
+    request = xmlrpcobj.request
+    pagelist = pagename
+    packagename = "%s.zip" % pagename
+    target = wikiutil.taintfilename(packagename)
+    filelike = cStringIO.StringIO()
+    package = PackagePages(pagename, request).collectpackage(unpackLine(pagelist, ","), filelike, target, include_attachments)
+    return xmlrpcobj._outlob(filelike.getvalue())