[CMF-checkins]
SVN: CMF/branches/goldegg-folder_contents/CMFDefault/
first cut of folder_contents view
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun Sep 25 09:47:38 EDT 2005
Log message for revision 38617:
first cut of folder_contents view
Changed:
A CMF/branches/goldegg-folder_contents/CMFDefault/browser/
A CMF/branches/goldegg-folder_contents/CMFDefault/browser/__init__.py
A CMF/branches/goldegg-folder_contents/CMFDefault/browser/configure.zcml
A CMF/branches/goldegg-folder_contents/CMFDefault/browser/folder_contents.py
U CMF/branches/goldegg-folder_contents/CMFDefault/configure.zcml
U CMF/branches/goldegg-folder_contents/CMFDefault/skins/zpt_generic/folder_contents_template.pt
-=-
Added: CMF/branches/goldegg-folder_contents/CMFDefault/browser/__init__.py
===================================================================
--- CMF/branches/goldegg-folder_contents/CMFDefault/browser/__init__.py 2005-09-25 13:35:59 UTC (rev 38616)
+++ CMF/branches/goldegg-folder_contents/CMFDefault/browser/__init__.py 2005-09-25 13:47:37 UTC (rev 38617)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2005 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 package.
+
+$Id$
+"""
Property changes on: CMF/branches/goldegg-folder_contents/CMFDefault/browser/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/branches/goldegg-folder_contents/CMFDefault/browser/configure.zcml
===================================================================
--- CMF/branches/goldegg-folder_contents/CMFDefault/browser/configure.zcml 2005-09-25 13:35:59 UTC (rev 38616)
+++ CMF/branches/goldegg-folder_contents/CMFDefault/browser/configure.zcml 2005-09-25 13:47:37 UTC (rev 38617)
@@ -0,0 +1,11 @@
+<configure xmlns="http://namespaces.zope.org/browser">
+
+ <page
+ for="Products.CMFCore.interfaces.IFolderish"
+ name="folder_contents"
+ class=".folder_contents.FolderContents"
+ template="../skins/zpt_generic/folder_contents_template.pt"
+ permission="zope2.View"
+ />
+
+</configure>
Property changes on: CMF/branches/goldegg-folder_contents/CMFDefault/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: CMF/branches/goldegg-folder_contents/CMFDefault/browser/folder_contents.py
===================================================================
--- CMF/branches/goldegg-folder_contents/CMFDefault/browser/folder_contents.py 2005-09-25 13:35:59 UTC (rev 38616)
+++ CMF/branches/goldegg-folder_contents/CMFDefault/browser/folder_contents.py 2005-09-25 13:47:37 UTC (rev 38617)
@@ -0,0 +1,220 @@
+from Products.Five.browser import BrowserView
+from AccessControl import ClassSecurityInfo
+
+from ZTUtils import Batch
+from ZTUtils import make_query
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.permissions import AddPortalContent
+from Products.CMFDefault.permissions import DeleteObjects
+from Products.CMFDefault.permissions import ListFolderContents
+from Products.CMFDefault.permissions import ManageProperties
+from Products.CMFDefault.permissions import ViewManagementScreens
+from Products.CMFDefault.utils import html_marshal
+from Products.CMFDefault.utils import MessageID as _
+
+from DocumentTemplate import sequence
+
+class FolderContents(BrowserView):
+
+ _DEFAULT_TARGET = 'object/folderContents'
+
+ def _portal_url(self):
+ utool = getToolByName(self.context, 'portal_url')
+ return utool()
+
+ def _upitems_list_allowed(self):
+ mtool = getToolByName(self.context, 'portal_membership')
+ return mtool.checkPermission(ListFolderContents, self.context,
+ 'aq_parent')
+
+ def _items_manage_allowed(self):
+ mtool = getToolByName(self.context, 'portal_membership')
+ return mtool.checkPermission(ViewManagementScreens, self.context)
+
+ def _items_delete_allowed(self):
+ mtool = getToolByName(self.context, 'portal_membership')
+ return mtool.checkPermission(DeleteObjects, self.context)
+
+ def _items_add_allowed(self):
+ mtool = getToolByName(self.context, 'portal_membership')
+ return mtool.checkPermission(AddPortalContent, self.context)
+
+ def _items_move_allowed(self):
+ mtool = getToolByName(self.context, 'portal_membership')
+ return mtool.checkPermission(ManageProperties, self.context)
+
+ def _is_default(self):
+ if not self.key:
+ (self.key, self.reverse) = self.context.getDefaultSorting()
+ return 1
+ elif (self.key, self.reverse) == self.context.getDefaultSorting():
+ return 1
+ else:
+ return 0
+
+ def action(self):
+ return self.context.getActionInfo(self._DEFAULT_TARGET)['url']
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ context = self.context
+ form = self.request.form
+ default_target = self._DEFAULT_TARGET
+ ids = form.get('ids', ())
+ b_start = self.b_start = form.get('b_start', 0)
+ key = self.key = form.get('key', '')
+ reverse = self.reverse = form.get('reverse', '')
+ default_kw = self.default_kw = {'b_start': b_start, 'key': key,
+ 'reverse': reverse}
+ if 'items_copy' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_copy_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_cut' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_cut_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_delete' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_delete_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_new' in form and \
+ context.setRedirect(context, 'object/new'):
+ return
+ elif 'items_paste' in form and \
+ context.folder_paste_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_rename' in form and \
+ context.validateItemIds(**form) and \
+ context.setRedirect(context, 'object/rename_items', ids=ids,
+ **default_kw):
+ return
+ elif 'items_sort' in form and \
+ context.folder_sort_control(**form) and \
+ context.setRedirect(context, default_target, b_start=b_start):
+ return
+ elif 'items_up' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_up_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_down' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_down_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_top' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_top_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ elif 'items_bottom' in form and \
+ context.validateItemIds(**form) and \
+ context.folder_bottom_control(**form) and \
+ context.setRedirect(context, default_target, **default_kw):
+ return
+ return self.index()
+
+ def up_info(self):
+ if self._upitems_list_allowed():
+ up_obj = self.context.aq_parent
+ if hasattr(up_obj, 'portal_url'):
+ up_url = up_obj.getActionInfo('object/folderContents')['url']
+ return {'icon': '%s/UpFolder_icon.gif' % self._portal_url(),
+ 'id': up_obj.getId(),
+ 'url': up_url }
+ else:
+ return {'icon': '',
+ 'id': 'Root',
+ 'url': ''}
+ else:
+ return {}
+
+ def batch(self):
+ columns = ( {'key': 'Type',
+ 'title': _('Type'),
+ 'width': '20',
+ 'colspan': '2'}
+ , {'key': 'getId',
+ 'title': _('Name'),
+ 'width': '360',
+ 'colspan': None}
+ , {'key': 'modified',
+ 'title': _('Last Modified'),
+ 'width': '180',
+ 'colspan': None}
+ , {'key': 'position',
+ 'title': _('Position'),
+ 'width': '80',
+ 'colspan': None }
+ )
+ for column in columns:
+ if self.key == column['key'] and not self.reverse and self.key != 'position':
+ query = make_query(key=column['key'], reverse=1)
+ else:
+ query = make_query(key=column['key'])
+ column['url'] = '%s?%s' % (self.action(), query)
+
+ self.context.filterCookie()
+ folderfilter = self.request.get('folderfilter', '')
+ filter = self.context.decodeFolderFilter(folderfilter)
+ items = self.context.listFolderContents(contentFilter=filter)
+ items = sequence.sort( items, ((self.key, 'cmp', self.reverse and 'desc' or 'asc'),) )
+ batch_obj = Batch(items, 25, self.b_start, orphan=0)
+ items = self.items = []
+ i = 1
+ for item in batch_obj:
+ item_icon = item.getIcon(1)
+ item_id = item.getId()
+ item_position = self.key == 'position' and str(self.b_start + i) or '...'
+ i += 1
+ item_url = item.getActionInfo( ('object/folderContents',
+ 'object/view') )['url']
+ items.append( { 'checkbox': self._items_manage_allowed() and
+ ('cb_%s' % item_id) or '',
+ 'icon': item_icon and
+ ( '%s/%s' % (self._portal_url(), item_icon) ) or '',
+ 'id': item_id,
+ 'modified': item.ModificationDate(),
+ 'position': item_position,
+ 'title': item.Title(),
+ 'type': item.Type() or None,
+ 'url': item_url } )
+ navigation = self.context.getBatchNavigation(batch_obj, self.action(), **self.default_kw)
+ self.length = batch_obj.sequence_length
+ return { 'listColumnInfos': tuple(columns),
+ 'listItemInfos': tuple(items),
+ 'navigation': navigation }
+
+ def form(self):
+ hidden_vars = []
+ for name, value in html_marshal(**self.default_kw):
+ hidden_vars.append( {'name': name, 'value': value} )
+ buttons = []
+ if self._items_manage_allowed():
+ if self._items_add_allowed() and self.context.allowedContentTypes():
+ buttons.append( {'name': 'items_new', 'value': _('New...')} )
+ if self.items:
+ buttons.append( {'name': 'items_rename', 'value': _('Rename')} )
+ if self.items:
+ buttons.append( {'name': 'items_cut', 'value': _('Cut')} )
+ buttons.append( {'name': 'items_copy', 'value': _('Copy')} )
+ if self._items_add_allowed() and self.context.cb_dataValid():
+ buttons.append( {'name': 'items_paste', 'value': _('Paste')} )
+ if self._items_delete_allowed() and self.items:
+ buttons.append( {'name': 'items_delete', 'value': _('Delete')} )
+ is_orderable = self._items_move_allowed() and (self.key == 'position') and self.length > 1
+ is_sortable = self._items_move_allowed() and not self._is_default()
+ deltas = range( 1, min(5, self.length) ) + range(5, self.length, 5)
+ return { 'listHiddenVarInfos': tuple(hidden_vars),
+ 'listButtonInfos': tuple(buttons),
+ 'listDeltas': tuple(deltas),
+ 'is_orderable': is_orderable,
+ 'is_sortable': is_sortable }
Property changes on: CMF/branches/goldegg-folder_contents/CMFDefault/browser/folder_contents.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/branches/goldegg-folder_contents/CMFDefault/configure.zcml
===================================================================
--- CMF/branches/goldegg-folder_contents/CMFDefault/configure.zcml 2005-09-25 13:35:59 UTC (rev 38616)
+++ CMF/branches/goldegg-folder_contents/CMFDefault/configure.zcml 2005-09-25 13:47:37 UTC (rev 38617)
@@ -2,6 +2,8 @@
xmlns="http://namespaces.zope.org/zope"
>
+ <include package=".browser"/>
+
<include package=".skin"/>
</configure>
Modified: CMF/branches/goldegg-folder_contents/CMFDefault/skins/zpt_generic/folder_contents_template.pt
===================================================================
--- CMF/branches/goldegg-folder_contents/CMFDefault/skins/zpt_generic/folder_contents_template.pt 2005-09-25 13:35:59 UTC (rev 38616)
+++ CMF/branches/goldegg-folder_contents/CMFDefault/skins/zpt_generic/folder_contents_template.pt 2005-09-25 13:47:37 UTC (rev 38617)
@@ -7,9 +7,9 @@
</metal:slot>
<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
- tal:define="batch options/batch;
- form options/form;
- up_info options/up_info">
+ tal:define="batch view/batch|options/batch;
+ form view/form|options/form;
+ up_info view/up_info|options/up_info">
<div class="Desktop">
<p tal:condition="up_info"
@@ -24,7 +24,7 @@
><span class="mild" i18n:translate="">Root</span></tal:case></p>
<form action="folder_contents" method="post"
- tal:attributes="action form/action"
+ tal:attributes="action view/action|form/action"
><metal:macro metal:use-macro="context/form_widgets/macros/hidden_vars" />
<table class="BatchTable"
tal:condition="batch/listItemInfos">
More information about the CMF-checkins
mailing list