Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes
CMFPlone.PloneFolder.OrderedContainer Class Reference
Inheritance diagram for CMFPlone.PloneFolder.OrderedContainer:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.PloneFolder.OrderedContainer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def moveObject
def moveObjectsByDelta
def getCMFObjectsSubsetIds
def getObjectPosition
def moveObjectsUp
def moveObjectsDown
def moveObjectsToTop
def moveObjectsToBottom
def moveObjectToPosition
def orderObjects
def manage_renameObject

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Attributes

 _objects

Static Private Attributes

tuple __implements__ = (IOrderedContainer, IZopeOrderedContainer)

Detailed Description

Folder with subobject ordering support.

Definition at line 51 of file PloneFolder.py.


Member Function Documentation

Get the ids of only cmf objects (used for moveObjectsByDelta).

Definition at line 130 of file PloneFolder.py.

00130 
00131     def getCMFObjectsSubsetIds(self, objs):
00132         """Get the ids of only cmf objects (used for moveObjectsByDelta)."""
00133         ttool = getToolByName(self, 'portal_types')
00134         cmf_meta_types = [ti.Metatype() for ti in ttool.listTypeInfo()]
00135         return [obj['id'] for obj in objs if obj['meta_type'] in cmf_meta_types]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 137 of file PloneFolder.py.

00137 
00138     def getObjectPosition(self, id):
00139 
00140         objs = list(self._objects)
00141         om = [objs.index(om) for om in objs if om['id']==id]
00142 
00143         if om: # only 1 in list if any
00144             return om[0]
00145 
00146         raise NotFound, 'Object %s was not found' % str(id)

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.manage_renameObject (   self,
  id,
  new_id,
  REQUEST = None 
)
Rename a particular sub-object.

Definition at line 193 of file PloneFolder.py.

00193 
00194     def manage_renameObject(self, id, new_id, REQUEST=None):
00195         """Rename a particular sub-object."""
00196         objidx = self.getObjectPosition(id)
00197         method = OrderedContainer.inheritedAttribute('manage_renameObject')
00198         result = method(self, id, new_id, REQUEST)
00199         self.moveObject(new_id, objidx)
00200         putils = getToolByName(self, 'plone_utils')
00201         putils.reindexOnReorder(self)
00202         return result
00203 
00204 InitializeClass(OrderedContainer)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObject (   self,
  id,
  position 
)

Definition at line 59 of file PloneFolder.py.

00059 
00060     def moveObject(self, id, position):
00061         obj_idx  = self.getObjectPosition(id)
00062         if obj_idx == position:
00063             return None
00064         elif position < 0:
00065             position = 0
00066 
00067         metadata = list(self._objects)
00068         obj_meta = metadata.pop(obj_idx)
00069         metadata.insert(position, obj_meta)
00070         self._objects = tuple(metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectsByDelta (   self,
  ids,
  delta,
  subset_ids = None,
  suppress_events = False 
)
Move specified sub-objects by delta.

Definition at line 77 of file PloneFolder.py.

00077 
00078                            suppress_events=False):
00079         """Move specified sub-objects by delta."""
00080         if type(ids) is StringType:
00081             ids = (ids,)
00082         min_position = 0
00083         objects = list(self._objects)
00084         if subset_ids == None:
00085             subset_ids = self.getCMFObjectsSubsetIds(objects)
00086         else:
00087             subset_ids = list(subset_ids)
00088         # unify moving direction
00089         if delta > 0:
00090             ids = list(ids)
00091             ids.reverse()
00092             subset_ids.reverse()
00093         counter = 0
00094 
00095         for id in ids:
00096             try:
00097                 old_position = subset_ids.index(id)
00098             except ValueError:
00099                 continue
00100             new_position = max(old_position - abs(delta), min_position)
00101             if new_position == min_position:
00102                 min_position += 1
00103             if not old_position == new_position:
00104                 subset_ids.remove(id)
00105                 subset_ids.insert(new_position, id)
00106                 counter += 1
00107 
00108         if counter > 0:
00109             if delta > 0:
00110                 subset_ids.reverse()
00111             obj_dict = {}
00112             for obj in objects:
00113                 obj_dict[obj['id']] = obj
00114             pos = 0
00115             for i in range(len(objects)):
00116                 if objects[i]['id'] in subset_ids:
00117                     try:
00118                         objects[i] = obj_dict[subset_ids[pos]]
00119                         pos += 1
00120                     except KeyError:
00121                         raise ValueError('The object with the id "%s" does '
00122                                          'not exist.' % subset_ids[pos])
00123             self._objects = tuple(objects)
00124 
00125         if not suppress_events:
00126             notifyContainerModified(self)
00127 
00128         return counter

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectsDown (   self,
  ids,
  delta = 1,
  RESPONSE = None 
)
Move an object down.

Definition at line 155 of file PloneFolder.py.

00155 
00156     def moveObjectsDown(self, ids, delta=1, RESPONSE=None):
00157         """Move an object down."""
00158         self.moveObjectsByDelta(ids, delta)
00159         if RESPONSE is not None:
00160             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectsToBottom (   self,
  ids,
  RESPONSE = None 
)
Move an object to the bottom.

Definition at line 169 of file PloneFolder.py.

00169 
00170     def moveObjectsToBottom(self, ids, RESPONSE=None):
00171         """Move an object to the bottom."""
00172         self.moveObjectsByDelta(ids, len(self._objects))
00173         if RESPONSE is not None:
00174             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectsToTop (   self,
  ids,
  RESPONSE = None 
)
Move an object to the top.

Definition at line 162 of file PloneFolder.py.

00162 
00163     def moveObjectsToTop(self, ids, RESPONSE=None):
00164         """Move an object to the top."""
00165         self.moveObjectsByDelta(ids, - len(self._objects))
00166         if RESPONSE is not None:
00167             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectsUp (   self,
  ids,
  delta = 1,
  RESPONSE = None 
)
Move an object up.

Definition at line 148 of file PloneFolder.py.

00148 
00149     def moveObjectsUp(self, ids, delta=1, RESPONSE=None):
00150         """Move an object up."""
00151         self.moveObjectsByDelta(ids, -delta)
00152         if RESPONSE is not None:
00153             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.moveObjectToPosition (   self,
  id,
  position,
  suppress_events = False 
)
Move specified object to absolute position.

Definition at line 176 of file PloneFolder.py.

00176 
00177     def moveObjectToPosition(self, id, position, suppress_events=False):
00178         """Move specified object to absolute position."""
00179         delta = position - self.getObjectPosition(id)
00180         return self.moveObjectsByDelta(id, delta,
00181                                        suppress_events=suppress_events)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.orderObjects (   self,
  key,
  reverse = None 
)
Order sub-objects by key and direction.

Definition at line 183 of file PloneFolder.py.

00183 
00184     def orderObjects(self, key, reverse=None):
00185         """Order sub-objects by key and direction."""
00186         ids = [id for id, obj in sort(self.objectItems(),
00187                                       ((key, 'cmp', 'asc'),))]
00188         if reverse:
00189             ids.reverse()
00190         return self.moveObjectsByDelta(ids, -len(self._objects))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple CMFPlone.PloneFolder.OrderedContainer.__implements__ = (IOrderedContainer, IZopeOrderedContainer) [static, private]

Reimplemented in CMFPlone.PloneFolder.PloneFolder.

Definition at line 54 of file PloneFolder.py.

Definition at line 69 of file PloneFolder.py.

tuple CMFPlone.PloneFolder.OrderedContainer.security = ClassSecurityInfo() [static]

Reimplemented in CMFPlone.PloneFolder.PloneFolder.

Definition at line 56 of file PloneFolder.py.


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