我正在尝试用MoinMoin以编程方式创建一个新的维基页面。但是它不允许我编辑这个页面,我该如何提供一个用户来创建这个页面呢?
[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!在request对象上设置User后,它会创建页面,但随后会锁定整个wiki实例,使其无法创建、编辑和保存任何带有401 Unauthorized错误的新页面。
发布于 2011-03-12 01:15:44
您需要获取一个User并将其附加到ScriptContext对象,这里称为request。
>>> import MoinMoin.user
>>> user = MoinMoin.user.get_by_email_address(request,'jarrod.roberson@mycompany.com')
>>> request.user = user
>>> pe = PageEditor(request, 'MyNewTestPage')
>>> pe.saveText('Hello World!', 0)还有其他方法可以查找User,这种方法对我来说效果很好。我相信有更好的方法。
警告:请确保您以适当的UID (在我的示例中为apache:apache )运行脚本,否则将损坏整个MoinMoin维基。
https://stackoverflow.com/questions/5275856
复制相似问题