2014-09-02 18:29 GMT+02:00 Sorawee Porncharoenwase <nullzero.free(a)gmail.com>
:
- set `page.text` to `None` to discard changes
Not sure I like this, it seems to be a semantic mess and a little too much
Page object implementation related. Of course internally if the text
attribute value is None this usually mean the page have not been loaded yet
and practically it discard changes.
But imagine a user for whom the Page object is the representation of a
Wikipage on server. He may have no idea of how the Page object is
implemented. He may believe if he does this and saves the page he actually
will blank the page on server when saving (actually if I read the code well
it will raise an error in the site.editpage function)
Why not use something more explicit as a "discard_changes" function ? I
don't really like the raw access to the attribute as it exposes some
implementation details
Of course python has setter methods, but when I read
@text.setter def text(self, value): """Update the current (edited)
wikitext.
@param value: New value or None @param value: basestring """
self._text = None if value is None else unicode(value)
and
@text.deleter def text(self): """Delete the current
(edited) wikitext.""" if hasattr(self, "_text"):
del self._text
I find there is a lot of implicit for a pythonic program :) at least the
meaning and the effects should be more explicitely documented.