本文整理汇总了Python中Products.CMFDefault.Document.Document类的典型用法代码示例。如果您正苦于以下问题:Python Document类的具体用法?Python Document怎么用?Python Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSTX
def testSTX( self ):
self.REQUEST['BODY']=SIMPLE_STRUCTUREDTEXT
d = Document( 'foo' )
d.PUT(self.REQUEST, self.RESPONSE)
rnlinesplit = compile( r'\r?\n?' )
get_text = d.manage_FTPget()
simple_lines = rnlinesplit.split( SIMPLE_STRUCTUREDTEXT )
get_lines = rnlinesplit.split( get_text )
# strip off headers
simple_headers = []
while simple_lines and simple_lines[0]:
simple_headers.append( simple_lines[0] )
simple_lines = simple_lines[1:]
get_headers = []
while get_lines and get_lines[0]:
get_headers.append( get_lines[0] )
get_lines = get_lines[1:]
self.assertEqual( get_lines, simple_lines )
for header in simple_headers:
self.failUnless( header in get_headers )
示例2: test_StructuredText
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'
]
示例3: test_deletePropagation
def test_deletePropagation(self):
# import pdb; pdb.set_trace()
portal_catalog = CatalogTool()
self.root._setObject('portal_catalog', portal_catalog)
catalog = self.root.portal_catalog
portal_discussion = DiscussionTool()
self.root._setObject('portal_discussion', portal_discussion)
portal_url = URLTool()
self.root._setObject('portal_url', portal_url)
portal_workflow = WorkflowTool()
self.root._setObject('portal_workflow', portal_workflow)
test = Document('test')
self.root._setObject('test', test)
test = self.root.test
test.allow_discussion = 1
assert len(catalog) == 1
portal_discussion.createDiscussionFor(test)
talkback = test.talkback
talkback.createReply(title='test'
, text='blah'
)
foo = talkback.getReplies()[0]
assert len(catalog) == 2
self.root._delObject('test')
assert len(catalog) == 0
示例4: test_indexableContent_html
def test_indexableContent_html(self):
from Products.CMFCore.CatalogTool import IndexableObjectWrapper
from Products.CMFDefault.Document import Document
d = Document('foo', title='Foo', text_format='html',
text='foo content')
d.setLanguage('en')
try:
w = IndexableObjectWrapper(ob=d, catalog=None)
except TypeError:
w = IndexableObjectWrapper({}, d) # BBB: for CMF < 2.2
a = self._makeOne(w)
icc = a.indexableContent(['Title', 'Description'])
self.assertEqual(icc.getFields(), ['Description', 'Title'])
self.assertEqual(icc.getFieldData('Title')[0],
{'content': u'Foo', 'language': 'en'})
self.assertEqual(icc.getFieldData('Description')[0],
{'content': u'', 'language': 'en'})
icc = a.indexableContent(['SearchableText'])
self.assertEqual(icc.getFields(), ['SearchableText'])
self.assertEqual(icc.getFieldData('SearchableText')[0],
{'content': u'Foo', 'language': 'en'})
self.assertEqual(icc.getFieldData('SearchableText')[1],
{'content': u'', 'language': 'en'})
self.assertEqual(icc.getFieldData('SearchableText')[2],
{'content': u'foo content', 'language': 'en'})
示例5: edit
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 )
示例6: test_UpperedHtml
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
示例7: test_STX_NoHeaders_but_colon
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 )
示例8: test_StructuredText
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
示例9: test_BigHtml
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
示例10: setUp
def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory('Folder', 'target')
self.portal.invokeFactory('Folder', 'folder')
self.folder = self.portal['folder']
self.folder.invokeFactory('Document', 'd1')
self.folder.d1.setEffectiveDate(DateTime('2009/04/22'))
self.folder.invokeFactory('Folder', 'relativeTarget')
o = Document('cmf', 'CMF Content', '', '', '')
o.setEffectiveDate(DateTime('2009/04/22'))
self.folder._setObject('cmf', o, suppress_events=True)
示例11: __call__
def __call__(self, id, title=None, *args, **kw):
item = super(_HomeFolderFactory,
self).__call__(id, title=title, *args, **kw)
# Create Member's initial content
subitem = Document('index_html', "{0}'s Home".format(id),
"{0}'s front page".format(id),
'structured-text', DEFAULT_MEMBER_CONTENT % id)
subitem.manage_setLocalRoles(id, ['Owner'])
subitem._setPortalTypeName('Document')
item._setObject('index_html', subitem, suppress_events=True)
return item
示例12: setUp
def setUp(self):
self.portal = self.layer["portal"]
setRoles(self.portal, TEST_USER_ID, ["Manager"])
self.portal.invokeFactory("Folder", "target")
self.portal.invokeFactory("Folder", "folder")
self.folder = self.portal["folder"]
self.folder.invokeFactory("Document", "d1")
self.folder.d1.setEffectiveDate(DateTime("2009/04/22"))
self.folder.invokeFactory("Folder", "relativeTarget")
o = Document("cmf", "CMF Content", "", "", "")
o.setEffectiveDate(DateTime("2009/04/22"))
self.folder._setObject("cmf", o, suppress_events=True)
示例13: test_BigHtml_via_upload
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 )
示例14: testHTML
def testHTML( self ):
REQUEST=fakeRequest()
REQUEST['BODY']=SIMPLE_HTML
d = Document( 'foo' )
d.PUT(REQUEST, RESPONSE=fakeResponse())
rnlinesplit = re.compile( r'\r?\n?' )
simple_lines = rnlinesplit.split( SIMPLE_HTML )
get_lines = rnlinesplit.split( d.manage_FTPget() )
# strip off headers
meta_pattern = re.compile( r'meta name="([a-z]*)" '
+ r'content="([a-z]*)"'
)
title_pattern = re.compile( r'<title>(.*)</title>' )
simple_headers = []
while simple_lines and simple_lines[0] != '<BODY>':
header = string.lower( string.strip( simple_lines[0] ) )
match = meta_pattern.search( header )
if match:
simple_headers.append( match.groups() )
else:
match = title_pattern.search( header )
if match:
simple_headers.append( ( 'title', match.group(1) ) )
simple_lines = simple_lines[1:]
get_headers = []
while get_lines and get_lines[0] != '<BODY>':
header = string.lower( string.strip( get_lines[0] ) )
match = meta_pattern.search( header )
if match:
get_headers.append( match.groups() )
else:
match = title_pattern.search( header )
if match:
get_headers.append( ( 'title', match.group(1) ) )
get_lines = get_lines[1:]
self.assertEqual( get_lines, simple_lines )
self.failUnless( get_headers )
self.failUnless( simple_headers )
self.failUnless( len( get_headers ) >= len( simple_headers ) )
for header in simple_headers:
self.failUnless( header in get_headers )
示例15: __init__
def __init__(self,
id,
title='',
position='',
topic='',
description='',
source='',
url='',
text='',
text_format='',
):
""" Instanciates an Article """
Document.__init__(self, id, title, description, text_format, text)
self.position = position
self.topic = topic
self.source = source
self.url = string.split(url,'\n')