comparison MoinMoin/PageEditor.py @ 3042:353739af70fa

PageEditor: fixed copyPage for write restricted pages, tests added (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Feb 2008 22:06:50 +0100
parents b545446562a0
children a1322262398a
comparison
equal deleted inserted replaced
3041:7400c1f2e20a 3042:353739af70fa
562 try: 562 try:
563 filesys.copytree(oldpath, newpath) 563 filesys.copytree(oldpath, newpath)
564 self.error = None 564 self.error = None
565 if not comment: 565 if not comment:
566 comment = u"## page was copied from %s" % self.page_name 566 comment = u"## page was copied from %s" % self.page_name
567 if request.user.may.write(newpagename): 567 savetext = u"## page was copied from %s\n%s" % (self.page_name, savetext)
568 # Save page text with a comment about the old name and log entry 568 Page.__init__(self, request, newpagename)
569 savetext = u"## page was copied from %s\n%s" % (self.page_name, savetext) 569 self._write_file(savetext, "SAVENEW", comment)
570 newpage.saveText(savetext, 0, comment=comment, extra=self.page_name, action='SAVE', notify=False)
571 else:
572 # if user is not able to write to the page itselfs we set a log entry only
573 from MoinMoin import packages
574 rev = newpage.current_rev()
575 packages.edit_logfile_append(self, newpagename, newpath, rev, 'SAVENEW', logname='edit-log',
576 comment=comment, author=u"CopyPage action")
577 570
578 event = PageCopiedEvent(request, newpage, self, comment) 571 event = PageCopiedEvent(request, newpage, self, comment)
579 send_event(event) 572 send_event(event)
580 573
581 return True, None 574 return True, None
822 if text: 815 if text:
823 lines = text.splitlines() 816 lines = text.splitlines()
824 # Strip trailing spaces if needed 817 # Strip trailing spaces if needed
825 if kw.get('stripspaces', 0): 818 if kw.get('stripspaces', 0):
826 lines = [line.rstrip() for line in lines] 819 lines = [line.rstrip() for line in lines]
827
828 # Add final newline if not present, better for diffs (does 820 # Add final newline if not present, better for diffs (does
829 # not include former last line when just adding text to 821 # not include former last line when just adding text to
830 # bottom; idea by CliffordAdams) 822 # bottom; idea by CliffordAdams)
831 if not lines[-1] == u'': 823 if not lines[-1] == u'':
832 # '' will make newline after join 824 # '' will make newline after join