Example #1
0
def create_wiki(wikiname, adminname, request):
    from Sycamore.wikidb import setRecentChanges
    wikiname = wikiname.lower()
    is_in_farm = wikiutil.isInFarm(wikiname, request)
    is_valid_name = isValidWikiName(wikiname)
    if is_valid_name and not is_in_farm:
        old_wiki = request.config.wiki_name
        wikiname = wikiname.lower()
        create_config(wikiname, request) 

        request.switch_wiki(wikiname)
        buildDB.insert_pages(request, global_pages=False)
        setup_admin(adminname, request)

        build_page_caches(request)
        clear_page_caches(request)

        build_search_index(request)
        setRecentChanges(request)
        request.switch_wiki(old_wiki)
        return None

    if is_in_farm:
        return 'Wiki creation failed because the wiki "%s" already exists!' % (
            wikiname)
    if not is_valid_name:
        return ('Wiki creation failed because the wiki name "%s" is invalid.  '
                'You may only use the numbers 0-9, the letters a-z, and the '
                'dash "-" in a wiki name.' % wikiname)
Example #2
0
def rename_old_user_pages(request):
    from Sycamore import user
    for wikiname in wikiutil.getWikiList(request):
        request.switch_wiki(wikiname)
        user_pages = _get_user_pages(request) 
        num_user_pages = len(user_pages)
        n = 0
        for page in user_pages:
            new_user_pagename = config.user_page_prefix + page.proper_name()
            new_user_page = Page(new_user_pagename, request)
            if new_user_page.exists():
                # something crazzzzy is going on
                continue 
            old_pagename_propercased = page.proper_name()
            d = {'new_name': new_user_pagename.lower(), 'new_propercased_name': new_user_pagename,
                'old_pagename': page.page_name, 'wiki_id': request.config.wiki_id,
                'wiki_name': request.config.wiki_name, 'latest_ed_time': page.mtime(),
                'old_propercased_name': page.proper_name()}

            print page.page_name, '->', new_user_pagename
            _user_page_move(request, copy(d))
            _user_page_redirect(request, d)
            n += 1
Example #3
0
def revert_file_to_version(filename, pagename, version_date, wiki_name,
                           request, keep_deleted_state=False):
    request.switch_wiki(wiki_name)
    Files.restore_file(filename, version_date, pagename, request,
                       permanent=True, showrc=False,
                       keep_deleted_state=keep_deleted_state)
Example #4
0
def delete_file(filename, pagename, wiki_name, request):
    request.switch_wiki(wiki_name)
    Files.del_file(filename, pagename, request, permanent=True)
Example #5
0
def delete_page(pagename, wiki_name, request):
    request.switch_wiki(wiki_name)
    pg = PageEditor(pagename, request)
    pg.deletePage('', permanent=True, showrc=False)
Example #6
0
def revert_page_to_version(pagename, wiki_name, version_date, request):
    request.switch_wiki(wiki_name)
    pg = PageEditor(pagename, request)
    oldpg = Page(pagename, request, prev_date=version_date)
    revert_to_page(oldpg, request, pg, permanent=True, showrc=False)
Example #7
0
def getBaseWikiFullName(request):
    original_wiki = request.config.wiki_name
    request.switch_wiki(getBaseWikiName())
    full_name = request.config.sitename
    request.switch_wiki(original_wiki)
    return full_name