[CMF-checkins] CVS: CMF - Document.py:1.8
Jeffrey Shell
jeffrey@digicool.com
Mon, 21 May 2001 18:00:13 -0400 (EDT)
Update of /cvs-repository/CMF/CMFDefault
In directory korak.digicool.com:/home/jeffrey/InstanceHomes/cmf-dev/CMF/CMFDefault
Modified Files:
Document.py
Log Message:
Subclassed HTMLWithImages as CMFHtmlWithImages so that the document()
method wouldn't return extra HTML tags (html, head, body, etc).
Changed _format_stx to use it. Verified by test_StructuredText() test
in test_Document.py
--- Updated File Document.py in package CMF --
--- Document.py 2001/05/19 18:59:39 1.7
+++ Document.py 2001/05/21 22:00:12 1.8
@@ -88,6 +88,7 @@
ADD_CONTENT_PERMISSION = 'Add portal content'
import Globals, StructuredText, string
+from StructuredText.HTMLWithImages import HTMLWithImages
from Globals import DTMLFile, InitializeClass
from AccessControl import ClassSecurityInfo
from Products.CMFCore.PortalContent import PortalContent
@@ -104,6 +105,18 @@
self._setObject(id,o)
afterCreate(self.this()._getOb(id))
+class CMFHtmlWithImages(HTMLWithImages):
+ """ Special subclass of HTMLWithImages, overriding document() """
+ def document(self, doc, level, output):
+ """\
+ HTMLWithImages.document renders full HTML (head, title, body). For
+ CMF Purposes, we don't want that. We just want those nice juicy
+ body parts perfectly rendered.
+ """
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+
+CMFHtmlWithImages = CMFHtmlWithImages()
class Document(PortalContent, DefaultDublinCoreImpl):
""" A Document - Handles both StructuredText and HTML """
@@ -207,7 +220,7 @@
return "" # return now or have errors!
doc = StructuredText.DocumentWithImages(st)
- html = StructuredText.HTMLWithImages(doc)
+ html = CMFHtmlWithImages(doc, level)
return html
security.declareProtected(CMFCorePermissions.View, 'SearchableText')