changeset 5358:a5bd554abd87

xmlrpc: renamePage and deleteAttachment method added
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 08 Dec 2009 14:28:57 +0100
parents a7477cf9c536
children 92fdc2ecbad5
files MoinMoin/xmlrpc/__init__.py
diffstat 1 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/xmlrpc/__init__.py	Tue Dec 08 12:14:59 2009 +0100
+++ b/MoinMoin/xmlrpc/__init__.py	Tue Dec 08 14:28:57 2009 +0100
@@ -555,6 +555,25 @@
 
         return xmlrpclib.Boolean(1)
 
+    def xmlrpc_renamePage(self, pagename, newpagename):
+        """Renames a page to newpagename
+
+        @param pagename: the page name (unicode or utf-8)
+        @param newpagename: then new pagename (unicode or utf-8)
+        @rtype boolean
+        @return true on success
+        """
+        if not (self.request.user.may.delete(pagename) and self.request.user.may.write(newpagename)):
+            return xmlrpclib.Fault(1, "You are not allowed to rename this page")
+        editor = PageEditor(self.request, pagename)
+
+        try:
+            editor.renamePage(newpagename)
+        except PageEditor.SaveError, error:
+            return xmlrpclib.Fault(1, "Rename failed: %s" % (str(error), ))
+
+        return xmlrpclib.Boolean(1)
+
     def xmlrpc_revertPage(self, pagename, revision):
         """Revert a page to previous revision
 
@@ -981,9 +1000,26 @@
         AttachFile._addLogEntry(self.request, 'ATTNEW', pagename, attachname)
         return xmlrpclib.Boolean(1)
 
+    def xmlrpc_deleteAttachment(self, pagename, attachname):
+        """ Deletes attachment from pagename
+
+        @param pagename: pagename (utf-8)
+        @param attachname: attachment name (utf-8)
+        @rtype boolean
+        @return true on success
+        """
+        pagename = self._instr(pagename)
+
+        if not self.request.user.may.delete(pagename):
+            return xmlrpclib.Fault(1, 'You are not allowed to delete attachments on this page.')
+
+        attachname = wikiutil.taintfilename(attachname)
+        filename = AttachFile.getFilename(self.request, pagename, attachname)
+        AttachFile.remove_attachment(self.request, pagename, attachname)
+        return xmlrpclib.Boolean(1)
+
     # XXX END WARNING XXX
 
-
     def xmlrpc_getBotTranslations(self):
         """ Return translations to be used by notification bot