当前位置: 首页>>代码示例>>Python>>正文


Python Page.send_page方法代码示例

本文整理汇总了Python中Sycamore.Page.Page.send_page方法的典型用法代码示例。如果您正苦于以下问题:Python Page.send_page方法的具体用法?Python Page.send_page怎么用?Python Page.send_page使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sycamore.Page.Page的用法示例。


在下文中一共展示了Page.send_page方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    _ = request.getText
    page = Page(pagename, request.cursor)
    if request.user.may.read(pagename):
        badwords, badwords_re, msg = checkSpelling(page, request)
    else:
        badwords = []
        msg = _("You can't check spelling on a page you can't read.")

    if badwords:
        page.send_page(request, msg=msg, hilite_re=badwords_re)
    else:
        page.send_page(request, msg=msg)
开发者ID:ivanov,项目名称:sycamore,代码行数:15,代码来源:SpellCheck.py

示例2: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    _ = request.getText
    request.formatter = Formatter(request)
    page = Page(pagename, request)
    if not page.page_name.startswith(config.user_page_prefix.lower()):
        return page.send_page(msg="Not a user page.")
    username = pagename[len(config.user_page_prefix):]

    request.http_headers()

    wikiutil.simple_send_title(request, pagename,
                               strict_title="User %s's information" % username)


    request.write('<div id="content" class="content">\n\n')
    InfoBar(request, page).render()
    request.write('<div id="tabPage">')

    if config.wiki_farm:
    	request.write('<h3>Watched Wikis</h3>')
	display_watched_wikis(request, username)

    request.write('<h3>Bookmarks</h3>\n')
    display_bookmarks(request, username)

    request.write('<h3>Edits</h3>\n')
    display_edits(request, username, pagename)

    request.write('</div></div>')
    wikiutil.send_footer(request, pagename, showpage=1, noedit=True)
开发者ID:rtucker,项目名称:sycamore,代码行数:32,代码来源:userinfo.py

示例3: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    page = Page(pagename, request)
    msg = None
    form = request.form

    if form.has_key("id"):
        id = request.form["id"][0]
        return send_human_readable(id, request)
    return page.send_page(msg=msg)
开发者ID:philipn,项目名称:sycamore,代码行数:11,代码来源:captcha.py

示例4: loadLanguage

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def loadLanguage(request, lang):
    """
    Load text dictionary for a specific language.

    Note that while ISO language coded use a dash, like 'en-us', our
    languages files use '_' like 'en_us' because they are saved as
    Python source files.

    """
    from Sycamore.util import pysupport
    lang_module = "Sycamore.i18n." + filename(lang)
    texts = pysupport.importName(lang_module, "text") 
    meta = pysupport.importName(lang_module, "meta") 

    # FIXME this doesnt work, leads to &amp;amp;amp;...
    # maybe parser.wiki._do_ent_repl is the problem?
    
    # please help finding this bug. I want to get rid of html in i18n texts
    # and a nice way to do is to replace them by wiki markup. so we wont have
    # to change them every time we go to a new html standard (like html 4.01
    # now and soon maybe xhtml).
    
    # use the wiki parser now to replace some wiki markup with html
    # maybe this is the better implementation, less overhead
    if 0:
        from Sycamore.Page import Page
        from Sycamore.parser.wiki import Parser
        from Sycamore.formatter.text_html import Formatter
        import cStringIO
        for key in texts:
            text = texts[key]
            out = cStringIO.StringIO()
            request.redirect(out)
            print "making parser ..."
            parser = Parser(text, request)
            formatter = Formatter(request)
            p = Page("$$$$i18n$$$$")
            formatter.setPage(p)
            print "formatting ..."
            parser.format(formatter)
            print "formatting finished ..."
            text = out.getvalue()
            request.redirect()
            #if text.startswith("<p>\n"):
            #    text = text[4:]
            #if text.endswith("</p>\n"):
            #    text = text[:-5]
            #print text
            
            # XXX catch problem early:
            if "&amp;amp;" in text:
                raise str(key)+str(text)
            
            texts[key] = text
        
    #alternative implementation, also doesnt work:
    if 0:
        import cStringIO
        from Sycamore.Page import Page
        page = Page("$$$i18n$$$")
        #key = "xxx"
        for key in texts:
            text = texts[key]
            page.set_raw_body(text, 1)
            out = cStringIO.StringIO()
            request.redirect(out)
            page.send_page(request, content_only=1)
            text = out.getvalue()
            if text.startswith("<p>\n"):
                text = text[4:]
            if text.endswith("</p>\n"):
                text = text[:-5]
            #print text
            request.redirect()
            texts[key] = text
        
    # TODO caching for CGI or performance will suck
    # pickle texts dict to caching area

    # XXX UNICODE
    # convert to unicode
    #encoding = meta['encoding']
    #for t in texts:
    #    texts[t] = texts[t].decode(encoding)
    return texts
开发者ID:ivanov,项目名称:sycamore,代码行数:87,代码来源:__init__.py

示例5: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    _ = request.getText
    page = Page(pagename, request)
    actname = __name__.split('.')[-1] 
    if not request.user.may.admin(page):
        msg = _("You don't have admin permissions on this page, "
                "so you cannot change security settings.")
        return page.send_page(msg)
    
    if request.form.has_key('button'):
        # process save
        groups = [] 
        groups_dict = {}
        for key in request.form:
            if key.endswith('_groupname'):
                groups.append(unquoteWikiname(key[:-10]))
            else:
                if key.endswith('_may_read'):
                    dowhat = 'read'
                    groupname = unquoteWikiname(key[:-9])
                elif key.endswith('_may_edit'):
                    dowhat = 'edit'
                    groupname = unquoteWikiname(key[:-9])
                elif key.endswith('_may_delete'):
                    dowhat = 'delete'
                    groupname = unquoteWikiname(key[:-11])
                elif key.endswith('_may_admin'):
                    dowhat = 'admin'
                    groupname = unquoteWikiname(key[:-10])
                else:
                    continue

                if not groups_dict.has_key(groupname):
                    groups_dict[groupname] = [False, False, False, False]

                groups_dict[groupname][ACL_RIGHTS_TABLE[dowhat]] = True

        # set groups we weren't sent any checkboxes for to
        # all false (nothing checked)
        groups_no_checks = filter(lambda(groupname): (
            groupname not in groups_dict), groups)
        for groupname in groups_no_checks:
            groups_dict[groupname] = [False, False, False, False]
 
        wikiacl.setACL(pagename, groups_dict, request)
        return page.send_page(
            msg = _("Security settings sucessfully changed!"))

    formhtml = ['<h3>Security settings for "%s":</h3>' % pagename]

    button = _("Save")
    url = page.url()
    d = {'url': url, 'actname': actname, 'button': button}
    formhtml.append('<form method="POST" action="%(url)s">\n'
                    '<input type="hidden" name="action" value="%(actname)s">\n'
                    % d)

    custom_groups = user.getGroupList(request, exclude_special_groups=True)
    grouplist = ['All', 'Known'] + custom_groups
    for groupname in grouplist:
        # "All" and "Known" are a bit condense
        if groupname == 'All':
            written_groupname = 'Everybody'
        elif groupname == 'Known':
            written_groupname = 'Logged in people'
        else:
            written_groupname = groupname

        group = wikiacl.Group(groupname, request, fresh=True)

        # we want to show the 'change security' option only if
        # it makes some sense
        show_admin = groupname in custom_groups

        formhtml.append('<h6>%s</h6>' % written_groupname)
        formhtml.append('<input type="hidden" name="%s_groupname" '
                                  'value="1">' % quoteWikiname(groupname))
        if group.may(page, 'read'):
            formhtml.append('<input type="checkbox" checked '
                                    'name="%s_may_read" value="1">' %
                            quoteWikiname(groupname))
        else:
            formhtml.append('<input type="checkbox" name="%s_may_read" '
                                   'value="1">' % quoteWikiname(groupname))
        formhtml.append(' read ')

        if group.may(page, 'edit'):
            formhtml.append('<input type="checkbox" checked '
                                   'name="%s_may_edit" value="1">' %
                            quoteWikiname(groupname))
        else:
            formhtml.append('<input type="checkbox" name="%s_may_edit" '
                                   'value="1">' % quoteWikiname(groupname))
        formhtml.append(' edit ') 

        if group.may(page, 'delete'):
            formhtml.append('<input type="checkbox" checked '
                                   'name="%s_may_delete" value="1">' %
                            quoteWikiname(groupname))
        else:
#.........这里部分代码省略.........
开发者ID:ivanov,项目名称:sycamore,代码行数:103,代码来源:Security.py

示例6: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    from Sycamore.PageEditor import PageEditor
    _ = request.getText
    actname = __name__.split('.')[-1]
    page = Page(pagename, request)
    permanent = False
    showrc = True
    if not request.user.may.edit(page):
        return page.send_page(
            msg = _('You are not allowed to revert this page!'))

    # check whether the user clicked the delete button
    if request.form.has_key('button') and request.form.has_key('ticket'):
        # check whether this is a valid deletion request (make outside
        # attacks harder by requiring two full HTTP transactions)
        if not _checkTicket(request.form['ticket'][0]):
            return page.send_page(
                msg = _('Please use the interactive user interface to '
                        'revert pages!'))
        # revert the page
        if request.form.has_key('version'):
            version = int(request.form['version'][0])
            oldpg = Page(pagename, request, version=version)
            date = oldpg.prev_date
            if request.form.has_key('comment'):
                entered_comment = request.form['comment'][0]
            else:
                entered_comment = ''
            if len(entered_comment) > wikiaction.MAX_COMMENT_LENGTH:
                return page.send_page(msg = _(
                    'Comments must be less than %s characters long.' %
                    wikiaction.MAX_COMMENT_LENGTH))
            else:
                comment = 'v%s' % str(version)

            comment = "%sc%s" % (comment, entered_comment)
        else:
            return

        if (request.form.has_key('permanent') and
            request.form['permanent'][0] and request.user.may.admin(page)):
            permanent = True
            if (request.form.has_key('noshowrc') and
                request.form['noshowrc'][0]):
                showrc = False

        pg = PageEditor(pagename, request)
        savemsg = revert_to_page(oldpg, request, pg, comment=comment,
                                 permanent=permanent, showrc=showrc)
        return pg.send_page(msg=savemsg,
                            force_regenerate_content=(permanent and not
                                                      showrc))

    # get version
    if request.form.has_key('version'):
        version = request.form['version'][0]
    else:
        return page.send_page(msg= _(
            'Please use the interactive user interface to revert pages!'))

    oldpg = Page(pagename, request, version=version)
    # send revert form
    url = page.url()
    ticket = _createTicket()
    button = _('Revert')
    comment_label = _("Reason for the revert:")
    if request.user.may.admin(page):
        admin_label = (
            '<p>Permanently remove newer versions: '
            '<input id="noshowrctoggle" type="checkbox" name="permanent" '
                   'value="1"><span id="noshowrc">'
            "Don't log on Recent Changes: "
            '<input type="checkbox" name="noshowrc" value="1"></span></p>\n'
            '<script type="text/javascript">\n'
            "document.getElementById('noshowrc').style.visibility = "
                "'hidden';\n"
            "document.getElementById('noshowrc').style.paddingLeft = "
                "'1em';\n"
            "document.getElementById('noshowrctoggle').onclick = "
                "function () {\n"
            "document.getElementById('noshowrc').style.visibility = "
                "document.getElementById('noshowrctoggle').checked ? "
                    "'visible' : 'hidden'; \n"
            "}\n"
            "</script>\n"
        )
    else:
        admin_label = ''

    formhtml = (
        '<form method="GET" action="%(url)s">'
        '<input type="hidden" name="action" value="%(actname)s">'
        '<input type="hidden" name="ticket" value="%(ticket)s">'
        '<input type="hidden" name="version" value="%(version)s">'
        '<p>'
        '%(comment_label)s'
        '</p>'
        '<input type="text" name="comment" size="60" maxlength="80">'
        '<input type="submit" name="button" value="%(button)s">'
        '%(admin_label)s'
#.........这里部分代码省略.........
开发者ID:rtucker,项目名称:sycamore,代码行数:103,代码来源:revert.py

示例7: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(macro, args, formatter=None):
    if not formatter:
        formatter = macro.formatter
    _ = macro.request.getText

    re_args = re.search('(?P<caption>.+)\,\s(?P<the_rest>.*)', args)
    pagename = re_args.group('caption')
    items = re_args.group('the_rest')
    page = Page(pagename, macro.request)

    try:
        links = max(int(items), 1)
    except StandardError:
        links = 1

    raw = page.get_raw_body(fresh=macro.request.set_cache)
    if not macro.request.user.may.read(page):
        raw = ""

    # this selects lines looking like a list item
    # !!! TODO: make multi-line quotes possible
    # (optionally split by "----" or something)
    quotes = raw.splitlines()
    if links > 1:
        quotes = [quote for quote in quotes if quote.startswith(' *')]
        random.shuffle(quotes)
        while len(quotes) > links:
            quotes = quotes[:-1]
        quote = ''

        for name in quotes:
            quote = quote + name + '\n'
            
        page.set_raw_body(quote, 1)
        out = cStringIO.StringIO()
        macro.request.redirect(out)
        page.send_page(content_only=1,
                       content_id="randomquote_%s" %
                                   wikiutil.quoteWikiname(page.page_name) )
        quote = out.getvalue()
        macro.request.redirect()
    else:
        quotes = [quote.strip() for quote in quotes]
        quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
        if quotes:
            quote = random.choice(quotes)
        else:
            quote = ''

        page.set_raw_body(quote, 1)
        out = cStringIO.StringIO()
        macro.request.redirect(out)
        page.send_page(content_only=1,
                       content_id="randomquote_%s" %
                                  wikiutil.quoteWikiname(page.page_name) )
        quote = out.getvalue()
        macro.request.redirect()

    if not quotes:
        return (macro.formatter.highlight(1) +
                _('No quotes on %(pagename)s.') % {'pagename': pagename} +
                macro.formatter.highlight(0))
    
    return quote.decode(config.charset)
开发者ID:ivanov,项目名称:sycamore,代码行数:66,代码来源:randomitem.py

示例8: execute

# 需要导入模块: from Sycamore.Page import Page [as 别名]
# 或者: from Sycamore.Page.Page import send_page [as 别名]
def execute(pagename, request):
    from Sycamore.PageEditor import PageEditor
    _ = request.getText
    actname = __name__.split('.')[-1]
    page = Page(pagename, request)
    msg = None
    form = request.form
    wikiname = None
    
    if not config.wiki_farm or not config.allow_web_based_wiki_creation:
        return page.send_page(msg='You are not allowed to create new wikis.')
    if not request.user.valid:
        return page.send_page(msg='You must be logged in to create new wikis.')

    if do_email_auth:
        if request.form.has_key('send_email') and request.form['send_email'][0]:
            if (not request.form.has_key('wikiname') or not
                request.form['wikiname'][0]):
                return page.send_page(msg='Missing wiki name.')
            wikiname = request.form['wikiname'][0].lower()
            if not farm.isValidWikiName(wikiname):
                msg = ('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)
            elif wikiutil.isInFarm(wikiname, request):
                msg = 'Wiki "%s" already exists!' % wikiname 
            else:
                msg = send_validation_email(wikiname, request)
            return page.send_page(msg=msg)
        email_code = has_valid_email_link(request)
        if not email_code:
            return page.send_page(msg=("Invalid email link. "
                                       "To create a wiki you must follow the link send to your email account."))
        
    if form.has_key('wikiname') and form['wikiname'][0]:
        can_create_wiki = False
        wikiname = form['wikiname'][0].lower()
        if do_email_auth:
            if not config.captcha_support:
                can_create_wiki = True
            elif form.has_key('captcha_id') and form.has_key('captcha_code'):
                this_captcha = captcha.Captcha(page, id=form['captcha_id'][0])
                if this_captcha.check(form['captcha_code'][0]):
                    can_create_wiki = True
                else:
                    msg = ('Human verification was incorrect.  '
                           'Please try again!')
            else:
                if form.has_key('audio'):
                    type = 'wav'
                else:
                    type = 'png'
                captcha.send_captcha(page, wikiname, actname, email_code, type)
                return
        else:
            can_create_wiki = True

        if can_create_wiki:
            msg = farm.create_wiki(wikiname, request.user.name, request)
            if do_email_auth:
                _clearAuthCode(request, wikiname, email_code)
            if msg:
                # there was a problem
                return page.send_page(msg=msg)

            farm.add_wiki_to_watch(wikiname, request) 

            formatter = Formatter(request)
            wiki_location = farm.link_to_wiki(wikiname, formatter)
            msg = (
                'Wiki "%s" created successfully! '
                'Follow this link to get to your wiki:\n'
                '<p>\n'
                '%s\n'
                '</p>\n'
                '<p>\n'
                'The wiki was added to your list of watched wikis '
                '(change in '
                    '<a href="%sUser_Settings">your account settings</a>).\n'
                '</p>' %
                (wikiname, wiki_location, farm.getBaseFarmURL(request)))

    return page.send_page(msg=msg)
开发者ID:ivanov,项目名称:sycamore,代码行数:86,代码来源:new_wiki.py


注:本文中的Sycamore.Page.Page.send_page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。