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


Python WikiPage.save方法代码示例

本文整理汇总了Python中trac.wiki.WikiPage.save方法的典型用法代码示例。如果您正苦于以下问题:Python WikiPage.save方法的具体用法?Python WikiPage.save怎么用?Python WikiPage.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.wiki.WikiPage的用法示例。


在下文中一共展示了WikiPage.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_update_page(self):
        cursor = self.db.cursor()
        cursor.execute(
            "INSERT INTO wiki VALUES(%s,%s,%s,%s,%s,%s,%s,%s)",
            ("TestPage", 1, 42, "joe", "::1", "Bla bla", "Testing", 0),
        )

        page = WikiPage(self.env, "TestPage")
        page.text = "Bla"
        page.save("kate", "Changing", "192.168.0.101", 43)

        cursor.execute(
            "SELECT version,time,author,ipnr,text,comment," "readonly FROM wiki WHERE name=%s", ("TestPage",)
        )
        self.assertEqual((1, 42, "joe", "::1", "Bla bla", "Testing", 0), cursor.fetchone())
        self.assertEqual((2, 43, "kate", "192.168.0.101", "Bla", "Changing", 0), cursor.fetchone())

        listener = TestWikiChangeListener(self.env)
        self.assertEqual((page, 2, 43, "Changing", "kate", "192.168.0.101"), listener.changed[0])

        page = WikiPage(self.env, "TestPage")
        history = list(page.get_history())
        self.assertEqual(2, len(history))
        self.assertEqual((2, 43, "kate", "Changing", "192.168.0.101"), history[0])
        self.assertEqual((1, 42, "joe", "Testing", "::1"), history[1])
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:27,代码来源:model.py

示例2: process_request

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def process_request(self, req):
        req.perm.assert_permission ('WIKI_MODIFY')
        page_name = req.args['target_page'][req.args['target_page'].find('wiki')+5:]
        p = WikiPage(self.env, page_name )

        author_name = req.authname
        comment_text = req.args['comment']
        comment_parent = req.args['comment_parent']
        dt = datetime.now()
        comment_date = dt.strftime("%Y-%m-%d %H:%M:%S")
        comment_id = "%032x" % random.getrandbits(128)
        redirect_url = "%s%s#%s" % (req.base_path, req.args['target_page'],comment_id)
        changeset_comment = "%s..." % comment_text[:20]

        insertion_index = string.find( p.text, "=%s" % comment_parent )
        if ( insertion_index != -1 ):
            heads = string.count(p.text,"{{{#!WikiComments",0,insertion_index)
            tails = string.count(p.text,"}}}",0,insertion_index)
            level = heads - tails
            padding = ""
            comment_out = '%s{{{#!WikiComments author="%s" date="%s" id="%s""\n%s%s\n%s=%s\n%s}}}\n' \
                % (padding, author_name,comment_date,comment_id,padding,comment_text,padding,comment_id,padding)
            p.text = p.text[:insertion_index]+comment_out+p.text[insertion_index:]

        p.save( author_name, changeset_comment, req.remote_addr )
        req.redirect(redirect_url)
开发者ID:jarnik,项目名称:trac-wikicomments,代码行数:28,代码来源:wikicomments.py

示例3: _do_uploadPicture

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def _do_uploadPicture(self, req, userProfile, teamRosterData, req_arg_picture = 'tr_userProfile_picture' ):
        
        upload = req.args.get(req_arg_picture, None)
        if upload == None or not hasattr(upload, 'filename') or not upload.filename:
            return userProfile.picture_href
        
        if hasattr(upload.file, 'fileno'):
            size = os.fstat(upload.file.fileno())[6]
        else:
            upload.file.seek(0, 2) # seek to end of file
            size = upload.file.tell()
            upload.file.seek(0)
        if size == 0:
            raise TracError(_("Can't upload empty file"))

        filename = upload.filename
        filename = filename.replace('\\', '/').replace(':', '/')        
        filename = os.path.basename(filename)
        
        if not filename:
            raise TracError(_('No file uploaded'))
        
        page = WikiPage(self.env,  self.teamRoster_wikiPage)
        if not page.exists:
            page.text="= Team Roster Pictures ="
            page.save( 'trac', 'Page created by tracteamroster component',  req.remote_addr)
       
              
        attachment = Attachment(self.env, 'wiki', self.teamRoster_wikiPage)
        attachment.author = get_reporter_id(req, 'author')
        attachment.ipnr = req.remote_addr
        attachment.insert('_'.join([userProfile.id, filename]), upload.file, size)
        
        return req.href('/'.join(['raw-attachment', 'wiki',self.teamRoster_wikiPage,attachment.filename]))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:36,代码来源:admin.py

示例4: test_update_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_update_page(self):
        cursor = self.db.cursor()
        t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        cursor.execute("INSERT INTO wiki VALUES(%s,%s,%s,%s,%s,%s,%s,%s)",
                       ('TestPage', 1, to_timestamp(t), 'joe', '::1', 'Bla bla',
                        'Testing', 0))

        page = WikiPage(self.env, 'TestPage')
        page.text = 'Bla'
        page.save('kate', 'Changing', '192.168.0.101', t2)
        self.assertEqual(2, page.resource.version)

        cursor.execute("SELECT version,time,author,ipnr,text,comment,"
                       "readonly FROM wiki WHERE name=%s", ('TestPage',))
        self.assertEqual((1, to_timestamp(t), 'joe', '::1', 'Bla bla', 'Testing', 0),
                         cursor.fetchone())
        self.assertEqual((2, to_timestamp(t2), 'kate', '192.168.0.101', 'Bla',
                          'Changing', 0), cursor.fetchone())

        listener = TestWikiChangeListener(self.env)
        self.assertEqual((page, 2, t2, 'Changing', 'kate', '192.168.0.101'),
                         listener.changed[0])

        page = WikiPage(self.env, 'TestPage')
        history = list(page.get_history())
        self.assertEqual(2, len(history))
        self.assertEqual((2, t2, 'kate', 'Changing', '192.168.0.101'),
                         history[0])
        self.assertEqual((1, t, 'joe', 'Testing', '::1'), history[1])
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:32,代码来源:model.py

示例5: test_wiki_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_wiki_page(self):
        page = WikiPage(self.env, 'NewPage')
        page.text = 'Lorem ipsum dolor sit amet'
        # TODO Tags
        page.save('santa', 'Commment', 'northpole.example.com')
        so = self._get_so()
        self.assertEquals('%s:wiki:NewPage' % self.basename, so.doc_id)
        self.assertEquals('wiki', so.realm)
        self.assertEquals('NewPage', so.id)
        self.assertTrue('NewPage' in so.title)
        self.assertTrue('Lorem ipsum' in so.title)
        self.assertEquals('santa', so.author)
        self.assertEquals(page.time, so.created)
        self.assertEquals(page.time, so.changed)
        self.assertTrue('santa' in so.involved)
        self.assertTrue('Lorem ipsum' in so.oneline)
        self.assertTrue('Lorem ipsum' in so.body)

        original_time = page.time
        page.text = 'No latin filler here'
        page.save('Jack Sprat', 'Could eat no fat', 'dinnertable.local')
        so = self._get_so()
        self.assertEquals('%s:wiki:NewPage' % self.basename, so.doc_id)
        self.assertEquals('wiki', so.realm)
        self.assertEquals('NewPage', so.id)
        self.assertEquals(original_time, so.created)
        self.assertEquals(page.time, so.changed)
        self.assertFalse('Lorem ipsum' in so.body)
        self.assertTrue('No latin filler here' in so.body)
        self.assertTrue('Could eat no fat' in so.comments)
开发者ID:getpenelope,项目名称:fulltextsearchplugin,代码行数:32,代码来源:fulltextsearch.py

示例6: _create_wiki_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
 def _create_wiki_page(self, name=None):
     name = name or self.INITIAL_NAME
     wiki_page = WikiPage(self.env, name)
     wiki_page.text = self.INITIAL_TEXT
     wiki_page.save(
         self.INITIAL_AUTHOR,
         self.INITIAL_COMMENT,
         self.INITIAL_REMOTE_ADDRESS)
     return wiki_page
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:11,代码来源:model.py

示例7: test_wiki_page_unicode_error

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
 def test_wiki_page_unicode_error(self):
     import pkg_resources
     import define
     text = open(pkg_resources.resource_filename(define.__name__, 'default-pages/DefineGuide%2FTicketTutorial')).read()
     page = WikiPage(self.env, 'TicketTutorial')
     page.text = text.decode('utf-8')
     page.save('olle', 'Comment', 'define.logica.com')
     so = self._get_so()
     self.assertEquals('%s:wiki:TicketTutorial' % self.basename, so.doc_id)
开发者ID:getpenelope,项目名称:fulltextsearchplugin,代码行数:11,代码来源:fulltextsearch.py

示例8: test_parseTestcase_parseWikiPage

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
def test_parseTestcase_parseWikiPage(build_trac_env):
    env = build_trac_env

    wikipage = WikiPage(env, "TcTestplanCreate")
    wikipage.text = TESTCASE.decode("utf-8")
    wikipage.save("pytest", "comment", "127.0.0.1")

    tcp = TestcaseParser(env)
    testcase = tcp.parseTestcase(pagename="TcTestplanCreate")
    assert len(testcase.actions) == 5
开发者ID:InQuant,项目名称:TracTestManager,代码行数:12,代码来源:test_parser.py

示例9: test_can_index_changed_event

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
 def test_can_index_changed_event(self):
     #arrange
     self.insert_wiki(self.DUMMY_PAGE_NAME, "Text to be changed")
     page = WikiPage(self.env, self.DUMMY_PAGE_NAME)
     page.text = "changed text with keyword"
     page.save("anAuthor", "some comment", "::1")
     #act
     results = self.search_api.query("*:*")
     #assert
     self.print_result(results)
     self.assertEqual(1, results.hits)
     doc = results.docs[0]
     self.assertEqual("changed text with keyword", doc["content"])
开发者ID:mohsadki,项目名称:dargest,代码行数:15,代码来源:wiki_search.py

示例10: test_can_index_version_deleted_event

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
 def test_can_index_version_deleted_event(self):
     #arrange
     self.insert_wiki(self.DUMMY_PAGE_NAME, "version1")
     page = WikiPage(self.env, self.DUMMY_PAGE_NAME)
     page.text = "version 2"
     page.save("anAuthor", "some comment", "::1")
     page.delete(version=2)
     #act
     results = self.search_api.query("*:*")
     #assert
     self.print_result(results)
     self.assertEqual(1, results.hits)
     self.assertEqual("version1", results.docs[0]["content"])
开发者ID:mohsadki,项目名称:dargest,代码行数:15,代码来源:wiki_search.py

示例11: test_create_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_create_page(self):
        page = WikiPage(self.env)
        page.name = "TestPage"
        page.text = "Bla bla"
        page.save("joe", "Testing", "::1", 42)

        cursor = self.db.cursor()
        cursor.execute(
            "SELECT version,time,author,ipnr,text,comment," "readonly FROM wiki WHERE name=%s", ("TestPage",)
        )
        self.assertEqual((1, 42, "joe", "::1", "Bla bla", "Testing", 0), cursor.fetchone())

        listener = TestWikiChangeListener(self.env)
        self.assertEqual(page, listener.added[0])
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:16,代码来源:model.py

示例12: test_create_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_create_page(self):
        page = WikiPage(self.env)
        page.name = 'TestPage'
        page.text = 'Bla bla'
        t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        page.save('joe', 'Testing', '::1', t)

        cursor = self.db.cursor()
        cursor.execute("SELECT version,time,author,ipnr,text,comment,"
                       "readonly FROM wiki WHERE name=%s", ('TestPage',))
        self.assertEqual((1, to_timestamp(t), 'joe', '::1', 'Bla bla', 'Testing', 0),
                         cursor.fetchone())

        listener = TestWikiChangeListener(self.env)
        self.assertEqual(page, listener.added[0])
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:17,代码来源:model.py

示例13: get_uploaded_file_href

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def get_uploaded_file_href(self, req, user, field, req_field):
        """Returns uploaded file's url
        
        @param req: trac.web.req
        @param user: tracusermanager.api.User
        @param field: str
        @param req_field: str 
        @return: str
        """
        
        # validate request field
        upload = req.args.get(req_field, None)
        if upload == None or not hasattr(upload, 'filename') or not upload.filename:
            return user[field]
        
        if hasattr(upload.file, 'fileno'):
            size = os.fstat(upload.file.fileno())[6]
        else:
            upload.file.seek(0, 2) # seek to end of file
            size = upload.file.tell()
            upload.file.seek(0)
        if size == 0:
            raise TracError(_("Can't upload empty file"))

        filename = upload.filename
        filename = filename.replace('\\', '/').replace(':', '/')        
        filename = os.path.basename(filename)
        
        if not filename:
            raise TracError(_('No file uploaded'))
        
        page = WikiPage(self.env,  self.attachments_wikiPage)
        if not page.exists:
            page.text="= UserManager's Attachments ="
            page.save( 'trac', 'Page created by tracusermanager.profile component',  req.remote_addr)
       
        attachment = Attachment(self.env, 'wiki', self.attachments_wikiPage)
        attachment.author = get_reporter_id(req, 'author')
        attachment.ipnr = req.remote_addr
        attachment.description = (_("%s\'s Avatar") % (user.username))
        attachment.insert('_'.join([user.username, filename]), upload.file, size)
        
        return req.href('/'.join(['raw-attachment', 'wiki',self.attachments_wikiPage, attachment.filename]))
开发者ID:ejucovy,项目名称:trac-UserManagerPlugin,代码行数:45,代码来源:api.py

示例14: test_invalid_page_name

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_invalid_page_name(self):
        invalid_names = ('../Page', 'Page/..', 'Page/////SubPage',
                         'Page/./SubPage', '/PagePrefix', 'PageSuffix/')

        for name in invalid_names:
            page = WikiPage(self.env)
            page.name = name
            page.text = 'Bla bla'
            t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
            self.assertRaises(TracError, page.save, 'joe', 'Testing', '::1', t)

        page = WikiPage(self.env)
        page.name = 'TestPage'
        page.text = 'Bla bla'
        t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        page.save('joe', 'Testing', '::1', t)
        for name in invalid_names:
            page = WikiPage(self.env, 'TestPage')
            self.assertRaises(TracError, page.rename, name)
开发者ID:exocad,项目名称:exotrac,代码行数:21,代码来源:model.py

示例15: test_update_page

# 需要导入模块: from trac.wiki import WikiPage [as 别名]
# 或者: from trac.wiki.WikiPage import save [as 别名]
    def test_update_page(self):
        t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        self.env.db_transaction(
            "INSERT INTO wiki VALUES(%s,%s,%s,%s,%s,%s,%s,%s)",
            ('TestPage', 1, to_utimestamp(t), 'joe', '::1', 'Bla bla',
             'Testing', 0))

        page = WikiPage(self.env, 'TestPage')
        page.text = 'Bla'
        page.save('kate', 'Changing', '192.168.0.101', t2)

        self.assertEqual(2, page.version)
        self.assertEqual(2, page.resource.version)
        self.assertEqual(0, page.readonly)
        self.assertEqual('kate', page.author)
        self.assertEqual('Changing', page.comment)
        self.assertEqual(t2, page.time)

        with self.env.db_query as db:
            rows = db("""
               SELECT version, time, author, ipnr, text, comment, readonly
               FROM wiki WHERE name=%s ORDER BY version
               """, ('TestPage',))
            self.assertEqual(2, len(rows))
            self.assertEqual((1, to_utimestamp(t), 'joe', '::1', 'Bla bla',
                              'Testing', 0), rows[0])
            self.assertEqual((2, to_utimestamp(t2), 'kate', '192.168.0.101',
                              'Bla', 'Changing', 0), rows[1])

        listener = TestLegacyWikiChangeListener(self.env)
        self.assertEqual((page, 2, t2, 'Changing', 'kate', '192.168.0.101'),
                         listener.changed[0])
        listener = TestWikiChangeListener(self.env)
        self.assertEqual((page, 2, t2, 'Changing', 'kate'),
                         listener.changed[0])

        page = WikiPage(self.env, 'TestPage')
        history = list(page.get_history())
        self.assertEqual(2, len(history))
        self.assertEqual((2, t2, 'kate', 'Changing', '192.168.0.101'),
                         history[0])
        self.assertEqual((1, t, 'joe', 'Testing', '::1'), history[1])
开发者ID:exocad,项目名称:exotrac,代码行数:45,代码来源:model.py


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