本文整理汇总了Python中MoinMoin.PageEditor.PageEditor.getPagePath方法的典型用法代码示例。如果您正苦于以下问题:Python PageEditor.getPagePath方法的具体用法?Python PageEditor.getPagePath怎么用?Python PageEditor.getPagePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.PageEditor.PageEditor
的用法示例。
在下文中一共展示了PageEditor.getPagePath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_addattachment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""):
"""
Installs an attachment
@param pagename: Page where the file is attached. Or in 2.0, the file itself.
@param zipname: Filename of the attachment from the zip file
@param filename: Filename of the attachment (just applicable for MoinMoin < 2.0)
"""
if self.request.user.may.write(pagename):
_ = self.request.getText
attachments = Page(self.request, pagename).getPagePath("attachments", check_create=1)
filename = wikiutil.taintfilename(filename)
zipname = wikiutil.taintfilename(zipname)
target = os.path.join(attachments, filename)
page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author)
rev = page.current_rev()
path = page.getPagePath(check_create=0)
if not os.path.exists(target):
self._extractToFile(zipname, target)
if os.path.exists(target):
os.chmod(target, config.umask )
action = 'ATTNEW'
edit_logfile_append(self, pagename, path, rev, action, logname='edit-log',
comment=u'%(filename)s' % {"filename": filename}, author=author)
self.msg += u"%(filename)s attached \n" % {"filename": filename}
else:
self.msg += u"%(filename)s not attached \n" % {"filename": filename}
else:
self.msg += u"action add attachment: not enough rights - nothing done \n"
示例2: do_delattachment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def do_delattachment(self, filename, pagename, author=u"Scripting Subsystem", comment=u""):
"""
Removes an attachment
@param pagename: Page where the file is attached. Or in 2.0, the file itself.
@param filename: Filename of the attachment (just applicable for MoinMoin < 2.0)
"""
if self.request.user.may.write(pagename):
_ = self.request.getText
attachments = Page(self.request, pagename).getPagePath("attachments", check_create=1)
filename = wikiutil.taintfilename(filename)
target = os.path.join(attachments, filename)
page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author)
rev = page.current_rev()
path = page.getPagePath(check_create=0)
if os.path.exists(target):
os.remove(target)
action = 'ATTDEL'
edit_logfile_append(self, pagename, path, rev, action, logname='edit-log',
comment=u'%(filename)s' % {"filename": filename}, author=author)
self.msg += u"%(filename)s removed \n" % {"filename": filename}
else:
self.msg += u"%(filename)s does not exist \n" % {"filename": filename}
else:
self.msg += u"action delete attachment: not enough rights - nothing done \n"
示例3: nuke_page
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def nuke_page(request, pagename):
""" completely delete a page, everything in the pagedir """
page = PageEditor(request, pagename, do_editor_backup=False)
page.deletePage()
# really get rid of everything there:
fpath = page.getPagePath(check_create=0)
shutil.rmtree(fpath, True)
示例4: rename
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def rename(self):
""" Rename pagename and return the new page """
_ = self.request.getText
form = self.request.form
# Require a valid ticket. Make outside attacks harder by
# requiring two full HTTP transactions
if not wikiutil.checkTicket(form['ticket'][0]):
self.error = _('Please use the interactive user interface to rename pages!')
return
# Get new name from form and normalize.
comment = form.get('comment', [u''])[0]
newpagename = form.get('newpagename')[0]
newpagename = self.request.normalizePagename(newpagename)
# Name might be empty after normalization. To save translation
# work for this extreme case, we just use "EmptyName".
if not newpagename:
newpagename = "EmptyName"
# Valid new name
newpage = PageEditor(self.request, newpagename)
# Check whether a page with the new name already exists
if newpage.exists(includeDeleted=1):
return self.pageExistsError(newpagename)
# Get old page text
savetext = self.page.get_raw_body()
oldpath = self.page.getPagePath(check_create=0)
newpath = newpage.getPagePath(check_create=0)
# Rename page
# NOTE: might fail if another process created newpagename just
# NOW, while you read this comment. Rename is atomic for files -
# but for directories, rename will fail if the directory
# exists. We should have global edit-lock to avoid this.
# See http://docs.python.org/lib/os-file-dir.html
try:
os.rename(oldpath, newpath)
self.newpage = newpage
self.error = None
# Save page text with a comment about the old name
savetext = u"## page was renamed from %s\n%s" % (self.pagename, savetext)
newpage.saveText(savetext, 0, comment=comment)
except OSError, err:
# Try to understand what happened. Maybe its better to check
# the error code, but I just reused the available code above...
if newpage.exists(includeDeleted=1):
return self.pageExistsError(newpagename)
else:
self.error = _('Could not rename page because of file system'
' error: %s.') % unicode(err)
示例5: nuke_page
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def nuke_page(request, pagename):
""" completely delete a page, everything in the pagedir """
attachments = AttachFile._get_files(request, pagename)
for attachment in attachments:
AttachFile.remove_attachment(request, pagename, attachment)
page = PageEditor(request, pagename, do_editor_backup=False)
page.deletePage()
# really get rid of everything there:
fpath = page.getPagePath(check_create=0)
shutil.rmtree(fpath, True)
示例6: do_replaceunderlayattachment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
def do_replaceunderlayattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""):
"""
overwrite underlay attachments
@param pagename: Page where the file is attached. Or in 2.0, the file itself.
@param zipname: Filename of the attachment from the zip file
@param filename: Filename of the attachment (just applicable for MoinMoin < 2.0)
"""
if self.request.user.may.write(pagename):
_ = self.request.getText
filename = wikiutil.taintfilename(filename)
zipname = wikiutil.taintfilename(zipname)
page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author)
pagedir = page.getPagePath(use_underlay=1, check_create=1)
attachments = os.path.join(pagedir, 'attachments')
if not os.path.exists(attachments):
os.mkdir(attachments)
target = os.path.join(attachments, filename)
self._extractToFile(zipname, target)
if os.path.exists(target):
filesys.chmod(target, 0666 & config.umask)
else:
self.msg += u"action replace underlay attachment: not enough rights - nothing done \n"
示例7: __init__
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import getPagePath [as 别名]
class RenamePage:
""" Rename page action
Note: the action name is the class name
"""
def __init__(self, pagename, request):
self.request = request
self.pagename = pagename
self.page = PageEditor(request, pagename)
self.newpage = None
self.error = ''
def allowed(self):
""" Check if user is allowed to do this
This could be a standard method of the base action class, doing
the filtering by action class name and cfg.allowed_actions.
"""
may = self.request.user.may
return (self.__class__.__name__ in self.request.cfg.allowed_actions and
may.write(self.pagename) and may.delete(self.pagename))
def render(self):
""" Render action
This action return a wiki page with optional message, or
redirect to new page.
"""
_ = self.request.getText
form = self.request.form
if form.has_key('cancel'):
# User canceled
return self.page.send_page(self.request)
# Validate user rights and page state. If we get error here, we
# return an error message, without the rename form.
error = None
if not self.allowed():
error = _('You are not allowed to rename pages in this wiki!')
elif not self.page.exists():
error = _('This page is already deleted or was never created!')
if error:
# Send page with an error message
return self.page.send_page(self.request, msg=error)
# Try to rename. If we get an error here, we return the error
# message with a rename form.
elif (form.has_key('rename') and form.has_key('newpagename') and
form.has_key('ticket')):
# User replied to the rename form with all required items
self.rename()
if not self.error:
self.request.http_redirect(self.newpage.url(self.request))
return self.request.finish()
# A new form request, or form has missing data, or rename
# failed. Return a new form with optional error.
return self.page.send_page(self.request, msg=self.makeform())
def rename(self):
""" Rename pagename and return the new page """
_ = self.request.getText
form = self.request.form
# Require a valid ticket. Make outside attacks harder by
# requiring two full HTTP transactions
if not wikiutil.checkTicket(form['ticket'][0]):
self.error = _('Please use the interactive user interface to rename pages!')
return
# Get new name from form and normalize.
comment = form.get('comment', [u''])[0]
newpagename = form.get('newpagename')[0]
newpagename = self.request.normalizePagename(newpagename)
# Name might be empty after normalization. To save translation
# work for this extreme case, we just use "EmptyName".
if not newpagename:
newpagename = "EmptyName"
# Valid new name
newpage = PageEditor(self.request, newpagename)
# Check whether a page with the new name already exists
if newpage.exists(includeDeleted=1):
return self.pageExistsError(newpagename)
# Get old page text
savetext = self.page.get_raw_body()
oldpath = self.page.getPagePath(check_create=0)
newpath = newpage.getPagePath(check_create=0)
# Rename page
# NOTE: might fail if another process created newpagename just
# NOW, while you read this comment. Rename is atomic for files -
# but for directories, rename will fail if the directory
# exists. We should have global edit-lock to avoid this.
#.........这里部分代码省略.........