本文整理汇总了Python中trac.wiki.model.WikiPage.delete方法的典型用法代码示例。如果您正苦于以下问题:Python WikiPage.delete方法的具体用法?Python WikiPage.delete怎么用?Python WikiPage.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.wiki.model.WikiPage
的用法示例。
在下文中一共展示了WikiPage.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_wiki_page
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import delete [as 别名]
def copy_wiki_page(source_env, dest_env, name, dest_db=None):
# In case a string gets passed in
if not isinstance(source_env, Environment):
source_env = _open_environment(source_env)
if not isinstance(dest_env, Environment):
dest_env = _open_environment(dest_env)
# Log message
source_env.log.info('DatamoverPlugin: Moving page %s to the environment at %s', name, dest_env.path)
dest_env.log.info('DatamoverPlugin: Moving page %s from the environment at %s', name, source_env.path)
# Open databases
source_db = source_env.get_db_cnx()
source_cursor = source_db.cursor()
handle_commit = True
if not dest_db:
dest_db, handle_commit = dest_env.get_db_cnx(), False
dest_cursor = dest_db.cursor()
# Remove the page from the destination
dest_page = WikiPage(dest_env, name, db=dest_db)
if dest_page.exists:
dest_page.delete(db=dest_db)
# Copy each entry in the wiki table
source_cursor.execute('SELECT * FROM wiki WHERE name=%s',(name,))
for row in source_cursor:
wiki_data = dict(zip([d[0] for d in source_cursor.description], row))
q = make_query(wiki_data, 'wiki')
dest_cursor.execute(*q)
if handle_commit:
dest_db.commit()
示例2: delete_wiki_page_in_trac
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import delete [as 别名]
def delete_wiki_page_in_trac(self, filename):
page = WikiPage(self.env, filename)
page.delete()
conn = self.env.get_db_cnx()
c = conn.cursor()
c.execute("DELETE FROM wiki_local WHERE name = '%s'" % filename)
conn.commit()
conn.close()
示例3: Main
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import delete [as 别名]
def Main(opts):
""" Cross your fingers and pray """
env = Environment(opts.envpath)
from tractags.api import TagSystem
tlist = opts.tags or split_tags(env.config.get('blog', 'default_tag',
'blog'))
tags = TagSystem(env)
req = Mock(perm=MockPerm())
blog = tags.query(req, ' '.join(tlist + ['realm:wiki']))
cnx = env.get_db_cnx()
for resource, page_tags in list(blog):
try:
page = WikiPage(env, version=1, name=resource.id)
_, publish_time, author, _, _ = page.get_history().next()
if opts.deleteonly:
page.delete()
continue
categories = ' '.join([t for t in page_tags if t not in tlist])
page = WikiPage(env, name=resource.id)
for version, version_time, version_author, version_comment, \
_ in page.get_history():
# Currently the basename of the post url is used due to
# http://trac-hacks.org/ticket/2956
#name = resource.id.replace('/', '_')
name = resource.id
# extract title from text:
fulltext = page.text
match = _title_split_match(fulltext)
if match:
title = match.group(1)
fulltext = match.group(2)
else:
title = name
body = fulltext
print "Adding post %s, v%s: %s" % (name, version, title)
insert_blog_post(cnx, name, version, title, body,
publish_time, version_time,
version_comment, version_author, author,
categories)
reparent_blog_attachments(env, resource.id, name)
continue
cnx.commit()
if opts.delete:
page.delete()
continue
except:
env.log.debug("Error loading wiki page %s" % resource.id,
exc_info=True)
print "Failed to add post %s, v%s: %s" % (name, version, title)
cnx.rollback()
cnx.close()
return 1
cnx.close()
return 0
示例4: deletePage
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import delete [as 别名]
def deletePage(self, req, name, version=None):
"""Delete a Wiki page (all versions) or a specific version by
including an optional version number. Attachments will also be
deleted if page no longer exists. Returns True for success."""
wp = WikiPage(self.env, name, version)
req.perm(wp.resource).require("WIKI_DELETE")
try:
wp.delete(version)
return True
except:
return False