All pastes #935278 Raw Edit

Miscellany

public python v1 · immutable
·published 2008-03-09 14:53 UTC
rendered paste body
+    +    def _addTextElem(self, target, elemName, text):+            newElement = self.doc.createElement(elemName)+            newElement.appendChild(self.doc.createTextNode(text))+            target.appendChild(newElement)+        +    +    def _addRevisionHistory(self, targetNode):+        from MoinMoin.logfile import editlog+        from MoinMoin import user+        log = editlog.EditLog(self.request, rootpagename=self.title)+        user_cache={}+        +        history = self.doc.createElement("revhistory")++        # read in the complete log of this page+        for line in log.reverse():+            if not line.action in ('SAVE', 'SAVENEW', 'SAVE/REVERT', 'SAVE/RENAME', ):+                #Let's ignore adding of attachments+                continue+            revision = self.doc.createElement("revision")+            +            #Revision number (without preceeding zeros)+            self._addTextElem(revision, "revnumber", line.rev.lstrip('0'))+            +            #Date of revision+            date_text = self.request.user.getFormattedDateTime(+                wikiutil.version2timestamp(line.ed_time_usecs))+            self._addTextElem(revision, "date", date_text)++            #Author or revision+            if not (line.userid in user_cache):+                user_cache[line.userid] = user.User(self.request, line.userid, auth_method="text_docbook:740")+            author = user_cache[line.userid]+            if author and author.name:+                self._addTextElem(revision, "authorinitials", author.name)+            else:+                self._addTextElem(revision, "authorinitials", line.hostname)++            #Comment from author of revision+            comment = line.comment+            if not comment:+                if '/REVERT' in line.action:+                    comment = _("Revert to revision %(rev)d.") % {'rev': int(line.extra)}+                elif '/RENAME' in line.action:+                    comment = _("Renamed from '%(oldpagename)s'.") % {'oldpagename': line.extra}+            if comment:+                self._addTextElem(revision, "revremark", comment)++            history.appendChild(revision)++        targetNode.appendChild(history)