本文整理汇总了Python中utils.html_headcheck函数的典型用法代码示例。如果您正苦于以下问题:Python html_headcheck函数的具体用法?Python html_headcheck怎么用?Python html_headcheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html_headcheck函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setFormat
def setFormat(self, format):
""" Set text format and Dublin Core resource format.
"""
value = str(format)
old_value = self.text_format
if value == 'text/html' or value == 'html':
self.text_format = 'html'
elif value == 'text/plain':
if self.text_format not in ('structured-text', 'plain'):
self.text_format = 'structured-text'
elif value == 'plain':
self.text_format = 'plain'
else:
self.text_format = 'structured-text'
# Did the format change? We might need to re-cook the content.
if value != old_value:
if html_headcheck(self.text) and value != 'plain':
self.text = bodyfinder(self.text)
self._edit( self.text
, text_format=self.text_format
, safety_belt=self._safety_belt
)
开发者ID:goschtl,项目名称:zope,代码行数:25,代码来源:Document.py
示例2: edit
def edit(self, text_format, text, file='', safety_belt=''):
""" Update the document.
To add webDav support, we need to check if the content is locked, and if
so return ResourceLockedError if not, call _edit.
Note that this method expects to be called from a web form, and so
disables header processing
"""
self.failIfLocked()
if not self._safety_belt_update(safety_belt=safety_belt):
msg = _(u'Intervening changes from elsewhere detected. '
u'Please refetch the document and reapply your changes. '
u'(You may be able to recover your version using the '
u"browser 'back' button, but will have to apply them to "
u'a freshly fetched copy.)')
raise EditingConflict(msg)
if file and (type(file) is not type('')):
contents=file.read()
if contents:
text = contents
if html_headcheck(text) and text_format.lower() != 'plain':
text = bodyfinder(text)
self.setFormat(text_format)
self._edit(text)
self.reindexObject()
开发者ID:goschtl,项目名称:zope,代码行数:26,代码来源:Document.py
示例3: edit
def edit(self, text_format, text, file='', safety_belt=''):
""" Update the document.
To add webDav support, we need to check if the content is locked, and if
so return ResourceLockedError if not, call _edit.
Note that this method expects to be called from a web form, and so
disables header processing
"""
self.failIfLocked()
if file and (type(file) is not type('')):
contents=file.read()
if contents:
text = contents
if html_headcheck(text) and text_format.lower() != 'plain':
text = bodyfinder(text)
self.setFormat(text_format)
self._edit(text=text, text_format=text_format, safety_belt=safety_belt)
self.reindexObject()
开发者ID:goschtl,项目名称:zope,代码行数:19,代码来源:Document.py
示例4: PUT
def PUT(self, REQUEST, RESPONSE):
""" Handle HTTP (and presumably FTP?) PUT requests """
self.dav__init(REQUEST, RESPONSE)
body = REQUEST.get('BODY', '')
guessedformat = REQUEST.get_header('Content-Type', 'text/plain')
ishtml = (guessedformat == 'text/html') or utils.html_headcheck(body)
if ishtml: self.setFormat('text/html')
else: self.setFormat('text/plain')
try:
self.edit(text_format=self.text_format, text=body)
except 'EditingConflict', msg:
# XXX Can we get an error msg through? Should we be raising an
# exception, to be handled in the FTP mechanism? Inquiring
# minds...
get_transaction().abort()
RESPONSE.setStatus(450)
return RESPONSE
开发者ID:goschtl,项目名称:zope,代码行数:19,代码来源:Document.py
示例5: PUT
def PUT(self, REQUEST, RESPONSE):
""" Handle HTTP (and presumably FTP?) PUT requests """
self.dav__init(REQUEST, RESPONSE)
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
body = REQUEST.get('BODY', '')
guessedformat = REQUEST.get_header('Content-Type', 'text/plain')
ishtml = (guessedformat == 'text/html') or utils.html_headcheck(body)
if ishtml: self.setFormat('text/html')
else: self.setFormat('text/plain')
try:
headers, body, format = self.handleText(text=body)
safety_belt = headers.get('SafetyBelt', '')
self.setMetadata(headers)
self._edit(text=body, safety_belt=safety_belt)
except 'EditingConflict', msg:
# XXX Can we get an error msg through? Should we be raising an
# exception, to be handled in the FTP mechanism? Inquiring
# minds...
get_transaction().abort()
RESPONSE.setStatus(450)
return RESPONSE
开发者ID:goschtl,项目名称:zope,代码行数:23,代码来源:Document.py
示例6: guessFormat
def guessFormat(self, text):
""" Simple stab at guessing the inner format of the text """
if utils.html_headcheck(text): return 'html'
else: return 'structured-text'
开发者ID:goschtl,项目名称:zope,代码行数:4,代码来源:Document.py
注:本文中的utils.html_headcheck函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论