--- packages.py.orig 2006-06-03 20:41:07.000000000 +0200 +++ packages.py 2006-06-04 10:25:17.000000000 +0200 @@ -4,6 +4,7 @@ @copyright: 2005 by MoinMoin:AlexanderSchremmer @license: GNU GPL, see COPYING for details. + 2005-2006 R.Bauer AddAttachment operation added """ import os @@ -197,6 +198,26 @@ self.msg += package.msg + def do_addattachment(self,filename,pagename,author=u"Scripting Subsystem", comment=u""): + """ + Installs an attachment + + @param pagename: Page where the file is attached. Or in 2.0, the file itself. + @param filename: Filename of the attachment (just applicable for MoinMoin < 2.0) + """ + _ = self.request.getText + + attachments = Page(self.request, pagename).getPagePath("attachments", check_create=1) + target = os.path.join(attachments,filename) + + if not os.path.exists(target): + self._extractToFile(filename, target) + if os.path.exists(target): + os.chmod(target, config.umask ) + self.msg += u"%(filename)s attached \n" % {"filename": filename} + else: + self.msg += u"%(filename)s not attached \n" % {"filename":filename} + def do_addrevision(self, filename, pagename, author=u"Scripting Subsystem", comment=u"", trivial = u"No"): """ Adds a revision to a page.