當前位置: 首頁>>代碼示例>>Python>>正文


Python Document.edit方法代碼示例

本文整理匯總了Python中Products.CMFDefault.Document.Document.edit方法的典型用法代碼示例。如果您正苦於以下問題:Python Document.edit方法的具體用法?Python Document.edit怎麽用?Python Document.edit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Products.CMFDefault.Document.Document的用法示例。


在下文中一共展示了Document.edit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_StructuredText

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
    def test_StructuredText(self):
        d = Document('foo')
        assert hasattr(d, 'cooked_text')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        
        assert d.Format() == 'text/plain'
        assert d.Title() == 'My Document'
        assert d.Description() == 'A document by me'
        assert len(d.Contributors()) == 3
        assert string.find(d.cooked_text, '<p>') >= 0
        assert string.find(d.CookedBody(), '<h1') >= 0

        # Make sure extra HTML is NOT found
        assert string.find(d.cooked_text, '<title>') == -1, d.cooked_text
        assert string.find(d.cooked_text, '<body>') == -1, d.cooked_text

        # test subject/keyword headers
        subj = list(d.Subject())
        assert len(subj) == 4
        subj.sort()
        assert subj == [
            'content management',
            'framework',
            'unit tests',
            'zope'
            ]
開發者ID:goschtl,項目名稱:zope,代碼行數:28,代碼來源:test_Document.py

示例2: edit

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def edit( self, text, description=None, text_format=None ):
     """Edit the News Item.
     """
     if text_format is None:
         text_format = getattr(self, 'text_format', 'structured-text')
     if description is not None:
         self.setDescription( description )
     Document.edit( self, text_format, text )
開發者ID:nacho22martin,項目名稱:tesis,代碼行數:10,代碼來源:NewsItem.py

示例3: test_UpperedHtml

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_UpperedHtml(self):
     d = Document('foo')
     d.edit(text_format='', text=string.upper(BASIC_HTML))
     assert d.Format() == 'text/html'
     assert d.title == 'TITLE IN TAG'
     assert string.find(d.text, '</BODY') == -1
     assert d.Description() == 'DESCRIBE ME'
     assert len(d.Contributors()) == 3
開發者ID:goschtl,項目名稱:zope,代碼行數:10,代碼來源:test_Document.py

示例4: test_StructuredText

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_StructuredText(self):
     d = Document('foo')
     d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
     
     assert d.Format() == 'text/plain'
     assert d.Title() == 'My Document'
     assert d.Description() == 'A document by me'
     assert len(d.Contributors()) == 3
     assert string.find(d.cooked_text, '<p>') >= 0
開發者ID:goschtl,項目名稱:zope,代碼行數:11,代碼來源:test_Document.py

示例5: test_STX_NoHeaders_but_colon

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
    def test_STX_NoHeaders_but_colon( self ):
        d = Document('foo')
        d.editMetadata( title="Plain STX"
                       , description="Look, Ma, no headers!"
                       , subject=( "plain", "STX" )
                       )

        d.edit(text_format='structured-text', text=STX_NO_HEADERS_BUT_COLON)
        self.assertEqual( d.EditableBody(), STX_NO_HEADERS_BUT_COLON )
開發者ID:goschtl,項目名稱:zope,代碼行數:11,代碼來源:test_Document.py

示例6: test_BigHtml

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_BigHtml(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000): s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document',
                             'body': body}
     d.edit(text_format=None, text=html)
     assert d.CookedBody() == body
開發者ID:goschtl,項目名稱:zope,代碼行數:12,代碼來源:test_Document.py

示例7: test_BigHtml_via_upload

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_BigHtml_via_upload(self):
     d = Document('foo')
     s = []
     looper = '<li> number %s</li>'
     for i in range(12000): s.append(looper % i)
     body = '<ul>\n%s\n</ul>' % string.join(s, '\n')
     html = HTML_TEMPLATE % {'title': 'big document',
                             'body': body}
     from StringIO import StringIO
     file = StringIO( html )
     d.edit(text_format='html', text='', file=file)
     self.assertEqual( d.CookedBody(), body )
開發者ID:goschtl,項目名稱:zope,代碼行數:14,代碼來源:test_Document.py

示例8: edit

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def edit(self,   
         title='',
         position='',
         topic='',
         description='',
         source='',
         url='',
         text='',
         text_format='',
         file='',
         ):
     """ Edit article properties """     
     Document.edit(self, text_format, text, file)
     self.editMetadata(title=title, description=description)
     self.position=position
     self.topic=topic
     self.source = source
     self.url = string.split(url,'\n')
開發者ID:BackupTheBerlios,項目名稱:plonenewsletter,代碼行數:20,代碼來源:Article.py

示例9: test_STX_NoHeaders

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
    def test_STX_NoHeaders( self ):
        d = Document('foo')
        d._editMetadata( title="Plain STX"
                       , description="Look, Ma, no headers!"
                       , subject=( "plain", "STX" )
                       )
        assert d.Format() == 'text/html'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len( d.Subject() ) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()

        d.edit(text_format='structured-text', text=STX_NO_HEADERS)
        
        assert d.Format() == 'text/plain'
        assert d.Title() == 'Plain STX'
        assert d.Description() == 'Look, Ma, no headers!'
        assert len( d.Subject() ) == 2
        assert 'plain' in d.Subject()
        assert 'STX' in d.Subject()
開發者ID:goschtl,項目名稱:zope,代碼行數:23,代碼來源:test_Document.py

示例10: test_STX_Levels

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody()
        self.failUnless( string.find(d.CookedBody(), '<h1') >= 0 )
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody(stx_level=2)
        self.failIf( (string.find(ct, '<h1') >= 0) )
        self.failUnless( string.find(ct, '<h2') >= 0 )
        self.assertEqual( d._stx_level, 1 )

        ct = d.CookedBody(stx_level=2, setlevel=1)
        self.failIf( (string.find(ct, '<h1') >= 0) )
        self.failUnless( string.find(ct, '<h2') >= 0 )
        self.assertEqual( d._stx_level, 2 )

        ct = d.CookedBody()
        self.assertEqual( d._stx_level, 2 )
        self.failIf( (string.find(d.CookedBody(), '<h1') >= 0) )
        self.failUnless( string.find(d.CookedBody(), '<h2') >= 0 )
開發者ID:goschtl,項目名稱:zope,代碼行數:25,代碼來源:test_Document.py

示例11: test_STX_Levels

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
    def test_STX_Levels(self):
        d = Document('foo')
        d.edit(text_format='structured-text', text=BASIC_STRUCTUREDTEXT)
        assert d._stx_level == 1

        ct = d.CookedBody()
        assert string.find(d.CookedBody(), '<h1') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 1

        ct = d.CookedBody(stx_level=2, setlevel=1)
        assert not (string.find(ct, '<h1') >= 0)
        assert string.find(ct, '<h2') >= 0
        assert d._stx_level == 2

        ct = d.CookedBody()
        assert d._stx_level == 2
        assert not (string.find(d.CookedBody(), '<h1') >= 0)
        assert string.find(d.CookedBody(), '<h2') >= 0
開發者ID:goschtl,項目名稱:zope,代碼行數:25,代碼來源:test_Document.py

示例12: test_EditStructuredTextWithHTML

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_EditStructuredTextWithHTML(self):
     d = Document('foo')
     d.edit(text_format=None, text=STX_WITH_HTML)
     
     assert d.Format() == 'text/plain', "%s != %s" % (
         d.Format(), 'text/plain')
開發者ID:goschtl,項目名稱:zope,代碼行數:8,代碼來源:test_Document.py

示例13: test_HtmlWithoutNewlines

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_HtmlWithoutNewlines(self):
     d = Document('foo')
     html = string.join(string.split(BASIC_HTML, '\n'), '')
     d.edit(text_format='', text=html)
     assert d.Format() == 'text/html'
     assert d.Description() == 'Describe me'
開發者ID:goschtl,項目名稱:zope,代碼行數:8,代碼來源:test_Document.py

示例14: test_HtmlWithDoctype

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_HtmlWithDoctype(self):
     d = Document('foo')
     html = '%s\n%s' % (DOCTYPE, BASIC_HTML)
     d.edit(text_format='', text=html)
     assert d.Description() == 'Describe me'
開發者ID:goschtl,項目名稱:zope,代碼行數:7,代碼來源:test_Document.py

示例15: test_EntityInTitle

# 需要導入模塊: from Products.CMFDefault.Document import Document [as 別名]
# 或者: from Products.CMFDefault.Document.Document import edit [as 別名]
 def test_EntityInTitle(self):
     d = Document('foo')
     d.edit(text_format='html', text=ENTITY_IN_TITLE)
     assert d.title == '&Auuml;rger', "Title '%s' being lost" % (
         d.title )
開發者ID:goschtl,項目名稱:zope,代碼行數:7,代碼來源:test_Document.py


注:本文中的Products.CMFDefault.Document.Document.edit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。