本文整理汇总了Python中MoinMoin.PageEditor.PageEditor类的典型用法代码示例。如果您正苦于以下问题:Python PageEditor类的具体用法?Python PageEditor怎么用?Python PageEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PageEditor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: xmlrpc_revertPage
def xmlrpc_revertPage(self, pagename, revision):
"""
Revert a page to previous revision
This is mainly intended to be used by the jabber bot.
@param pagename: the page name (unicode or utf-8)
@param revision: revision to revert to
@rtype: bool
@return: True on success
"""
pagename = self._instr(pagename)
if not self.request.user.may.write(pagename):
return xmlrpclib.Fault(1, "You are not allowed to edit this page")
rev = int(self._instr(revision))
editor = PageEditor(self.request, pagename, do_editor_backup=0)
try:
editor.revertPage(rev)
except PageEditor.SaveError, error:
return xmlrpclib.Fault(1, "Revert failed: %s" % (str(error), ))
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:25,代码来源:__init__.py
示例2: do_action
def do_action(self):
""" Rename this page to "pagename" """
_ = self._
form = self.form
newpagename = form.get('newpagename', [u''])[0]
newpagename = self.request.normalizePagename(newpagename)
comment = form.get('comment', [u''])[0]
comment = wikiutil.clean_input(comment)
self.page = PageEditor(self.request, self.pagename)
success, msgs = self.page.renamePage(newpagename, comment)
rename_subpages = 0
if 'rename_subpages' in form:
try:
rename_subpages = int(form['rename_subpages'][0])
except:
pass
if rename_subpages and self.subpages:
for name in self.subpages:
self.page = PageEditor(self.request, name)
new_subpagename = name.replace(self.pagename, newpagename, 1)
success_i, msg = self.page.renamePage(new_subpagename, comment)
msgs = "%s %s" % (msgs, msg)
self.newpagename = newpagename # keep there for finish
return success, msgs
开发者ID:steveyen,项目名称:moingo,代码行数:28,代码来源:RenamePage.py
示例3: do_addattachment
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"
开发者ID:steveyen,项目名称:moingo,代码行数:30,代码来源:packages.py
示例4: xmlrpc_putPage
def xmlrpc_putPage(self, pagename, pagetext):
"""
save a page / change a page to a new text
@param pagename: the page name (unicode or utf-8)
@param pagetext: the new page text (content, unicode or utf-8)
@rtype: bool
@return: True on success
"""
pagename = self._instr(pagename)
pagename = wikiutil.normalize_pagename(pagename, self.cfg)
if not pagename:
return xmlrpclib.Fault("INVALID", "pagename can't be empty")
# check ACLs
if not self.request.user.may.write(pagename):
return xmlrpclib.Fault(1, "You are not allowed to edit this page")
page = PageEditor(self.request, pagename, do_editor_backup=0)
try:
if self.version == 2:
newtext = self._instr(pagetext)
elif self.version == 1:
newtext = self._inlob(pagetext)
msg = page.saveText(newtext, 0)
except page.SaveError, msg:
logging.error("SaveError: %s" % msg)
return xmlrpclib.Fault(1, "%s" % msg)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:28,代码来源:__init__.py
示例5: execute
def execute(pagename, request):
request.headers["Content-Type"] = "text/plain; charset=ascii"
if request.environ['REQUEST_METHOD'] != 'POST':
return
form = values_to_form(request.values)
content = form.get('content', [None])[0]
if not content:
sendfault(request, "Missing page content")
return
pagename = normalize_pagename(pagename, request.cfg)
if not pagename:
sendfault(request, "No page name entered")
return
if not request.user.may.write(pagename):
sendfault(request, "You are not allowed to edit this page")
return
page = PageEditor(request, pagename)
if page.exists():
sendfault(request, "Page already exists.")
return
msg = ""
try:
msg = page.saveText(content, 0)
except page.SaveError, msg:
sendfault(request, "Failed to save page: %s" % pagename)
return
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:32,代码来源:putPageJSON.py
示例6: do_action
def do_action(self):
""" Delete pagename """
form = self.form
comment = form.get('comment', [u''])[0]
comment = wikiutil.clean_input(comment)
# Create a page editor that does not do editor backups, because
# delete generates a "deleted" version of the page.
self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
success, msgs = self.page.deletePage(comment)
delete_subpages = 0
if 'delete_subpages' in form:
try:
delete_subpages = int(form['delete_subpages'][0])
except:
pass
if delete_subpages and self.subpages:
for name in self.subpages:
self.page = PageEditor(self.request, name, do_editor_backup=0)
success_i, msg = self.page.deletePage(comment)
msgs = "%s %s" % (msgs, msg)
return success, msgs
开发者ID:steveyen,项目名称:moingo,代码行数:25,代码来源:DeletePage.py
示例7: do_delattachment
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"
开发者ID:steveyen,项目名称:moingo,代码行数:26,代码来源:packages.py
示例8: mainloop
def mainloop(self):
self.init_request()
request = self.request
request.user.may = IAmRoot()
request.cfg.mail_enabled = False
for root, dirs, files in os.walk(self.options.file_dir):
files.sort()
for filename in files:
pagename = self.options.page + filename_function(filename)
#print "Pushing %r as %r" % (filename, pagename)
p = PageEditor(request, pagename, do_editor_backup=0, uid_override=self.options.author, do_revision_backup=0)
if p.exists():
if filename != files[-1]:
continue
else:
p = PageEditor(request, pagename, do_editor_backup=0, uid_override=self.options.author)
fileObj = open(os.path.join(root, filename), 'rb')
try:
acl = ""
if self.options.acl:
acl = "#acl %s\n" % (self.options.acl, )
p.saveText(acl + "#format irc\n" + decodeLinewise(fileObj.read()), 0)
except PageEditor.Unchanged, e:
pass
except PageEditor.SaveError, e:
print "Got %r" % (e, )
fileObj.close()
开发者ID:steveyen,项目名称:moingo,代码行数:28,代码来源:irclog.py
示例9: save
def save(self, editor, newtext, rev, **kw):
request = self.request
username = request.user.name
pagename = editor.page_name
if grouppage_autocreate and username == pagename:
# create group pages when a user saves his own homepage
for page in grouppages:
grouppagename = "%s/%s" % (username, page)
grouppage = Page(request, grouppagename)
if not grouppage.exists():
text = """\
#acl %(username)s:read,write,delete,revert
* %(username)s
""" % locals()
editor = PageEditor(request, grouppagename)
editor._write_file(text)
parts = pagename.split('/')
if len(parts) == 2:
subpage = parts[1]
if subpage in grouppages and not self.admin(pagename):
return False
# No problem to save if my base class agrees
return Permissions.save(self, editor, newtext, rev, **kw)
开发者ID:Glottotopia,项目名称:aagd,代码行数:26,代码来源:autoadmin.py
示例10: do_action
def do_action(self):
""" Load """
status = False
_ = self._
form = self.form
request = self.request
comment = form.get('comment', [u''])[0]
comment = wikiutil.clean_input(comment)
filename = form.get('file__filename__')
rename = form.get('rename', [''])[0].strip()
if rename:
target = rename
else:
target = filename
target = AttachFile.preprocess_filename(target)
target = wikiutil.clean_input(target)
if target:
filecontent = form['file'][0]
if hasattr(filecontent, 'read'): # a file-like object
filecontent = filecontent.read() # XXX reads complete file into memory!
filecontent = wikiutil.decodeUnknownInput(filecontent)
self.pagename = target
pg = PageEditor(request, self.pagename)
try:
msg = pg.saveText(filecontent, 0, comment=comment)
status = True
except pg.EditConflict, e:
msg = e.message
except pg.SaveError, msg:
msg = unicode(msg)
开发者ID:steveyen,项目名称:moingo,代码行数:35,代码来源:Load.py
示例11: do_action
def do_action(self):
""" copy this page to "pagename" """
_ = self._
# Currently we only check TextCha for upload (this is what spammers ususally do),
# but it could be extended to more/all attachment write access
if not TextCha(self.request).check_answer_from_form():
return status, _('TextCha: Wrong answer! Go back and try again...')
form = self.form
newpagename = form.get('newpagename', u'')
newpagename = wikiutil.normalize_pagename(newpagename, self.cfg)
comment = form.get('comment', u'')
comment = wikiutil.clean_input(comment)
self.page = PageEditor(self.request, self.pagename)
success, msgs = self.page.copyPage(newpagename, comment)
copy_subpages = 0
try:
copy_subpages = int(form['copy_subpages'])
except:
pass
if copy_subpages and self.subpages or (not self.users_subpages and self.subpages):
for name in self.subpages:
self.page = PageEditor(self.request, name)
new_subpagename = name.replace(self.pagename, newpagename, 1)
success_i, msg = self.page.copyPage(new_subpagename, comment)
msgs = "%s %s" % (msgs, msg)
self.newpagename = newpagename # keep there for finish
return success, msgs
开发者ID:IvanLogvinov,项目名称:soar,代码行数:32,代码来源:CopyPage.py
示例12: execute
def execute(pagename, request):
form = values_to_form(request.values)
template = form.get('template', [''])[0]
if template and not request.page.exists():
template_page = wikiutil.unquoteWikiname(template)
if request.user.may.read(template_page):
editor = PageEditor(request, template_page)
editor.user = request.user
text = editor.get_raw_body()
editor.page_name = pagename
request.page.set_raw_body(editor._expand_variables(text))
newdata = parse_text(request, request.page,
request.page.get_raw_body())
# Add prototype metas (^ something::\s*$) as keys
protokeys = [y for x,y in dl_proto_re.findall(text)]
for key in protokeys:
if not (key in newdata[pagename].get('out', dict()) or
key in newdata[pagename].get('meta', dict())):
newdata[pagename].setdefault('meta', dict())[key] = list()
# I'll lie, cheat, do anything to make this work
newdata[pagename]['saved'] = True
# Add the template metas to cache so that they'd show
request.graphdata.cacheset(pagename, newdata.get(pagename, dict()))
MetaEdit.execute(pagename, request)
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:30,代码来源:editmeta.py
示例13: group_del
def group_del(request, grouppage, accounts):
_ = request.getText
success, msg = check_grouppage(request, grouppage)
if not success:
raise GroupException(msg + "(%s)" % (grouppage))
members = request.groups[grouppage].members | request.groups[grouppage].member_groups
for name in accounts:
if name not in members:
raise GroupException(name + _(' not in group: ') + grouppage)
page = PageEditor(request, grouppage)
pagetext = page.get_raw_body()
newtext = _group_del(request, pagetext, accounts)
msg = page.saveText(newtext, 0,
comment="Deleted from group: " +
', '.join(accounts))
newmembers = request.groups[grouppage].members | request.groups[grouppage].member_groups
if not newmembers == members - set(accounts):
msg = page.saveText(pagetext, 0,
comment="Reverting due to problems in group operation.")
raise GroupException(_('Delete unsuccessful for unknown reasons.'))
return True, msg
开发者ID:execgit,项目名称:graphingwiki,代码行数:27,代码来源:groups.py
示例14: test_acls
def test_acls(self):
p = PageEditor(self.request, self.pagename)
oldacl = p.getACL(self.request).acl
assert not self.request.user.may.admin(p.page_name)
newacl = parseACL(self.request, self.newtext).acl
assert newacl != oldacl
py.test.raises(PageEditor.NoAdmin, p.saveText, self.newtext, 0)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:7,代码来源:test_PageEditor.py
示例15: nuke_page
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)
开发者ID:steveyen,项目名称:moingo,代码行数:7,代码来源:__init__.py
示例16: deletecomment
def deletecomment(macro, delkey, delpasswd):
# Deletes a comment with given index and password
request = Globs.macro.request
formatter = Globs.macro.formatter
datapagename = Globs.datapagename
_ = request.getText
if Params.encryptpass:
from MoinMoin import user
delpasswd = user.encodePassword(delpasswd)
pg = PageEditor( request, datapagename )
pagetext = pg.get_raw_body()
regex = ur"""
(?P<comblock>
^[\{]{3}\n
^(?P<icon>[^\n]*)\n
^(?P<name>[^\n]*)\n
^(?P<date>[^\n]*)[\n]+
^(?P<text>
\s*.*?
(?=[\}]{3})
)[\}]{3}[\n]*
^[#]{2}PASSWORD[ ](?P<passwd>[^\n]*)[\n]*
^[#]{2}LOGINUSER[ ](?P<loginuser>[^\n]*)[\n$]*
)"""
pattern = re.compile(regex, re.UNICODE + re.MULTILINE + re.VERBOSE + re.DOTALL)
commentitems = pattern.findall(pagetext)
for item in commentitems:
if delkey == item[3].strip():
comauthor = item[2]
if Globs.admin or (request.user.valid and request.user.name == comauthor) or delpasswd == item[5]:
newpagetext = pagetext.replace(item[0], '', 1)
action = 'SAVE'
comment = 'Deleted comment by "%s"' % comauthor
trivial = 1
pg._write_file(newpagetext, action, u'PageComment modification at %s' % Globs.curpagename)
addLogEntry(request, 'COMDEL', Globs.curpagename, comment)
msg = _('The comment is deleted.')
# send notification mails
if Params.notify:
msg = msg + commentNotify(comment, trivial)
message(msg)
return
else:
message(_('Sorry, wrong password.'))
return
message(_('No such comment'))
开发者ID:130s,项目名称:roswiki,代码行数:59,代码来源:PageComment2.py
示例17: create_page
def create_page(request, pagename, content, do_editor_backup=False):
""" create a page with some content """
# make sure there is nothing already there:
nuke_page(request, pagename)
# now create from scratch:
page = PageEditor(request, pagename, do_editor_backup=do_editor_backup)
page.saveText(content, 0)
return page
开发者ID:happytk,项目名称:moin,代码行数:8,代码来源:__init__.py
示例18: append_page
def append_page(request, pagename, content, do_editor_backup=False):
""" appends some conetent to an existing page """
# reads the raw text of the existing page
raw = Page(request, pagename).get_raw_body()
# adds the new content to the old
content = "%s\n%s\n"% (raw, content)
page = PageEditor(request, pagename, do_editor_backup=do_editor_backup)
page.saveText(content, 0)
return page
开发者ID:happytk,项目名称:moin,代码行数:9,代码来源:__init__.py
示例19: ownPutPage
def ownPutPage(request, pagename, pagetext):
if not request.user.may.write(pagename):
return False
page = PageEditor(request, pagename)
try:
msg = page.saveText(pagetext, 0)
except page.SaveError, msg:
pass
开发者ID:graphingwiki,项目名称:gwiki-with-moin,代码行数:9,代码来源:ClarifiedCookie.py
示例20: savetext
def savetext(request, pagename, newtext, **kw):
page = PageEditor(request, pagename)
try:
msg = page.saveText(newtext, 0, **kw)
except page.Unchanged:
msg = u'Unchanged'
return msg
开发者ID:execgit,项目名称:gwiki-with-moin,代码行数:9,代码来源:moin_editpage.py
注:本文中的MoinMoin.PageEditor.PageEditor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论