On Fri, Sep 5, 2014 at 5:00 AM, John Mark Vandenberg <jayvdb@gmail.com> wrote:
On Wed, Sep 3, 2014 at 2:29 AM, Sorawee Porncharoenwase
<nullzero.free@gmail.com> wrote:
> I propose this change:
>
> - set `page.text` to `None` to discard changes

Doesn't the page.text setter already do this?

Yes, it already does this. Currently, `del page.text` and `page.text = None` do the same thing. Since I want to change the functionality of `del page.text`, I wrote "set `page.text` to `None` to discard changes" to say that `page.text = None` will not be changed.


> - delete `page.text` to reload content -- equivalent to get(force=True)

del page.text already removes the cached / modified page text.

so a forced reload of text is currently two lines:

del page.text
new = page.text

I dont see why 'del page.text' should initiate network activity to
reload the page text.


It seems to me that we want to switch get() to text property instead. To make text can do what get() can do, we want an ability to force reloading page--maybe to get the latest edit of a page which is edited frequently.
 
> - in Page.save(), if `page.text` is equal to unchanged text, no API call

Currently, when I want to do find & replace, I have to write

text = page.text.replace(find, replace)
if text != page.text: # avoid API call
    page.text = text
    page.save()

In the past, we have put(), so I can just write

text = page.get().replace(find, replace)
if text != page.text:
    page.put(text)

I therefore think that  the current functionality of save() is not useful much. I think that the right code for this is

page.text = page.text.replace(find, replace)
page.save()

In order to make this possible, if the text is unchanged, there should be no API call.
 
> - to touch a page, use page.touch(), which will call action="edit" &
> appendtext="", instead. The advantage is that there is no need to preload
> text.

We have a touch() changeset pending.

https://gerrit.wikimedia.org/r/#/c/144717/


Can I submit another patchset for 144717? action="edit" & appendtext="" is a better way to go because we don't have to retrieve text at all.
 
--
John Vandenberg

_______________________________________________
Pywikipedia-l mailing list
Pywikipedia-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

--
Sorawee Porncharoenwase