[CMF-checkins] SVN: CMF/branches/2.0/CMF merged r67574:r67575 from trunk:

Yvo Schubbe y.2006_ at wcm-solutions.de
Mon Apr 24 14:45:58 EDT 2006


Log message for revision 67576:
  merged r67574:r67575 from trunk:
  - added basic tests for folder views
  - converted filterCookie.py and clearCookie.py scripts to view methods
  - updated cmf_default.pot

Changed:
  U   CMF/branches/2.0/CMFCore/PortalFolder.py
  U   CMF/branches/2.0/CMFCore/tests/base/dummy.py
  U   CMF/branches/2.0/CMFDefault/browser/TODO.txt
  U   CMF/branches/2.0/CMFDefault/browser/folder.py
  A   CMF/branches/2.0/CMFDefault/browser/folder.txt
  A   CMF/branches/2.0/CMFDefault/browser/tests.py
  U   CMF/branches/2.0/CMFDefault/locales/cmf_default.pot
  U   CMF/branches/2.0/CMFDefault/skins/zpt_generic/folder_filter_form.pt

-=-
Modified: CMF/branches/2.0/CMFCore/PortalFolder.py
===================================================================
--- CMF/branches/2.0/CMFCore/PortalFolder.py	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFCore/PortalFolder.py	2006-04-24 18:45:58 UTC (rev 67576)
@@ -148,7 +148,7 @@
             # We'll modify it, work on a copy.
             filt = filt.copy()
         pt = filt.get('portal_type', [])
-        if type(pt) is type(''):
+        if isinstance(pt, basestring):
             pt = [pt]
         types_tool = getToolByName(self, 'portal_types')
         allowed_types = types_tool.listContentTypes()
@@ -553,14 +553,14 @@
                 self.description.append( 'Modified before: %s' % modified )
 
         if Type:
-            if type( Type ) == type( '' ):
-                Type = [ Type ]
+            if isinstance(Type, basestring):
+                Type = [Type]
             self.predicates.append( lambda x, Type=Type:
                                       x.Type() in Type )
             self.description.append( 'Type: %s' % ', '.join(Type) )
 
         if portal_type and portal_type is not self.MARKER:
-            if type(portal_type) is type(''):
+            if isinstance(portal_type, basestring):
                 portal_type = [portal_type]
             self.predicates.append( lambda x, pt=portal_type:
                                     hasattr(aq_base(x), 'getPortalTypeName')

Modified: CMF/branches/2.0/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/branches/2.0/CMFCore/tests/base/dummy.py	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFCore/tests/base/dummy.py	2006-04-24 18:45:58 UTC (rev 67576)
@@ -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/branches/2.0/CMFDefault/browser/TODO.txt
===================================================================
--- CMF/branches/2.0/CMFDefault/browser/TODO.txt	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFDefault/browser/TODO.txt	2006-04-24 18:45:58 UTC (rev 67576)
@@ -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/branches/2.0/CMFDefault/browser/folder.py
===================================================================
--- CMF/branches/2.0/CMFDefault/browser/folder.py	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFDefault/browser/folder.py	2006-04-24 18:45:58 UTC (rev 67576)
@@ -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.')

Copied: CMF/branches/2.0/CMFDefault/browser/folder.txt (from rev 67575, CMF/trunk/CMFDefault/browser/folder.txt)

Copied: CMF/branches/2.0/CMFDefault/browser/tests.py (from rev 67575, CMF/trunk/CMFDefault/browser/tests.py)

Modified: CMF/branches/2.0/CMFDefault/locales/cmf_default.pot
===================================================================
--- CMF/branches/2.0/CMFDefault/locales/cmf_default.pot	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFDefault/locales/cmf_default.pot	2006-04-24 18:45:58 UTC (rev 67576)
@@ -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/branches/2.0/CMFDefault/skins/zpt_generic/folder_filter_form.pt
===================================================================
--- CMF/branches/2.0/CMFDefault/skins/zpt_generic/folder_filter_form.pt	2006-04-24 18:30:03 UTC (rev 67575)
+++ CMF/branches/2.0/CMFDefault/skins/zpt_generic/folder_filter_form.pt	2006-04-24 18:45:58 UTC (rev 67576)
@@ -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