[Moin-user] Re: Re: getting notified when a page has been updated?

Nir Soffer nirs at freeshell.org
Sun Jan 29 13:42:02 EST 2006


On 29 Jan, 2006, at 22:00, Fredrik Lundh wrote:

> here's a variant that seems to work:
>
>         def save(self, editor, newtext, rev, **kw):
>             request = editor.request
>             text = editor.get_raw_body()
>             editor.set_raw_body(editor.normalizeText(newtext), 
> modified=1)
>             html = request.redirectedOutput(
>                 editor.send_page, request, count_hit=0, content_only=1
>                 )
>             editor.set_raw_body(text)
>

There is one important problem that may be critical, because this 
security has no security :-) You need to check first if the user may 
save (asking the super class), and only then update the html and return 
True.

Second, this hack bypass some checks in PageEditor.saveText, which may 
cause problems, for example, if two users edit the same page, the 
second user will overwrite the first user changes in the rendered html 
and the page cache, although he will not be able to save the page.

I think its better to add the page rendering to the end of 
PageEditor.saveText, something like this. Its more correct and much 
shorter.

             ...

             # send notification mails
             if self.request.cfg.mail_smarthost:
                 msg = msg + self._notifySubscribers(comment, trivial)

             # Render new text, updating the page cache
             html = self.request.redirectedOutput(self.send_page, 
self.request,
                                                count_hit=0, 
content_only=1)
             # save html here...

             if self.request.cfg.lupy_search:
                 from MoinMoin import lupy
                 index = lupy.Index(self.request)
                 ...

MoinMoin needs a standard way to do stuff before and after certain 
events, with an easy way to add custom code at those points.



Best Regards,

Nir Soffer





More information about the Moin-user mailing list