paul@120 | 1 | diff -r d0f5d4b70647 MoinMoin/packages.py |
paul@120 | 2 | --- a/MoinMoin/packages.py Sat Jul 20 00:03:25 2013 +0200 |
paul@120 | 3 | +++ b/MoinMoin/packages.py Fri Nov 01 21:04:48 2013 +0100 |
paul@117 | 4 | @@ -96,6 +96,10 @@ |
paul@101 | 5 | """ |
paul@101 | 6 | return (string.lower() in ('yes', 'true', '1')) |
paul@117 | 7 | |
paul@101 | 8 | +class IAmRoot(object): |
paul@101 | 9 | + def __getattr__(self, name): |
paul@101 | 10 | + return lambda *args, **kwargs: True |
paul@117 | 11 | + |
paul@101 | 12 | class ScriptEngine: |
paul@101 | 13 | """ |
paul@117 | 14 | The script engine supplies the needed commands to execute the installation |
paul@119 | 15 | @@ -118,7 +122,7 @@ |
paul@119 | 16 | self.msg = getattr(self, "msg", "") |
paul@119 | 17 | self.request = getattr(self, "request", None) |
paul@119 | 18 | |
paul@119 | 19 | - def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""): |
paul@119 | 20 | + def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u"", mtime=None): |
paul@119 | 21 | """ |
paul@119 | 22 | Installs an attachment |
paul@119 | 23 | |
paul@119 | 24 | @@ -133,7 +137,7 @@ |
paul@119 | 25 | filename = wikiutil.taintfilename(filename) |
paul@119 | 26 | zipname = wikiutil.taintfilename(zipname) |
paul@119 | 27 | target = os.path.join(attachments, filename) |
paul@119 | 28 | - page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author) |
paul@119 | 29 | + page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author, mtime=mtime) |
paul@119 | 30 | rev = page.current_rev() |
paul@119 | 31 | path = page.getPagePath(check_create=0) |
paul@119 | 32 | if not os.path.exists(target): |
paul@117 | 33 | @@ -286,7 +290,7 @@ |
paul@117 | 34 | |
paul@117 | 35 | self.msg += package.msg |
paul@117 | 36 | |
paul@117 | 37 | - def do_addrevision(self, filename, pagename, author=u"Scripting Subsystem", comment=u"", trivial=u"No"): |
paul@117 | 38 | + def do_addrevision(self, filename, pagename, author=u"Scripting Subsystem", comment=u"", trivial=u"No", mtime=None): |
paul@117 | 39 | """ Adds a revision to a page. |
paul@117 | 40 | |
paul@117 | 41 | @param filename: name of the file in this package |
paul@120 | 42 | @@ -298,7 +302,7 @@ |
paul@96 | 43 | _ = self.request.getText |
paul@96 | 44 | trivial = str2boolean(trivial) |
paul@96 | 45 | if self.request.user.may.write(pagename): |
paul@96 | 46 | - page = PageEditor(self.request, pagename, do_editor_backup=0) |
paul@120 | 47 | + page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author, mtime=mtime) |
paul@96 | 48 | try: |
paul@120 | 49 | page.saveText(self.extract_file(filename).decode("utf-8"), 0, trivial=trivial, comment=comment) |
paul@96 | 50 | except PageEditor.Unchanged: |
paul@101 | 51 | @@ -555,6 +559,7 @@ |
paul@101 | 52 | # Setup MoinMoin environment |
paul@101 | 53 | from MoinMoin.web.contexts import ScriptContext |
paul@101 | 54 | request = ScriptContext(url=request_url) |
paul@101 | 55 | + request.user.may = IAmRoot() |
paul@101 | 56 | |
paul@101 | 57 | package = ZipPackage(request, packagefile) |
paul@101 | 58 | if not package.isPackage(): |