Revision: 5508
Author: russblau
Date: 2008-06-03 20:23:58 +0000 (Tue, 03 Jun 2008)
Log Message:
-----------
Added a Page.text property; allows direct manipulation of the page's wiki-text as a
unicode object. This holds the current edited text, not necessarily the same as the text
saved on the wiki.
Modified Paths:
--------------
branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2008-06-03 20:10:50 UTC (rev 5507)
+++ branches/rewrite/pywikibot/page.py 2008-06-03 20:23:58 UTC (rev 5508)
@@ -327,6 +327,27 @@
self.site().loadrevisions(self)
return self._revid
+ def _textgetter(self):
+ """Return the current (edited) wikitext, loading it if
necessary."""
+ if not hasattr(self, '_text'):
+ try:
+ self._text = self.get()
+ except NoPage: # TODO: what other exceptions might be returned?
+ self._text = u""
+ return self._text
+
+ def _textsetter(self, value):
+ """Update the edited wikitext"""
+ self._text = unicode(value)
+
+ def _cleartext(self):
+ """Delete the edited wikitext"""
+ if hasattr(self, "_text"):
+ del self._text
+
+ text = property(_textgetter, _textsetter, _cleartext,
+ "The edited wikitext (unicode) of this Page")
+
def userName(self):
"""Return name or IP address of last user to edit
page."""
return self._revisions[self.latestRevision()].user
Show replies by date