Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions | Static Private Attributes
CMFDefault.browser.folder.FolderContentsView Class Reference
Inheritance diagram for CMFDefault.browser.folder.FolderContentsView:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.browser.folder.FolderContentsView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def up_info
def listColumnInfos
def listItemInfos
def listDeltas
def is_orderable
def is_sortable
def checkAllowedContentTypes
def checkClipboardData
def checkItems
def validateItemIds
def validateClipboardData
def cut_control
def copy_control
def paste_control
def delete_control
def sort_control
def up_control
def down_control
def top_control
def bottom_control
def set_filter_control
def clear_filter_control
def navigation_previous
def navigation_next
def summary_length
def summary_type
def summary_match
def __call__
def form_action
def listButtonInfos
def listHiddenVarInfos

Private Member Functions

def _getSorting
def _isDefaultSorting
def _getHiddenVars
def _getItems

Static Private Attributes

tuple _BUTTONS

Detailed Description

Contents view for IFolderish.

Definition at line 262 of file folder.py.


Member Function Documentation

def CMFDefault.browser.folder.FormViewBase.__call__ (   self,
  kw 
) [inherited]

Definition at line 74 of file folder.py.

00074 
00075     def __call__(self, **kw):
00076         form = self.request.form
00077         for button in self._BUTTONS:
00078             if button['id'] in form:
00079                 for permission in button.get('permissions', ()):
00080                     if not self._checkPermission(permission):
00081                         break
00082                 else:
00083                     for transform in button.get('transform', ()):
00084                         status = getattr(self, transform)(**form)
00085                         if isinstance(status, bool):
00086                             status = (status,)
00087                         if len(status) > 1:
00088                             message = translate(status[1], self.context)
00089                             self.request.other['portal_status_message'] = message
00090                         if not status[0]:
00091                             return self.index()
00092                     if self._setRedirect(*button['redirect']):
00093                         return
00094         return self.index()

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from CMFDefault.browser.folder.BatchViewBase.

Definition at line 354 of file folder.py.

00354 
00355     def _getHiddenVars(self):
00356         b_start = self._getBatchStart()
00357         is_default = self._isDefaultSorting()
00358         (key, reverse) = is_default and ('', 0) or self._getSorting()
00359         return {'b_start': b_start, 'key': key, 'reverse': reverse}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 361 of file folder.py.

00361 
00362     def _getItems(self):
00363         (key, reverse) = self._getSorting()
00364         folderfilter = self.request.get('folderfilter', '')
00365         filter = self.context.decodeFolderFilter(folderfilter)
00366         items = self.context.listFolderContents(contentFilter=filter)
00367         return sequence.sort(items,
00368                              ((key, 'cmp', reverse and 'desc' or 'asc'),))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 342 of file folder.py.

00342 
00343     def _getSorting(self):
00344         key = self.request.form.get('key', None)
00345         if key:
00346             return (key, self.request.form.get('reverse', 0))
00347         else:
00348             return self.context.getDefaultSorting()

Here is the caller graph for this function:

Definition at line 350 of file folder.py.

00350 
00351     def _isDefaultSorting(self):
00352         return self._getSorting() == self.context.getDefaultSorting()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 594 of file folder.py.

00594 
00595     def bottom_control(self, ids, **kw):
00596         subset_ids = [ obj.getId()
00597                        for obj in self.context.listFolderContents() ]
00598         try:
00599             attempt = self.context.moveObjectsToBottom(ids,
00600                                                        subset_ids=subset_ids)
00601             if attempt == 1:
00602                 return True, _(u'Item moved to bottom.')
00603             elif attempt > 1:
00604                 return True, _(u'Items moved to bottom.')
00605             else:
00606                 return False, _(u'Nothing to change.')
00607         except ValueError:
00608             return False, _(u'ValueError: Move failed.')

Definition at line 468 of file folder.py.

00468 
00469     def checkAllowedContentTypes(self):
00470         return bool(self.context.allowedContentTypes())

Definition at line 471 of file folder.py.

00471 
00472     def checkClipboardData(self):
00473         return bool(self.context.cb_dataValid())

Definition at line 474 of file folder.py.

00474 
00475     def checkItems(self):
00476         return bool(self._getItems())

Here is the call graph for this function:

Definition at line 615 of file folder.py.

00615 
00616     def clear_filter_control(self, **kw):
00617         self.request.RESPONSE.expireCookie('folderfilter', path='/')
00618         self.request.RESPONSE.expireCookie('show_filter_form', path='/')
00619         return True, _(u'Filter cleared.')
Copy objects from a folder to the clipboard.

Definition at line 508 of file folder.py.

00508 
00509     def copy_control(self, ids, **kw):
00510         """Copy objects from a folder to the clipboard.
00511         """
00512         try:
00513             self.context.manage_copyObjects(ids, self.request)
00514             if len(ids) == 1:
00515                 return True, _(u'Item copied.')
00516             else:
00517                 return True, _(u'Items copied.')
00518         except CopyError:
00519             return False, _(u'CopyError: Copy failed.')

Cut objects from a folder and copy to the clipboard.

Definition at line 494 of file folder.py.

00494 
00495     def cut_control(self, ids, **kw):
00496         """Cut objects from a folder and copy to the clipboard.
00497         """
00498         try:
00499             self.context.manage_cutObjects(ids, self.request)
00500             if len(ids) == 1:
00501                 return True, _(u'Item cut.')
00502             else:
00503                 return True, _(u'Items cut.')
00504         except CopyError:
00505             return False, _(u'CopyError: Cut failed.')
00506         except zExceptions_Unauthorized:
00507             return False, _(u'Unauthorized: Cut failed.')

Delete objects from a folder.

Definition at line 534 of file folder.py.

00534 
00535     def delete_control(self, ids, **kw):
00536         """Delete objects from a folder.
00537         """
00538         self.context.manage_delObjects(list(ids))
00539         if len(ids) == 1:
00540             return True, _(u'Item deleted.')
00541         else:
00542             return True, _(u'Items deleted.')

def CMFDefault.browser.folder.FolderContentsView.down_control (   self,
  ids,
  delta,
  kw 
)

Definition at line 564 of file folder.py.

00564 
00565     def down_control(self, ids, delta, **kw):
00566         subset_ids = [ obj.getId()
00567                        for obj in self.context.listFolderContents() ]
00568         try:
00569             attempt = self.context.moveObjectsDown(ids, delta,
00570                                                    subset_ids=subset_ids)
00571             if attempt == 1:
00572                 return True, _(u'Item moved down.')
00573             elif attempt > 1:
00574                 return True, _(u'Items moved down.')
00575             else:
00576                 return False, _(u'Nothing to change.')
00577         except ValueError:
00578             return False, _(u'ValueError: Move failed.')

Definition at line 96 of file folder.py.

00096 
00097     def form_action(self):
00098         return self._getViewURL()

Here is the call graph for this function:

Definition at line 455 of file folder.py.

00455 
00456     def is_orderable(self):
00457         length = len(self._getBatchObj())
00458         items_move_allowed = self._checkPermission(ManageProperties)
00459         (key, reverse) = self._getSorting()
00460         return items_move_allowed and (key == 'position') and length > 1

Here is the call graph for this function:

Definition at line 462 of file folder.py.

00462 
00463     def is_sortable(self):
00464         items_move_allowed = self._checkPermission(ManageProperties)
00465         return items_move_allowed and not self._isDefaultSorting()

Here is the call graph for this function:

Definition at line 100 of file folder.py.

00100 
00101     def listButtonInfos(self):
00102         form = self.request.form
00103         buttons = []
00104         for button in self._BUTTONS:
00105             if button.get('title', None):
00106                 for permission in button.get('permissions', ()):
00107                     if not self._checkPermission(permission):
00108                         break
00109                 else:
00110                     for condition in button.get('conditions', ()):
00111                         if not getattr(self, condition)():
00112                             break
00113                     else:
00114                         buttons.append({'name': button['id'],
00115                                         'value': button['title']})
00116         return tuple(buttons)

Here is the call graph for this function:

Definition at line 391 of file folder.py.

00391 
00392     def listColumnInfos(self):
00393         (key, reverse) = self._getSorting()
00394         columns = ( {'key': 'Type',
00395                      'title': _(u'Type'),
00396                      'width': '20',
00397                      'colspan': '2'}
00398                   , {'key': 'getId',
00399                      'title': _(u'Name'),
00400                      'width': '360',
00401                      'colspan': None}
00402                   , {'key': 'modified',
00403                      'title': _(u'Last Modified'),
00404                      'width': '180',
00405                      'colspan': None}
00406                   , {'key': 'position',
00407                      'title': _(u'Position'),
00408                      'width': '80',
00409                      'colspan': None }
00410                   )
00411         for column in columns:
00412             if key == column['key'] and not reverse and key != 'position':
00413                 query = make_query(key=column['key'], reverse=1)
00414             else:
00415                 query = make_query(key=column['key'])
00416             column['url'] = '%s?%s' % (self._getViewURL(), query)
00417         return tuple(columns)

Here is the call graph for this function:

Definition at line 449 of file folder.py.

00449 
00450     def listDeltas(self):
00451         length = self._getBatchObj().sequence_length
00452         deltas = range(1, min(5, length)) + range(5, length, 5)
00453         return tuple(deltas)

Here is the call graph for this function:

Definition at line 119 of file folder.py.

00119 
00120     def listHiddenVarInfos(self):
00121         kw = self._getHiddenVars()
00122         vars = [ {'name': name, 'value': value}
00123                  for name, value in html_marshal(**kw) ]
00124         return tuple(vars)
00125 

Here is the call graph for this function:

Reimplemented from CMFDefault.browser.folder.BatchViewBase.

Definition at line 420 of file folder.py.

00420 
00421     def listItemInfos(self):
00422         b_start = self._getBatchStart()
00423         (key, reverse) = self._getSorting()
00424         batch_obj = self._getBatchObj()
00425         items_manage_allowed = self._checkPermission(ViewManagementScreens)
00426         portal_url = self._getPortalURL()
00427 
00428         items = []
00429         i = 1
00430         for item in batch_obj:
00431             item_icon = item.getIcon(1)
00432             item_id = item.getId()
00433             item_position = (key == 'position') and str(b_start + i) or '...'
00434             i += 1
00435             item_url = item.getActionInfo(('object/folderContents',
00436                                            'object/view'))['url']
00437             items.append({'checkbox': items_manage_allowed and ('cb_%s' %
00438                                                                item_id) or '',
00439                           'icon': item_icon and ('%s/%s' %
00440                                                (portal_url, item_icon)) or '',
00441                           'id': item_id,
00442                           'modified': item.ModificationDate(),
00443                           'position': item_position,
00444                           'title': item.Title(),
00445                           'type': item.Type() or None,
00446                           'url': item_url})
00447         return tuple(items)

Here is the call graph for this function:

Definition at line 211 of file folder.py.

00211 
00212     def navigation_next(self):
00213         batch_obj = self._getBatchObj().next
00214         if batch_obj is None:
00215             return None
00216 
00217         length = len(batch_obj)
00218         url = self._getNavigationURL(batch_obj.first)
00219         if length == 1:
00220             title = _(u'Next item')
00221         else:
00222             title = _(u'Next ${count} items', mapping={'count': length})
00223         return {'title': title, 'url': url}

Here is the call graph for this function:

Definition at line 197 of file folder.py.

00197 
00198     def navigation_previous(self):
00199         batch_obj = self._getBatchObj().previous
00200         if batch_obj is None:
00201             return None
00202 
00203         length = len(batch_obj)
00204         url = self._getNavigationURL(batch_obj.first)
00205         if length == 1:
00206             title = _(u'Previous item')
00207         else:
00208             title = _(u'Previous ${count} items', mapping={'count': length})
00209         return {'title': title, 'url': url}

Here is the call graph for this function:

Paste objects to a folder from the clipboard.

Definition at line 520 of file folder.py.

00520 
00521     def paste_control(self, **kw):
00522         """Paste objects to a folder from the clipboard.
00523         """
00524         try:
00525             result = self.context.manage_pasteObjects(self.request['__cp'])
00526             if len(result) == 1:
00527                 return True, _(u'Item pasted.')
00528             else:
00529                 return True, _(u'Items pasted.')
00530         except CopyError:
00531             return False, _(u'CopyError: Paste failed.')
00532         except zExceptions_Unauthorized:
00533             return False, _(u'Unauthorized: Paste failed.')

Definition at line 609 of file folder.py.

00609 
00610     def set_filter_control(self, **kw):
00611         filter = self.context.encodeFolderFilter(self.request)
00612         self.request.RESPONSE.setCookie('folderfilter', filter, path='/',
00613                                       expires='Wed, 19 Feb 2020 14:28:00 GMT')
00614         return True, _(u'Filter applied.')

def CMFDefault.browser.folder.FolderContentsView.sort_control (   self,
  key = 'position',
  reverse = 0,
  kw 
)
Sort objects in a folder.

Definition at line 543 of file folder.py.

00543 
00544     def sort_control(self, key='position', reverse=0, **kw):
00545         """Sort objects in a folder.
00546         """
00547         self.context.setDefaultSorting(key, reverse)
00548         return True

Definition at line 225 of file folder.py.

00225 
00226     def summary_length(self):
00227         length = self._getBatchObj().sequence_length
00228         return length and thousands_commas(length) or ''

Here is the call graph for this function:

Definition at line 236 of file folder.py.

00236 
00237     def summary_match(self):
00238         return self.request.form.get('SearchableText')
00239 

Definition at line 230 of file folder.py.

00230 
00231     def summary_type(self):
00232         length = self._getBatchObj().sequence_length
00233         return (length == 1) and _(u'item') or _(u'items')

Here is the call graph for this function:

Definition at line 579 of file folder.py.

00579 
00580     def top_control(self, ids, **kw):
00581         subset_ids = [ obj.getId()
00582                        for obj in self.context.listFolderContents() ]
00583         try:
00584             attempt = self.context.moveObjectsToTop(ids,
00585                                                     subset_ids=subset_ids)
00586             if attempt == 1:
00587                 return True, _(u'Item moved to top.')
00588             elif attempt > 1:
00589                 return True, _(u'Items moved to top.')
00590             else:
00591                 return False, _(u'Nothing to change.')
00592         except ValueError:
00593             return False, _(u'ValueError: Move failed.')

def CMFDefault.browser.folder.FolderContentsView.up_control (   self,
  ids,
  delta,
  kw 
)

Definition at line 549 of file folder.py.

00549 
00550     def up_control(self, ids, delta, **kw):
00551         subset_ids = [ obj.getId()
00552                        for obj in self.context.listFolderContents() ]
00553         try:
00554             attempt = self.context.moveObjectsUp(ids, delta,
00555                                                  subset_ids=subset_ids)
00556             if attempt == 1:
00557                 return True, _(u'Item moved up.')
00558             elif attempt > 1:
00559                 return True, _(u'Items moved up.')
00560             else:
00561                 return False, _(u'Nothing to change.')
00562         except ValueError:
00563             return False, _(u'ValueError: Move failed.')

Definition at line 373 of file folder.py.

00373 
00374     def up_info(self):
00375         up_obj = self.context.aq_inner.aq_parent
00376         mtool = self._getTool('portal_membership')
00377         allowed = mtool.checkPermission(ListFolderContents, up_obj)
00378         if allowed:
00379             if IDynamicType.providedBy(up_obj):
00380                 up_url = up_obj.getActionInfo('object/folderContents')['url']
00381                 return {'icon': '%s/UpFolder_icon.gif' % self._getPortalURL(),
00382                         'id': up_obj.getId(),
00383                         'url': up_url}
00384             else:
00385                 return {'icon': '',
00386                         'id': 'Root',
00387                         'url': ''}
00388         else:
00389             return {}

Here is the call graph for this function:

Definition at line 485 of file folder.py.

00485 
00486     def validateClipboardData(self, **kw):
00487         if self.context.cb_dataValid():
00488             return True
00489         else:
00490             return False, _(u'Please copy or cut one or more items to paste '
00491                             u'first.')

def CMFDefault.browser.folder.FolderContentsView.validateItemIds (   self,
  ids = (),
  kw 
)

Definition at line 479 of file folder.py.

00479 
00480     def validateItemIds(self, ids=(), **kw):
00481         if ids:
00482             return True
00483         else:
00484             return False, _(u'Please select one or more items first.')


Member Data Documentation

Definition at line 267 of file folder.py.


The documentation for this class was generated from the following file: