[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ - improved source_html
Yvo Schubbe
y.2011 at wcm-solutions.de
Wed Jul 13 08:04:58 EDT 2011
Log message for revision 122172:
- improved source_html
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/browser/content/document.py
U Products.CMFDefault/trunk/Products/CMFDefault/browser/content/source.pt
U Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt
D Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.pt
A Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.py
A Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html_template.pt
U Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Document.py
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/document.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/document.py 2011-07-13 10:09:38 UTC (rev 122171)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/document.py 2011-07-13 12:04:57 UTC (rev 122172)
@@ -157,5 +157,12 @@
@decode
@memoize
+ def listMetadataFields(self):
+ return [ {'name': field[0], 'body': field[1]}
+ for field in self.context.getMetadataHeaders()
+ if field[0].lower() != 'title' ]
+
+ @decode
+ @memoize
def editable_body(self):
return self.context.EditableBody()
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/source.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/source.pt 2011-07-13 10:09:38 UTC (rev 122171)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/source.pt 2011-07-13 12:04:57 UTC (rev 122172)
@@ -1,11 +1,11 @@
-<html tal:define="hdrlist context/getMetadataHeaders">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
<head>
- <title tal:content="view/title">the title</title><tal:block
- tal:repeat="hdr hdrlist"><tal:block
- tal:condition="python:hdr[0].lower() != 'title'">
- <meta name="" content=""
- tal:attributes="name python:hdr[0]; content python:hdr[1];"
- /></tal:block></tal:block>
+ <title tal:content="view/title">TITLE</title>
+ <meta name="FIELD NAME" content="FIELD BODY"
+ tal:repeat="field view/listMetadataFields"
+ tal:attributes="name field/name; content field/body;" />
</head>
- <body><p tal:replace="structure view/editable_body">EditableBody</p></body>
+ <body><p tal:replace="structure view/editable_body">EDITABLE BODY</p></body>
</html>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt 2011-07-13 10:09:38 UTC (rev 122171)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt 2011-07-13 12:04:57 UTC (rev 122172)
@@ -120,6 +120,8 @@
>>> browser.open('http://localhost/site/myDocument/manage_FTPget')
>>> print browser.contents
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>TITLE</title>
Deleted: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.pt 2011-07-13 10:09:38 UTC (rev 122171)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.pt 2011-07-13 12:04:57 UTC (rev 122172)
@@ -1,11 +0,0 @@
-<html tal:define="hdrlist here/getMetadataHeaders">
- <head>
- <title tal:content="here/Title">the title</title><tal:block
- tal:repeat="hdr hdrlist"><tal:block
- tal:condition="python:hdr[0].lower() != 'title'">
- <meta name="" content=""
- tal:attributes="name python:hdr[0]; content python:hdr[1];"
- /></tal:block></tal:block>
- </head>
- <body><p tal:replace="structure here/EditableBody">EditableBody</p></body>
-</html>
Added: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.py (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.py 2011-07-13 12:04:57 UTC (rev 122172)
@@ -0,0 +1,14 @@
+##parameters=
+##
+from Products.CMFDefault.utils import decode
+
+options = {}
+
+metadata = [ {'name': field[0], 'body': field[1]}
+ for field in context.getMetadataHeaders()
+ if field[0].lower() != 'title' ]
+options['title'] = context.Title()
+options['listMetadataFields'] = metadata
+options['editable_body'] = context.EditableBody()
+
+return context.source_html_template(**decode(options, script))
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.py
___________________________________________________________________
Added: svn:eol-style
+ native
Copied: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html_template.pt (from rev 122171, Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html.pt)
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html_template.pt (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html_template.pt 2011-07-13 12:04:57 UTC (rev 122172)
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <title tal:content="options/title">TITLE</title>
+ <meta name="FIELD NAME" content="FIELD BODY"
+ tal:repeat="field options/listMetadataFields"
+ tal:attributes="name field/name; content field/body;" />
+ </head>
+ <body><p tal:replace="structure options/editable_body">EDITABLE BODY</p></body>
+</html>
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_content/source_html_template.pt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Document.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Document.py 2011-07-13 10:09:38 UTC (rev 122171)
+++ Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Document.py 2011-07-13 12:04:57 UTC (rev 122172)
@@ -24,6 +24,7 @@
from DocumentTemplate.DT_Util import html_quote
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+from Products.PythonScripts.PythonScript import PythonScript
from zope.component import getSiteManager
from zope.interface import implements
from zope.interface.verify import verifyClass
@@ -572,11 +573,17 @@
del fti['id']
ttool._setObject('Document', FTI('Document', **fti))
+ ps = self.site._setObject('source_html',
+ PythonScript('source_html'))
zpt = self.site._setObject('source_html',
- ZopePageTemplate('source_html'))
+ ZopePageTemplate('source_html_template'))
dir = abspath(dirname(utils.__file__))
- _file = path_join(dir, 'skins', 'zpt_content', 'source_html.pt')
+ _file = path_join(dir, 'skins', 'zpt_content', 'source_html.py')
data = open(_file, 'r').read()
+ ps.write(data)
+ _file = path_join(dir, 'skins', 'zpt_content',
+ 'source_html_template.pt')
+ data = open(_file, 'r').read()
zpt.write(data)
d = self._makeOne('foo')
More information about the checkins
mailing list