[moin-devel] Extend pages via action as another user
Jasper Olbrich
jasper.olbrich at posteo.de
Wed Jul 26 16:49:47 EDT 2017
Hi,
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.
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?
--
Jasper
More information about the moin-devel
mailing list