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

Philip Colmer philip.colmer at linaro.org
Tue Mar 3 11:47:56 EST 2015


Thanks, Paul, for your comments.

I've (finally) managed to find a way to get logging working on
PageEditor.py and I've been able to confirm that notify is, indeed,
set to False by my code.

Upon further thinking, I suspect that the notifications are *not*
being caused by my script editing the various pages but, instead, by
the fact that my script refreshes attachments on each of the pages.
The pages are profile pages for each employee and, as such, link to a
photo of the employee. Since I don't have an easy way of checking
whether or not the photo has changed, I just updated it every time the
script runs. Since the attachment code causes notifications, I think
that is the root cause.

So I've either got to figure out a clean way of extending the
attachment code so that notifications can be disabled in code, like
PageEditor allows, or find a better way to handle the photos so that I
don't have to keep on refreshing the attachments.

Regards

Philip


On 2 March 2015 at 18:20, Paul Boddie <paul at boddie.org.uk> wrote:
> 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
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Moin-user mailing list
> Moin-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/moin-user




More information about the Moin-user mailing list