[moin-devel] Extend pages via action as another user

Paul Boddie paul at boddie.org.uk
Wed Jul 26 18:04:05 EDT 2017


On Wednesday 26. July 2017 22.49.47 Jasper Olbrich wrote:
> 
> I'm trying to create a kind of group mechanism that allows any
> registered user who knows a password to join an existing group in my wiki.
> 
> Setup:
> * TestGroup page, member list at the bottom of the page
> * LetMeIn page with a form field for the password (FormCreate macro)
> * custom action deriving from FormSubmit
> 
> At first, I tried to edit the current revision of TestGroup on the file
> system level, but there seem to be some caching issues with regard to
> the permissions, or I screwed up the revisions or something else. It
> didn't work reliably.

Although Moin 1.x has a fairly understandable filesystem layout, getting the 
permissions right can be a challenge. Furthermore, there is caching involved 
with pages that provide group details, which may be the problem you were 
experiencing.

> Then I found the Page and PageEditor classes and did the following:
> 
>   real_user = self.request.user
>   # 'su'
>   u = User(self.request, _getUserIdByKey(self.request, "name", "ol"))
>   self.request.user = u
>   p = Page(self.request, "TestGroup")
>   rev = p.current_rev()
>   pe = PageEditor(self.request, "TestGroup")
>   pe.saveText(p.get_raw_body() + " * {}\n".format(real_user.name), rev)
>   # 'un-su'
>   self.request.user = real_user
> 
> "ol" is a user that can write to TestGroup.
> This code works, but feels kind of wrong. Are there better ways to do
> what I want?

Probably not! In my ApproveChanges plug-in for Moin, I did something rather 
similar. See the following resource for more details:

http://hgweb.boddie.org.uk/ApproveChanges/file/5e947e093388/ApproveChangesSupport.py#l180

Ideally, it would be possible to edit the group dictionary and have the 
dictionary serialised back to the originating page, but this is not a 
straightforward exercise. (Moin 2 might use special, rigid resources for 
things like this but I haven't really investigated.)

Paul


More information about the moin-devel mailing list