[CMF-checkins] SVN: CMF/trunk/CMF - added basic tests for folder
views
Yvo Schubbe
y.2006_ at wcm-solutions.de
Mon Apr 24 14:30:04 EDT 2006
Log message for revision 67575:
- added basic tests for folder views
- converted filterCookie.py and clearCookie.py scripts to view methods
- updated cmf_default.pot
Changed:
U CMF/trunk/CMFCore/tests/base/dummy.py
U CMF/trunk/CMFDefault/browser/TODO.txt
U CMF/trunk/CMFDefault/browser/folder.py
A CMF/trunk/CMFDefault/browser/folder.txt
A CMF/trunk/CMFDefault/browser/tests.py
U CMF/trunk/CMFDefault/locales/cmf_default.pot
U CMF/trunk/CMFDefault/skins/zpt_generic/folder_filter_form.pt
-=-
Modified: CMF/trunk/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/dummy.py 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFCore/tests/base/dummy.py 2006-04-24 18:30:03 UTC (rev 67575)
@@ -75,12 +75,19 @@
def Title(self):
return self.title
- def queryMethodID(self, alias, default=None, context=None):
- return self._actions.get(alias, default)
+ def allowType(self, contentType):
+ return True
def allowDiscussion(self):
return False
+ def queryMethodID(self, alias, default=None, context=None):
+ return self._actions.get(alias, default)
+
+ def isConstructionAllowed(self, container):
+ return True
+
+
class DummyContent( PortalContent, Item ):
"""
A Dummy piece of PortalContent
@@ -309,29 +316,13 @@
Action Provider
"""
- root = 'DummyTool'
-
- view_actions = ( ('', 'dummy_view')
- , ('view', 'dummy_view')
- , ('(Default)', 'dummy_view')
- )
-
-
def __init__(self, anon=1):
self.anon = anon
- def __call__( self ):
- return self.root
-
- getPortalPath = __call__
-
- def getPortalObject( self ):
- return aq_parent( aq_inner( self ) )
-
def getIcon( self, relative=0 ):
return 'Tool: %s' % relative
- # MembershipTool
+ # IMembershipTool
def getAuthenticatedMember(self):
return DummyUser()
@@ -341,21 +332,41 @@
def checkPermission(self, permissionName, object, subobjectName=None):
return True
- # TypesTool
- def listTypeInfo(self, container=None):
- typ = 'Dummy Content'
- return ( DummyType(typ, title=typ, actions=self.view_actions), )
+ # ITypesTool
+ _type_id = 'Dummy Content'
+ _type_actions = (('', 'dummy_view'),
+ ('view', 'dummy_view'),
+ ('(Default)', 'dummy_view'))
def getTypeInfo(self, contentType):
- typ = 'Dummy Content'
- return DummyType(typ, title=typ, actions=self.view_actions)
+ return DummyType(self._type_id, title=self._type_id,
+ actions=self._type_actions)
- # WorkflowTool
+ def listTypeInfo(self, container=None):
+ return (DummyType(self._type_id, title=self._type_id,
+ actions=self._type_actions),)
+
+ def listContentTypes(self, container=None, by_metatype=0):
+ return (self._type_id,)
+
+ # IURLTool
+ root = 'DummyTool'
+
+ def __call__(self):
+ return self.root
+
+ def getPortalObject(self):
+ return aq_parent(aq_inner(self))
+
+ getPortalPath = __call__
+
+ # IWorkflowTool
test_notified = None
def notifyCreated(self, ob):
self.test_notified = ob
+
class DummyCachingManager:
def getHTTPCachingHeaders( self, content, view_name, keywords, time=None ):
@@ -392,4 +403,3 @@
modified_date = content.modified()
set_last_modified = (modified_date is not None)
return (modified_date, FAKE_ETAG, set_last_modified)
-
Modified: CMF/trunk/CMFDefault/browser/TODO.txt
===================================================================
--- CMF/trunk/CMFDefault/browser/TODO.txt 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/browser/TODO.txt 2006-04-24 18:30:03 UTC (rev 67575)
@@ -31,6 +31,9 @@
folder_down_control.py -> FolderContentsView.down_control
folder_top_control.py -> FolderContentsView.top_control
folder_bottom_control.py -> FolderContentsView.bottom_control
+ filterCookie.py -> FolderContentsView.set_filter_control
+ FolderContentsView.clear_filter_control
+ clearCookie.py -> FolderContentsView.clear_filter_control
[x] IMutableMinimalDublinCore @@properties.html:
Modified: CMF/trunk/CMFDefault/browser/folder.py
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.py 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/browser/folder.py 2006-04-24 18:30:03 UTC (rev 67575)
@@ -19,6 +19,7 @@
from ZTUtils import LazyFilter
from ZTUtils import make_query
+from Products.CMFCore.interfaces import IDynamicType
from Products.CMFDefault.exceptions import CopyError
from Products.CMFDefault.exceptions import zExceptions_Unauthorized
from Products.CMFDefault.permissions import AddPortalContent
@@ -125,7 +126,13 @@
'permissions': (ManageProperties,),
'transform': ('validateItemIds', 'bottom_control'),
'redirect': ('portal_types', 'object/folderContents',
- 'b_start, key, reverse')})
+ 'b_start, key, reverse')},
+ {'id': 'set_view_filter',
+ 'transform': ('set_filter_control',),
+ 'redirect': ('portal_types', 'object/folderContents')},
+ {'id': 'clear_view_filter',
+ 'transform': ('clear_filter_control',),
+ 'redirect': ('portal_types', 'object/folderContents')})
# helpers
@@ -151,7 +158,6 @@
@memoize
def _getItems(self):
(key, reverse) = self._getSorting()
- self.context.filterCookie()
folderfilter = self.request.get('folderfilter', '')
filter = self.context.decodeFolderFilter(folderfilter)
items = self.context.listFolderContents(contentFilter=filter)
@@ -168,7 +174,7 @@
'aq_parent')
if allowed:
up_obj = self.context.aq_inner.aq_parent
- if hasattr(up_obj, 'portal_url'):
+ if IDynamicType.providedBy(up_obj):
up_url = up_obj.getActionInfo('object/folderContents')['url']
return {'icon': '%s/UpFolder_icon.gif' % self._getPortalURL(),
'id': up_obj.getId(),
@@ -398,3 +404,14 @@
return False, _(u'Nothing to change.')
except ValueError:
return False, _(u'ValueError: Move failed.')
+
+ def set_filter_control(self, **kw):
+ filter = self.context.encodeFolderFilter(self.request)
+ self.request.RESPONSE.setCookie('folderfilter', filter, path='/',
+ expires='Wed, 19 Feb 2020 14:28:00 GMT')
+ return True, _(u'Filter applied.')
+
+ def clear_filter_control(self, **kw):
+ self.request.RESPONSE.expireCookie('folderfilter', path='/')
+ self.request.RESPONSE.expireCookie('show_filter_form', path='/')
+ return True, _(u'Filter cleared.')
Added: CMF/trunk/CMFDefault/browser/folder.txt
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.txt 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/browser/folder.txt 2006-04-24 18:30:03 UTC (rev 67575)
@@ -0,0 +1,100 @@
+Browser Views for IFolderish
+
+
+ The required environment:
+
+ Setting up a dummy site with required tools::
+
+ >>> from Products.CMFCore.tests.base.dummy import DummySite
+ >>> site = DummySite('site')
+
+ >>> from Products.CMFCore.tests.base.dummy import DummyTool
+ >>> mtool = site._setObject('portal_membership', DummyTool())
+ >>> ptool = site._setObject('portal_properties', DummyTool())
+ >>> ttool = site._setObject('portal_types', DummyTool())
+ >>> utool = site._setObject('portal_url', DummyTool())
+
+
+ Basic functionality without security setup:
+
+ Setting up a simple request and an empty context object::
+
+ >>> class DummyRequest(dict):
+ ... def __init__(self):
+ ... self['ACTUAL_URL'] = 'actual_url'
+ ... self.form = {}
+ >>> request = DummyRequest()
+
+ >>> from Products.CMFCore.PortalFolder import PortalFolder
+ >>> context = PortalFolder('foo').__of__(site)
+
+ The FolderView interface used by templates::
+
+ >>> from Products.CMFDefault.browser.folder import FolderView
+ >>> view = FolderView(context, request)
+
+ >>> view.title()
+ u''
+
+ >>> view.description()
+ u''
+
+ >>> view.has_local()
+ False
+
+ The FolderContentsView interface used by templates::
+
+ >>> from Products.CMFDefault.browser.folder import FolderContentsView
+ >>> view = FolderContentsView(context, request)
+
+ >>> view.title()
+ u''
+
+ >>> view.description()
+ u''
+
+ >>> view.up_info()
+ {'url': u'', 'id': u'Root', 'icon': u''}
+
+ >>> view.listColumnInfos()
+ ({'url': 'actual_url?key=Type', 'width': '20', 'colspan': '2',
+ 'key': 'Type', 'title': u'Type'},
+ {'url': 'actual_url?key=getId', 'width': '360', 'colspan': None,
+ 'key': 'getId', 'title': u'Name'},
+ {'url': 'actual_url?key=modified', 'width': '180', 'colspan': None,
+ 'key': 'modified', 'title': u'Last Modified'},
+ {'url': 'actual_url?key=position', 'width': '80', 'colspan': None,
+ 'key': 'position', 'title': u'Position'})
+
+ >>> view.listItemInfos()
+ ()
+
+ >>> view.listDeltas()
+ ()
+
+ >>> view.is_orderable()
+ False
+
+ >>> view.is_sortable()
+ False
+
+ The FolderContentsView checkers used by button actions::
+
+ >>> view.checkAllowedContentTypes()
+ True
+
+ >>> view.checkClipboardData()
+ False
+
+ >>> view.checkItems()
+ False
+
+ The FolderContentsView validators used by button actions::
+
+ >>> view.validateItemIds()
+ (False, u'Please select one or more items first.')
+ >>> view.validateItemIds(('foo',))
+ True
+
+ >>> view.validateClipboardData()
+ (False, u'Please copy or cut one or more items to paste first.')
Property changes on: CMF/trunk/CMFDefault/browser/folder.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFDefault/browser/tests.py
===================================================================
--- CMF/trunk/CMFDefault/browser/tests.py 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/browser/tests.py 2006-04-24 18:30:03 UTC (rev 67575)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""CMFDefault browser tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+from zope.testing import doctest
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite('folder.txt',
+ optionflags=doctest.NORMALIZE_WHITESPACE),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: CMF/trunk/CMFDefault/browser/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFDefault/locales/cmf_default.pot
===================================================================
--- CMF/trunk/CMFDefault/locales/cmf_default.pot 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/locales/cmf_default.pot 2006-04-24 18:30:03 UTC (rev 67575)
@@ -74,10 +74,10 @@
msgstr ""
#: CMFDefault/browser/document.py:111
-#: CMFDefault/browser/folder.py:353
-#: CMFDefault/browser/folder.py:368
-#: CMFDefault/browser/folder.py:383
-#: CMFDefault/browser/folder.py:398
+#: CMFDefault/browser/folder.py:359
+#: CMFDefault/browser/folder.py:374
+#: CMFDefault/browser/folder.py:389
+#: CMFDefault/browser/folder.py:404
#: CMFDefault/browser/link.py:74
#: CMFDefault/browser/metadata.py:63
#: CMFDefault/browser/newsitem.py:53
@@ -127,7 +127,7 @@
msgid "Change and View"
msgstr ""
-#: CMFDefault/browser/folder.py:187
+#: CMFDefault/browser/folder.py:193
#: CMFDefault/skins/zpt_generic/folder_contents.py:113
#: CMFDefault/skins/zpt_generic/metadata_help.pt:110
#: CMFDefault/skins/zpt_generic/review.pt:25
@@ -135,110 +135,110 @@
msgid "Type"
msgstr ""
-#: CMFDefault/browser/folder.py:191
+#: CMFDefault/browser/folder.py:197
#: CMFDefault/skins/zpt_generic/folder_contents.py:117
msgid "Name"
msgstr ""
-#: CMFDefault/browser/folder.py:195
+#: CMFDefault/browser/folder.py:201
#: CMFDefault/skins/zpt_generic/folder_contents.py:121
msgid "Last Modified"
msgstr ""
-#: CMFDefault/browser/folder.py:199
+#: CMFDefault/browser/folder.py:205
#: CMFDefault/skins/zpt_generic/folder_contents.py:125
msgid "Position"
msgstr ""
-#: CMFDefault/browser/folder.py:276
+#: CMFDefault/browser/folder.py:282
#: CMFDefault/skins/zpt_control/validateItemIds.py:8
msgid "Please select one or more items first."
msgstr ""
-#: CMFDefault/browser/folder.py:282
+#: CMFDefault/browser/folder.py:288
#: CMFDefault/skins/zpt_control/validateClipboardData.py:8
msgid "Please copy or cut one or more items to paste first."
msgstr ""
-#: CMFDefault/browser/folder.py:293
+#: CMFDefault/browser/folder.py:299
#: CMFDefault/skins/zpt_control/folder_cut_control.py:11
msgid "Item cut."
msgstr ""
-#: CMFDefault/browser/folder.py:295
+#: CMFDefault/browser/folder.py:301
#: CMFDefault/skins/zpt_control/folder_cut_control.py:13
msgid "Items cut."
msgstr ""
-#: CMFDefault/browser/folder.py:297
+#: CMFDefault/browser/folder.py:303
#: CMFDefault/skins/zpt_control/folder_cut_control.py:15
msgid "CopyError: Cut failed."
msgstr ""
-#: CMFDefault/browser/folder.py:299
+#: CMFDefault/browser/folder.py:305
#: CMFDefault/skins/zpt_control/folder_cut_control.py:17
msgid "Unauthorized: Cut failed."
msgstr ""
-#: CMFDefault/browser/folder.py:307
+#: CMFDefault/browser/folder.py:313
#: CMFDefault/skins/zpt_control/folder_copy_control.py:10
msgid "Item copied."
msgstr ""
-#: CMFDefault/browser/folder.py:309
+#: CMFDefault/browser/folder.py:315
#: CMFDefault/skins/zpt_control/folder_copy_control.py:12
msgid "Items copied."
msgstr ""
-#: CMFDefault/browser/folder.py:311
+#: CMFDefault/browser/folder.py:317
#: CMFDefault/skins/zpt_control/folder_copy_control.py:14
msgid "CopyError: Copy failed."
msgstr ""
-#: CMFDefault/browser/folder.py:319
+#: CMFDefault/browser/folder.py:325
#: CMFDefault/skins/zpt_control/folder_paste_control.py:11
msgid "Item pasted."
msgstr ""
-#: CMFDefault/browser/folder.py:321
+#: CMFDefault/browser/folder.py:327
#: CMFDefault/skins/zpt_control/folder_paste_control.py:13
msgid "Items pasted."
msgstr ""
-#: CMFDefault/browser/folder.py:323
+#: CMFDefault/browser/folder.py:329
#: CMFDefault/skins/zpt_control/folder_paste_control.py:15
msgid "CopyError: Paste failed."
msgstr ""
-#: CMFDefault/browser/folder.py:325
+#: CMFDefault/browser/folder.py:331
#: CMFDefault/skins/zpt_control/folder_paste_control.py:17
msgid "Unauthorized: Paste failed."
msgstr ""
-#: CMFDefault/browser/folder.py:332
+#: CMFDefault/browser/folder.py:338
#: CMFDefault/skins/zpt_control/folder_delete_control.py:9
msgid "Item deleted."
msgstr ""
-#: CMFDefault/browser/folder.py:334
+#: CMFDefault/browser/folder.py:340
#: CMFDefault/skins/zpt_control/folder_delete_control.py:11
msgid "Items deleted."
msgstr ""
-#: CMFDefault/browser/folder.py:349
+#: CMFDefault/browser/folder.py:355
#: CMFDefault/skins/zpt_control/folder_up_control.py:9
msgid "Item moved up."
msgstr ""
-#: CMFDefault/browser/folder.py:351
+#: CMFDefault/browser/folder.py:357
#: CMFDefault/skins/zpt_control/folder_up_control.py:11
msgid "Items moved up."
msgstr ""
-#: CMFDefault/browser/folder.py:355
-#: CMFDefault/browser/folder.py:370
-#: CMFDefault/browser/folder.py:385
-#: CMFDefault/browser/folder.py:400
+#: CMFDefault/browser/folder.py:361
+#: CMFDefault/browser/folder.py:376
+#: CMFDefault/browser/folder.py:391
+#: CMFDefault/browser/folder.py:406
#: CMFDefault/skins/zpt_control/folder_bottom_control.py:15
#: CMFDefault/skins/zpt_control/folder_down_control.py:15
#: CMFDefault/skins/zpt_control/folder_top_control.py:15
@@ -246,63 +246,71 @@
msgid "ValueError: Move failed."
msgstr ""
-#: CMFDefault/browser/folder.py:364
+#: CMFDefault/browser/folder.py:370
#: CMFDefault/skins/zpt_control/folder_down_control.py:9
msgid "Item moved down."
msgstr ""
-#: CMFDefault/browser/folder.py:366
+#: CMFDefault/browser/folder.py:372
#: CMFDefault/skins/zpt_control/folder_down_control.py:11
msgid "Items moved down."
msgstr ""
-#: CMFDefault/browser/folder.py:379
+#: CMFDefault/browser/folder.py:385
#: CMFDefault/skins/zpt_control/folder_top_control.py:9
msgid "Item moved to top."
msgstr ""
-#: CMFDefault/browser/folder.py:381
+#: CMFDefault/browser/folder.py:387
#: CMFDefault/skins/zpt_control/folder_top_control.py:11
msgid "Items moved to top."
msgstr ""
-#: CMFDefault/browser/folder.py:394
+#: CMFDefault/browser/folder.py:400
#: CMFDefault/skins/zpt_control/folder_bottom_control.py:9
msgid "Item moved to bottom."
msgstr ""
-#: CMFDefault/browser/folder.py:396
+#: CMFDefault/browser/folder.py:402
#: CMFDefault/skins/zpt_control/folder_bottom_control.py:11
msgid "Items moved to bottom."
msgstr ""
-#: CMFDefault/browser/folder.py:65
+#: CMFDefault/browser/folder.py:412
+msgid "Filter applied."
+msgstr ""
+
+#: CMFDefault/browser/folder.py:417
+msgid "Filter cleared."
+msgstr ""
+
+#: CMFDefault/browser/folder.py:66
#: CMFDefault/skins/zpt_generic/folder_contents.py:172
#: CMFDefault/skins/zpt_generic/members_manage_form.py:50
msgid "New..."
msgstr ""
-#: CMFDefault/browser/folder.py:70
+#: CMFDefault/browser/folder.py:71
#: CMFDefault/skins/zpt_generic/folder_contents.py:175
msgid "Rename..."
msgstr ""
-#: CMFDefault/browser/folder.py:77
+#: CMFDefault/browser/folder.py:78
#: CMFDefault/skins/zpt_generic/folder_contents.py:177
msgid "Cut"
msgstr ""
-#: CMFDefault/browser/folder.py:84
+#: CMFDefault/browser/folder.py:85
#: CMFDefault/skins/zpt_generic/folder_contents.py:178
msgid "Copy"
msgstr ""
-#: CMFDefault/browser/folder.py:91
+#: CMFDefault/browser/folder.py:92
#: CMFDefault/skins/zpt_generic/folder_contents.py:180
msgid "Paste"
msgstr ""
-#: CMFDefault/browser/folder.py:98
+#: CMFDefault/browser/folder.py:99
#: CMFDefault/skins/zpt_generic/folder_contents.py:182
#: CMFDefault/skins/zpt_generic/members_delete_form.py:28
#: CMFDefault/skins/zpt_generic/folder_localrole_form.pt:196
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/folder_filter_form.pt
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/folder_filter_form.pt 2006-04-24 18:20:09 UTC (rev 67574)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/folder_filter_form.pt 2006-04-24 18:30:03 UTC (rev 67575)
@@ -75,8 +75,7 @@
</td>
</tr>
</table>
-<span tal:condition="hidefilter">
+ <div tal:condition="hidefilter" class="FormButtons">
<input type="submit" name="open_filter_form" value="Set View Filter"
- i18n:attributes="value" />
-</span>
+ i18n:attributes="value" /></div>
</form>
More information about the CMF-checkins
mailing list