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


Python WikiPage.delete方法代码示例

本文整理汇总了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()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:util.py

示例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()
开发者ID:dhoess,项目名称:geekedit,代码行数:10,代码来源:geekedit.py

示例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
开发者ID:kzhamaji,项目名称:TracFullBlogPlugin,代码行数:58,代码来源:migrate-tracblog.py

示例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
开发者ID:nextview,项目名称:tracxmlrpc,代码行数:13,代码来源:wiki.py


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