[Moin-user] Programmatic creating/editing of pages

Paul Boddie paul at boddie.org.uk
Mon Jan 12 12:06:26 EST 2015

On Monday 12. January 2015 11.49.27 Philip Colmer wrote:
> I've written a script that, every night, checks that the organisational
> pages are built from data taken from our LDAP directory.
> The code to do the page bit looks like this:
> ...
>         try:
>             editor = PageEditor(request,
> 'Internal/meet-the-team/{0}'.format(pnNormalised))
>             try:
>                 text = editor.normalizeText(personMainBody.getvalue())
>                 try:
>                     editor.saveText(text, 0)
> ...
> It works fine except for two areas that I'd like to overcome if the Moin
> API permits it:
> 1. I'd prefer NOT to have page history for these pages. It takes up disc
> space and isn't really necessary.

I do wonder whether edits that don't change pages actually produce new 
revisions. I'm fairly sure that when I've imported pages using the page 
package functionality, it hasn't updated unchanged pages, but maybe that's 
something that the page package stuff does.

> 2. I'd prefer NOT to have changes to these pages show up in the
> RecentChanges list. The reason for this request is because part of the
> update process requires me to update the photos for each person. Since I
> can't (easily) do a file comparison to see if the photo has changed, I
> replace all of the photos anyway just to be on the safe side. That is 200
> file updates every night which then swamps the RecentChanges list.

Once upon a time, I thought that the "trivial edit" feature suppressed 
RecentChanges entries, but I don't remember now what the actual effect of that 

> The bit of code that does the photo is:
>         if (person.photo != ''):

          if person.photo:


>             AttachFile.add_attachment(request,
> 'Internal/meet-the-team/{0}'.format(pnNormalised), "profile.jpg",
> person.photo, overwrite=1)
> Does the API support either of options to reduce noise/files?

Are there any opportunities to make checksums of the images and to detect 
changes that way, perhaps incorporating checksums into filenames so that the 
old checksum is handy? This is just a quick suggestion that may get people 
thinking about better ones. ;-)

I suppose the worst case scenario here is history rewriting, which might not 
be supported by the API. I only ever recall doing operations via the API to 
append to the edit log and to add page revisions.


More information about the Moin-user mailing list