Attachment 'TestMayWrite.py'
Download 1 # test for may.write
2 # Reimar Bauer
3 # GPL
4
5 from MoinMoin.util import filesys
6 from MoinMoin.PageEditor import PageEditor
7
8 def execute(macro, args):
9 request = macro.request
10 _ = request.getText
11 formatter = macro.formatter
12 comment = ''
13 oldpagename = 'TestUserHasNoACLRights'
14 newpagename = 'TestIfTestUserHasNoACLRights'
15 oldpage = PageEditor(request, oldpagename)
16 newpage = PageEditor(request, newpagename)
17 if not newpage.exists(includeDeleted=1) and not request.user.may.write(newpagename):
18 return _('You are not allowed to copy this page!')
19
20 pageexists_error = _("""'''A page with the name {{{'%s'}}} already exists.''' Try a different name.""") % (newpagename,)
21 # Check whether a page with the new name already exists
22 if newpage.exists(includeDeleted=1):
23 return pageexists_error
24
25 # Get old page text
26 savetext = oldpage.get_raw_body()
27 oldpath = oldpage.getPagePath(check_create=0)
28 newpath = newpage.getPagePath(check_create=0)
29
30 try:
31 filesys.copytree(oldpath, newpath)
32 request.write('we have copied to newpage %s<br>' % newpagename)
33 newpage.error = None
34 if not comment:
35 comment = u"## page was copied from %s" % oldpagename
36 request.write('we check here if we are able to write to an acl protected page<br>')
37 if request.user.may.write(newpagename): # and request.user.may.admin(newpagename):
38 request.write('Oops why we are here<br>')
39 except:
40 return "OK"
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.