Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.MyPages Namespace Reference

Functions

def execute

Function Documentation

def MoinMoin.action.MyPages.execute (   pagename,
  request 
)

Definition at line 9 of file MyPages.py.

00009 
00010 def execute(pagename, request):
00011     from MoinMoin import wikiutil
00012     from MoinMoin.Page import Page
00013 
00014     _ = request.getText
00015     thispage = Page(request, pagename)
00016 
00017     if request.user.valid:
00018         username = request.user.name
00019     else:
00020         username = ''
00021 
00022     if not username:
00023         request.theme.add_msg(_('Please log in first.'), "error")
00024         return thispage.send_page()
00025 
00026     userhomewiki = request.cfg.user_homewiki
00027     if userhomewiki != 'Self' and userhomewiki != request.cfg.interwikiname:
00028         interwiki = wikiutil.getInterwikiHomePage(request, username=username)
00029         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(request, *interwiki)
00030         wikiurl = wikiutil.mapURL(request, wikiurl)
00031         homepageurl = wikiutil.join_wiki(wikiurl, wikitail)
00032         request.http_redirect('%s?action=MyPages' % homepageurl)
00033 
00034     homepage = Page(request, username)
00035     if not homepage.exists():
00036         request.theme.add_msg(_('Please first create a homepage before creating additional pages.'), "error")
00037         return homepage.send_page()
00038 
00039     pagecontent = _("""\
00040 You can add some additional sub pages to your already existing homepage here.
00041 
00042 You can choose how open to other readers or writers those pages shall be,
00043 access is controlled by group membership of the corresponding group page.
00044 
00045 Just enter the sub page's name and click on the button to create a new page.
00046 
00047 Before creating access protected pages, make sure the corresponding group page
00048 exists and has the appropriate members in it. Use HomepageGroupsTemplate for creating
00049 the group pages.
00050 
00051 ||'''Add a new personal page:'''||'''Related access control list group:'''||
00052 ||<<NewPage(HomepageReadWritePageTemplate,read-write page,%(username)s)>>||[[%(username)s/ReadWriteGroup]]||
00053 ||<<NewPage(HomepageReadPageTemplate,read-only page,%(username)s)>>||[[%(username)s/ReadGroup]]||
00054 ||<<NewPage(HomepagePrivatePageTemplate,private page,%(username)s)>>||%(username)s only||
00055 
00056 """)
00057     pagecontent = pagecontent % locals()
00058 
00059     pagecontent = pagecontent.replace('\n', '\r\n')
00060 
00061     from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
00062 
00063     # This action generate data using the user language
00064     request.setContentLanguage(request.lang)
00065     request.theme.send_title(_('MyPages management'), page=homepage)
00066 
00067     parser = WikiParser(pagecontent, request)
00068     p = Page(request, "$$$")
00069     request.formatter.setPage(p)
00070     parser.format(request.formatter)
00071 
00072     # Start content - IMPORTANT - without content div, there is no direction support!
00073     request.write(request.formatter.startContent("content"))
00074 
00075     request.write(request.formatter.endContent())
00076     request.theme.send_footer(homepage.page_name)
00077     request.theme.send_closing_html()
00078