本文整理汇总了Python中MoinMoin.Page.Page类的典型用法代码示例。如果您正苦于以下问题:Python Page类的具体用法?Python Page怎么用?Python Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: breadcrumbs
def breadcrumbs(self, d, is_footer=False):
request = self.request
_ = request.getText
user = request.user
if not user.valid:
return ""
items = []
if user.show_page_trail:
trail = user.getTrail()
if trail:
for pagename in trail[::-1]:
try:
interwiki, page = wikiutil.split_interwiki(pagename)
if interwiki != request.cfg.interwikiname and interwiki != 'Self':
link = (
self.request.formatter.interwikilink(
True, interwiki, page) +
self.shortenPagename(page) +
self.request.formatter.interwikilink(
False, interwiki, page))
items.append(link)
continue
else:
pagename = page
except ValueError:
pass
page = Page(request, pagename)
title = page.split_title()
title = self.shortenPagename(title)
link = page.link_to(request, title)
items.append(link)
val = """ <div class="navbar breadcrumb">
<ul class="breadcrumb navbar-left">"""
for i, item in enumerate(items):
if i == 0:
val += '\n <li class="active">%s</li>' % item
else:
val += '\n <li>%s</li>' % item
val += '\n </ul>\n <ul class="breadcrumb navbar-right">'
actions = getattr(request.cfg, 'bootstrap_actions',
self.BREADCRUMB_ACTIONS)
for i, act in enumerate(actions):
if act[0].isupper() and not act in self.available_actions:
continue
val += '\n <li><a href="?action=%s%s">%s</a></li>' % (act, self.rev, self._actiontitle(act))
val += u"""
<li class="toggleCommentsButton" style="display:none;">
<a href="#" class="nbcomment" onClick="toggleComments(); return false;">%s</a>
</li>
%s
</ul>
</div>""" % (_('Comments'), self.actionsmenu(d, is_footer))
return val
开发者ID:execgit,项目名称:graphingwiki,代码行数:60,代码来源:opencollab.py
示例2: getAttachDir
def getAttachDir(request, pagename, create=0):
""" Get directory where attachments for page `pagename` are stored. """
if request.page and pagename == request.page.page_name:
page = request.page # reusing existing page obj is faster
else:
page = Page(request, pagename)
return page.getPagePath("attachments", check_create=create)
开发者ID:Glottotopia,项目名称:aagd,代码行数:7,代码来源:AttachFile.py
示例3: _do_queued_updates
def _do_queued_updates(self, request, amount=5):
""" Assumes that the write lock is acquired """
self.touch()
writer = xapidx.Index(self.dir, True)
writer.configure(self.prefixMap, self.indexValueMap)
# do all page updates
pages = self.update_queue.pages()[:amount]
for name in pages:
p = Page(request, name)
if request.cfg.xapian_index_history:
for rev in p.getRevList():
self._index_page(writer, Page(request, name, rev=rev), mode='update')
else:
self._index_page(writer, p, mode='update')
self.update_queue.remove([name])
# do page/attachment removals
items = self.remove_queue.pages()[:amount]
for item in items:
_item = item.split('//')
p = Page(request, _item[0])
self._remove_item(writer, p, _item[1])
self.remove_queue.remove([item])
writer.close()
开发者ID:steveyen,项目名称:moingo,代码行数:26,代码来源:Xapian.py
示例4: move_file
def move_file(request, pagename, new_pagename, attachment, new_attachment):
_ = request.getText
newpage = Page(request, new_pagename)
if newpage.exists(includeDeleted=1) and request.user.may.write(new_pagename) and request.user.may.delete(pagename):
new_attachment_path = os.path.join(getAttachDir(request, new_pagename,
create=1), new_attachment).encode(config.charset)
attachment_path = os.path.join(getAttachDir(request, pagename),
attachment).encode(config.charset)
if os.path.exists(new_attachment_path):
upload_form(pagename, request,
msg=_("Attachment '%(new_pagename)s/%(new_filename)s' already exists.") % {
'new_pagename': new_pagename,
'new_filename': new_attachment})
return
if new_attachment_path != attachment_path:
# move file
filesys.rename(attachment_path, new_attachment_path)
_addLogEntry(request, 'ATTDEL', pagename, attachment)
_addLogEntry(request, 'ATTNEW', new_pagename, new_attachment)
upload_form(pagename, request,
msg=_("Attachment '%(pagename)s/%(filename)s' moved to '%(new_pagename)s/%(new_filename)s'.") % {
'pagename': pagename,
'filename': attachment,
'new_pagename': new_pagename,
'new_filename': new_attachment})
else:
upload_form(pagename, request, msg=_("Nothing changed"))
else:
upload_form(pagename, request, msg=_("Page '%(new_pagename)s' does not exist or you don't have enough rights.") % {
'new_pagename': new_pagename})
开发者ID:steveyen,项目名称:moingo,代码行数:33,代码来源:AttachFile.py
示例5: macro_RandomQuote
def macro_RandomQuote(macro, pagename=u'FortuneCookies'):
_ = macro.request.getText
if macro.request.user.may.read(pagename):
page = Page(macro.request, pagename)
raw = page.get_raw_body()
else:
raw = ""
# this selects lines looking like a list item
# !!! TODO: make multi-line quotes possible (optionally split by "----" or something)
quotes = raw.splitlines()
quotes = [quote.strip() for quote in quotes]
quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
if not quotes:
return (macro.formatter.highlight(1) +
_('No quotes on %(pagename)s.') % {'pagename': pagename} +
macro.formatter.highlight(0))
quote = random.choice(quotes)
page.set_raw_body(quote, 1)
quote = macro.request.redirectedOutput(page.send_page,
content_only=1, content_id="RandomQuote")
return quote
开发者ID:IvanLogvinov,项目名称:soar,代码行数:26,代码来源:RandomQuote.py
示例6: pagelink
def pagelink(self, on, pagename="", page=None, **kw):
FormatterBase.pagelink(self, on, pagename, page, **kw)
if page is None:
page = Page(self.request, pagename, formatter=self)
link_text = page.link_to(self.request, on=on, **kw)
self._curr.xml_append(tree.text(U(link_text)))
return ""
开发者ID:pombredanne,项目名称:akara,代码行数:7,代码来源:application_xml.py
示例7: _retrieve_members
def _retrieve_members(self, group_name):
"""
MoinMoin.formatter.groups is used to extract group members from a page.
"""
formatter = Formatter(self.request)
page = Page(self.request, group_name, formatter=formatter)
request_page = getattr(self.request, "page", None)
self.request.page = page
# send_special is set to True because acl of the page should
# not be processed to avoid infinite recursion in the
# following case.
#
# Consider page UserGroup content:
#
# #acl UserGroup:read,write,admin All:read
#
# * ExampleUser
# * TestGroup
#
page.send_page(content_only=True, send_special=True)
if request_page:
self.request.page = request_page
else:
del self.request.page
return formatter.members
开发者ID:IvanLogvinov,项目名称:soar,代码行数:28,代码来源:wiki_groups.py
示例8: handle_file_attached
def handle_file_attached(event):
"""Sends an email to super users that have subscribed to this event type"""
names = set()
from_address = event.request.cfg.mail_from
request = event.request
page = Page(request, event.pagename)
subscribers = page.getSubscribers(request, return_users=1)
notification.filter_subscriber_list(event, subscribers, False)
recipients = []
for lang in subscribers:
recipients.extend(subscribers[lang])
attachlink = request.getBaseURL() + getAttachUrl(event.pagename, event.filename, request)
pagelink = request.getQualifiedURL(page.url(request, {}))
for lang in subscribers:
emails = []
_ = lambda text: request.getText(text, lang=lang)
links = _("Attachment link: %(attach)s\n" \
"Page link: %(page)s\n") % {'attach': attachlink, 'page': pagelink}
data = notification.attachment_added(request, _, event.pagename, event.filename, event.size)
data['text'] = data['text'] + links
emails = [usr.email for usr in subscribers[lang]]
if send_notification(request, from_address, emails, data):
names.update(recipients)
return notification.Success(names)
开发者ID:steveyen,项目名称:moingo,代码行数:34,代码来源:emailnotify.py
示例9: parse
def parse(story):
"""
The main workhorse that does nothing but call MoinMoin to do its dirty
laundry
@param story: A text for conversion
@type story: string
@returns: formatted string
@rtype: string
"""
s = StringIO()
oldstdout = sys.stdout
form = None
page = Page(None)
page.hilite_re = None
request = Request()
request.user = User()
formatter = Formatter(request)
formatter.setPage(page)
sys.stdout = s
Parser(story, request).format(formatter, form)
sys.stdout = oldstdout
result = s.getvalue()
s.close()
return result
开发者ID:BSierakowski,项目名称:personal_code,代码行数:25,代码来源:moinmoin.py
示例10: __init__
class PackagePages:
def __init__(self, pagename, request):
self.request = request
self.pagename = pagename
self.page = Page(request, pagename)
def allowed(self):
""" Check if user is allowed to do this. """
return not self.__class__.__name__ in self.request.cfg.actions_excluded
def render(self):
""" Render action
This action returns a wiki page with optional message, or
redirects to new page.
"""
_ = self.request.getText
if 'cancel' in self.request.values:
# User canceled
return self.page.send_page()
try:
if not self.allowed():
self.request.theme.add_msg(_('You are not allowed to edit this page.'), "error")
raise ActionError
elif not self.page.exists():
self.request.theme.add_msg(_('This page is already deleted or was never created!'))
raise ActionError
self.package()
except ActionError, e:
return self.page.send_page()
开发者ID:IvanLogvinov,项目名称:soar,代码行数:33,代码来源:PackagePages.py
示例11: linkto
def linkto(pagename, request, params=''):
_ = request.getText
if not request.cfg.chart_options:
request.formatter = Formatter(request)
return text(pagename, request, params)
if _debug:
return draw(pagename, request)
page = Page(request, pagename)
# Create escaped query string from dict and params
querystr = {'action': 'chart', 'type': 'hitcounts'}
querystr = wikiutil.makeQueryString(querystr)
querystr = wikiutil.escape(querystr)
if params:
querystr += '&' + params
# TODO: remove escape=0 in 2.0
data = {'url': page.url(request, querystr, escape=0)}
data.update(request.cfg.chart_options)
result = ('<img src="%(url)s" width="%(width)d" height="%(height)d"'
' alt="hitcounts chart">') % data
return result
开发者ID:imosts,项目名称:flume,代码行数:26,代码来源:hitcounts.py
示例12: trail
def trail(self, d):
""" Assemble page trail
@param d: parameter dictionary
@rtype: unicode
@return: trail html
"""
request = self.request
user = request.user
if user.valid and user.show_page_trail:
trail = user.getTrail()
if trail:
items = []
# Show all items except the last one which is this page.
for pagename in trail[:-1]:
page = Page(request, pagename)
title = page.split_title(request)
title = self.shortenPagename(title)
link = page.link_to(request, title)
items.append('<li>%s</li>' % link)
html = '''
<ul id="pagetrail">
%s
</ul>''' % '\n'.join(items)
return html
return ''
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:26,代码来源:__init__.py
示例13: username
def username(self, d):
""" Assemble the username / userprefs link
@param d: parameter dictionary
@rtype: string
@return: username html
"""
from MoinMoin.Page import Page
request = self.request
_ = request.getText
userlinks = []
# Add username/homepage link for registered users. We don't care
# if it exists, the user can create it.
if request.user.valid:
homepage = Page(request, request.user.name)
title = homepage.split_title(request)
homelink = homepage.link_to(request, text=title)
userlinks.append(homelink)
# Set pref page to localized Preferences page
prefpage = wikiutil.getSysPage(request, 'UserPreferences')
title = prefpage.split_title(request)
userlinks.append(prefpage.link_to(request, text=title))
else:
# Add prefpage links with title: Login
prefpage = wikiutil.getSysPage(request, 'UserPreferences')
userlinks.append(prefpage.link_to(request, text=_("Login")))
html = '<ul id="username"><li>%s</li></ul>' % '</li>\n<li>'.join(userlinks)
return html
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:31,代码来源:__init__.py
示例14: do_replaceunderlay
def do_replaceunderlay(self, filename, pagename):
"""
Overwrites underlay pages. Implementational detail: This needs to be
kept in sync with the page class.
@param filename: name of the file in the package
@param pagename: page to be overwritten
"""
page = Page(self.request, pagename)
pagedir = page.getPagePath(use_underlay=1, check_create=1)
revdir = os.path.join(pagedir, 'revisions')
cfn = os.path.join(pagedir, 'current')
revstr = '%08d' % 1
if not os.path.exists(revdir):
os.mkdir(revdir)
currentf = open(cfn, 'w')
currentf.write(revstr + "\n")
currentf.close()
pagefile = os.path.join(revdir, revstr)
self._extractToFile(filename, pagefile)
开发者ID:Glottotopia,项目名称:aagd,代码行数:25,代码来源:packages.py
示例15: make_iconlink
def make_iconlink(self, which, d):
"""
Make a link with an icon
@param which: icon id (dictionary key)
@param d: parameter dictionary
@rtype: string
@return: html link tag
"""
page_name, querystr, title, icon = self.button_table[which]
d['title'] = title % d
d['i18ntitle'] = self.request.getText(d['title'], formatted=False)
img_src = self.make_icon(icon, d)
attrs = {'rel': 'nofollow', 'title': d['i18ntitle'], }
if page_name:
page = Page(self.request, page_name % d)
else:
page = d['page']
if self.is_moin_1_5: # Moin 1.5.x
url = wikiutil.quoteWikinameURL(page.page_name)
querystr = wikiutil.makeQueryString(querystr)
if querystr:
url = '%s?%s' % (url, querystr)
html = wikiutil.link_tag(self.request, url, img_src, title="%(i18ntitle)s" % d)
else: # Moin 1.6
rev = d['rev']
if rev and which in ['raw', 'print', ]:
querystr['rev'] = str(rev)
html = page.link_to_raw(self.request, text=img_src, querystr=querystr, **attrs)
return html
开发者ID:130s,项目名称:roswiki,代码行数:30,代码来源:explorer.py
示例16: render
def render(self):
""" Redirect to the new page, using edit action and template """
error = self.checkAndCombineArguments() or self.checkPermissions()
if error:
# Send back to the page you came from, with an error msg
page = Page(self.request, self.referrer)
self.request.theme.add_msg(error, "error")
page.send_page()
else:
# Redirect to new page using edit action. No error checking
# is needed because it is done later in new request.
pagename = self.pagename
query = {'action': 'edit', 'backto': self.referrer}
template = self.request.form.get('template', [''])[0]
if template:
query['template'] = template
parent = self.request.form.get('parent', [''])[0]
if parent:
pagename = "%s/%s" % (parent, pagename)
url = Page(self.request, pagename).url(self.request, query)
self.request.http_redirect(url)
return ''
开发者ID:steveyen,项目名称:moingo,代码行数:26,代码来源:newpage.py
示例17: include
def include(self, name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
# content contains the included file name
_ = self.request.getText
# Limit the number of documents that can be included
if self.num_includes < self.max_includes:
self.num_includes += 1
else:
lines = [_("**Maximum number of allowed includes exceeded**")]
state_machine.insert_input(lines, 'MoinDirectives')
return
if len(content):
pagename = content[0]
page = Page(page_name=pagename, request=self.request)
if not self.request.user.may.read(pagename):
lines = [_("**You are not allowed to read the page: %s**") % (pagename, )]
else:
if page.exists():
text = page.get_raw_body()
lines = text.split('\n')
# Remove the "#format rst" line
if lines[0].startswith("#format"):
del lines[0]
else:
lines = [_("**Could not find the referenced page: %s**") % (pagename, )]
# Insert the text from the included document and then continue parsing
state_machine.insert_input(lines, 'MoinDirectives')
return
开发者ID:IvanLogvinov,项目名称:soar,代码行数:31,代码来源:text_rst.py
示例18: _getPages
def _getPages(request, pagename):
""" Return a (filtered) list of pages names.
"""
page = Page(request, pagename)
#links = page.parsePageLinks(request)
links = page.getPageLinks(request)
return links
开发者ID:130s,项目名称:roswiki,代码行数:7,代码来源:PageNavi.py
示例19: _load_group
def _load_group(self):
request = self.request
group_name = self.name
page = Page(request, group_name)
if page.exists():
arena = 'pagegroups'
key = wikiutil.quoteWikinameFS(group_name)
cache = caching.CacheEntry(request, arena, key, scope='wiki', use_pickle=True)
try:
cache_mtime = cache.mtime()
page_mtime = wikiutil.version2timestamp(page.mtime_usecs())
# TODO: fix up-to-date check mtime granularity problems.
#
# cache_mtime is float while page_mtime is integer
# The comparision needs to be done on the lowest type of both
if int(cache_mtime) > int(page_mtime):
# cache is uptodate
return cache.content()
else:
raise caching.CacheError
except caching.CacheError:
# either cache does not exist, is erroneous or not uptodate: recreate it
members, member_groups = super(WikiGroup, self)._load_group()
cache.update((members, member_groups))
return members, member_groups
else:
raise GroupDoesNotExistError(group_name)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:28,代码来源:wiki_groups.py
示例20: addTrail
def addTrail(self, pagename):
"""
Add page to trail.
@param pagename: the page name to add to the trail
"""
if self.valid and (self.show_page_trail or self.remember_last_visit):
# load trail if not known
self.getTrail()
# don't append tail to trail ;)
if self._trail and self._trail[-1] == pagename: return
# Add only existing pages that the user may read
if self._request:
from MoinMoin.Page import Page
page = Page(self._request, pagename)
if not (page.exists() and
self._request.user.may.read(page.page_name)):
return
# append new page, limiting the length
self._trail = filter(lambda p, pn=pagename: p != pn, self._trail)
self._trail = self._trail[-(self._cfg.trail_size-1):]
self._trail.append(pagename)
# save new trail
trailfile = codecs.open(self.__filename() + ".trail", "w", config.charset)
for t in self._trail:
trailfile.write('%s\n' % t)
trailfile.close()
try:
os.chmod(self.__filename() + ".trail", 0666 & config.umask)
except OSError:
pass
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:35,代码来源:user.py
注:本文中的MoinMoin.Page.Page类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论