[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ - improved 'manage_FTPget' method
Yvo Schubbe
y.2011 at wcm-solutions.de
Thu Mar 3 03:53:05 EST 2011
Log message for revision 120726:
- improved 'manage_FTPget' method
- fixed source view tests
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
UU Products.CMFDefault/trunk/Products/CMFDefault/Document.py
U Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2011-03-03 07:46:39 UTC (rev 120725)
+++ Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2011-03-03 08:53:04 UTC (rev 120726)
@@ -4,6 +4,9 @@
2.3.0-alpha (unreleased)
------------------------
+- Document: Improved 'manage_FTPget' method.
+ HTML responses can now be rendered by a view.
+
- Removed ``five.formlib`` dependency. ``zope.formlib`` is now used directly.
- profiles: Added default settings for the member data tool.
Modified: Products.CMFDefault/trunk/Products/CMFDefault/Document.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/Document.py 2011-03-03 07:46:39 UTC (rev 120725)
+++ Products.CMFDefault/trunk/Products/CMFDefault/Document.py 2011-03-03 08:53:04 UTC (rev 120726)
@@ -11,23 +11,22 @@
#
##############################################################################
""" Basic textual content object, supporting HTML, STX and plain text.
-
-$Id$
"""
+
try:
from reStructuredText import HTML as ReST
REST_AVAILABLE = True
except ImportError:
REST_AVAILABLE = False
+import transaction
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from Acquisition import aq_base
-from App.config import getConfiguration
from App.class_init import InitializeClass
+from App.config import getConfiguration
from App.special_dtml import DTMLFile
from DocumentTemplate.DT_Util import html_quote
-import transaction
from zope.component import queryUtility
from zope.component.factory import Factory
from zope.interface import implements
@@ -428,7 +427,7 @@
ti = self.getTypeInfo()
method_id = ti and ti.queryMethodID('gethtml', context=self)
if method_id:
- method = getattr(self, method_id)
+ method = self.unrestrictedTraverse(method_id)
if getattr(aq_base(method), 'isDocTemp', 0):
bodytext = method(self, self.REQUEST)
else:
Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/Document.py
___________________________________________________________________
Deleted: svn:keywords
- Author Date Id Revision
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt 2011-03-03 07:46:39 UTC (rev 120725)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/tests/document.txt 2011-03-03 08:53:04 UTC (rev 120726)
@@ -1,15 +1,20 @@
Document Views
--------------
-Set up Document and user.
+Set up site, method alias, user and Document.
- >>> from Products.CMFDefault.Document import Document
- >>> id = app.site._setObject('myDocument', Document('myDocument'))
-
+ >>> from zope.site.hooks import setSite
+ >>> setSite(app.site)
+ >>> ti = app.site.portal_types.Document
+ >>> dummy = ti.setMethodAliases({'gethtml': '@@source.html'})
>>> uf = app.site.acl_users
>>> _ignored = uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
- >>> from zope.site.hooks import setSite
- >>> setSite(app.site)
+ >>> from Products.CMFDefault.Document import Document
+ >>> obj_id = app.site._setObject('myDocument', Document('myDocument'))
+ >>> obj = app.site[obj_id]
+ >>> obj.portal_type = 'Document'
+ >>> obj.setTitle('TITLE')
+ >>> obj.setDescription('DESCRIPTION')
Create the browser object we'll be using.
@@ -69,31 +74,66 @@
>>> '[[cmf_default][This resource is locked ' in browser.contents
True
-Test source view.
-Unlock document first.
-
>>> app.site.myDocument.wl_clearLocks()
>>> app.site.myDocument.wl_isLocked()
0
- >>> browser.open('http://localhoste/site/myDocument/@@edit.html')
+Structured Text will be formatted as HTML in the view.
+
+ >>> browser.open('http://localhost/site/myDocument/@@edit.html')
>>> browser.getControl(name='form.text_format').value == ['structured-text']
True
>>> browser.getControl('[[cmf_default][Body]]').value = '*spam and eggs*'
>>> browser.getControl('[[cmf_default][Change]]').click()
-Structured Text will be formatted as HTML in the view
-
- >>> browser.open('http://localhoste/site/myDocument/@@view.html')
+ >>> browser.open('http://localhost/site/myDocument/@@view.html')
>>> '*spam and eggs*' in browser.contents
False
>>> '<em>spam and eggs</em>' in browser.contents
True
-Structured Text markup will be visible in the source view
+The source view is not used in 'structured-text' mode.
- >>> browser.open('http://localhoste/site/myDocument/@@source.html')
- >>> '*spam and eggs*' in browser.contents
- True
- >>> '<meta name="Description" content="" />' in browser.contents
- True
+ >>> browser.open('http://localhost/site/myDocument/manage_FTPget')
+ >>> print browser.contents
+ Title: TITLE
+ Subject:
+ Publisher:
+ Description: DESCRIPTION
+ Contributors:
+ Effective_date: None
+ Expiration_date: None
+ Type: Document
+ Format: text/plain
+ Language:
+ Rights:
+ SafetyBelt: ...
+ <BLANKLINE>
+ *spam and eggs*
+
+The source view is only used in 'html' mode.
+
+ >>> browser.open('http://localhost/site/myDocument/@@edit.html')
+ >>> browser.getControl(name='form.text_format').value = ['html']
+ >>> browser.getControl('[[cmf_default][Body]]').value = '<b>spam</b>'
+ >>> browser.getControl('[[cmf_default][Change]]').click()
+
+ >>> browser.open('http://localhost/site/myDocument/manage_FTPget')
+ >>> print browser.contents
+ <html>
+ <head>
+ <title>TITLE</title>
+ <meta name="Subject" content="" />
+ <meta name="Publisher" content="" />
+ <meta name="Description" content="DESCRIPTION" />
+ <meta name="Contributors" content="" />
+ <meta name="Effective_date" content="None" />
+ <meta name="Expiration_date" content="None" />
+ <meta name="Type" content="[[cmf_default][Document]]" />
+ <meta name="Format" content="text/html" />
+ <meta name="Language" content="" />
+ <meta name="Rights" content="" />
+ <meta name="SafetyBelt" content="..." />
+ </head>
+ <body><b>spam</b></body>
+ </html>
More information about the checkins
mailing list