I am trying to create a new wiki page programmatically with MoinMoin. But it is not allowing me to edit the page, how do I provide a user to create this page as?
[Fri Mar 11 11:44:35] [root]@[dev] /usr/local/share/moin
# python2.6
Python 2.6.5 (r265:79063, Jun 4 2010, 21:43:07)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from MoinMoin.web.contexts import ScriptContext
>>> from MoinMoin.PageEditor import PageEditor
>>> request = ScriptContext('http://wiki.dev.itaas.com')
>>> pe = PageEditor(request, 'MyNewTestPage')
>>> pe.saveText('Hello World!', 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/MoinMoin/PageEditor.py", line 1068, in saveText
raise self.AccessDenied, msg
MoinMoin.PageEditor.AccessDenied: You are not allowed to edit this page!
After setting a User on the request object, it creates the page, but then locks up the entire wiki instance from creating or editing and saving any new pages with 401 Unauthorized errors.
You need to get a
Userand attach it to theScriptContextobject, here calledrequest.There are other ways to look up a
Userthis one worked well for me. I am sure there is a better way.WARNING: Make sure you are running your script as the appropriate UID ( in my case apache:apache ) or you will corrupt the entire MoinMoin wiki.