[Moin-user] Trying to understand notification behaviour in PageEdit.py

Paul Boddie paul at boddie.org.uk
Mon Mar 2 13:20:17 EST 2015


On Wednesday 25. February 2015 11.02.13 Philip Colmer wrote:
> I've got a nightly script that does a lot of automated changes to
> pages and I need to stop the notifications going out because of the
> email overhead it is generating.
> 
> Looking at the code for PageEditor.py, I can see that saveText accepts
> the keyword notify:
> 
> @keyword notify: if False (default: True), don't send a PageChangedEvent
> 
> Indeed, there are calls to saveText within PageEditor.py where
> notify=False is set in the call.

Yes, it would seem that the intention is to silence notifications on things 
like renames, copies, deletions, and so on, replacing the change events with 
specific events.

> However, similarly changing my code so that it sets notify to False
> does not have the same effect.
> 
> editor.saveText(text, 0, notify=False) still results in a notification
> being sent. What is *really* weird is that if I edit the saveText code
> so that the default value for notify is changed, thus:
> 
> notify = kw.get('notify', False)
> 
> I *still* get the notification when my script runs, but if I edit a
> page manually, NO notifications are sent.

So that sounds like the presence of the keyword argument is enough to cause 
the notify state to be true. If you hadn't written out the invocation above 
with the actual notify parameter specified, I might have been inclined to 
suggest double-checking the provided value because some people less familiar 
with Python than yourself might accidentally use a string value ("False") and 
then experience that being interpreted as a true value.

But beyond this, I can only suggest introducing some trace statements to 
really check the value of notify and to confirm the logic.

> I've only got one file on my server called PageEditor.py so I am
> really bemused as to what the heck is going on here. I've trying
> adding logging to the code and, again, the logging only happens when
> I'm using moin via the web server. Nothing is output when my script
> runs.
> 
> Any suggestions, please?

There isn't an old PageEditor.pyc file confusing the situation, is there? 
Other than that, I might suspect an event handler listening to 
PagePreSaveEvent, but that isn't a standard thing you'd get with most Moin 
installations. (I have an extension called ApproveChanges which handles it, 
though, and I see that it doesn't use notify=False when playing around with 
page content, but that is pretty exotic stuff.)

Paul




More information about the Moin-user mailing list