Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes
Archetypes.OrderedBaseFolder.OrderedContainer Class Reference
Inheritance diagram for Archetypes.OrderedBaseFolder.OrderedContainer:
Inheritance 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

Definition at line 33 of file OrderedBaseFolder.py.


Member Function Documentation

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

Definition at line 110 of file OrderedBaseFolder.py.

00110 
00111     def getCMFObjectsSubsetIds(self, objs):
00112         """Get the ids of only cmf objects (used for moveObjectsByDelta)
00113         """
00114         ttool = getToolByName(self, 'portal_types')
00115         cmf_meta_types = [ti.Metatype() for ti in ttool.listTypeInfo()]
00116         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 118 of file OrderedBaseFolder.py.

00118 
00119     def getObjectPosition(self, id):
00120 
00121         objs = list(self._objects)
00122         om = [objs.index(om) for om in objs if om['id']==id ]
00123 
00124         if om: # only 1 in list if any
00125             return om[0]
00126 
00127         raise NotFound, 'Object %s was not found' % str(id)

Here is the caller graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.manage_renameObject (   self,
  id,
  new_id,
  REQUEST = None 
)

Reimplemented in Archetypes.OrderedBaseFolder.OrderedBaseFolder.

Definition at line 175 of file OrderedBaseFolder.py.

00175 
00176     def manage_renameObject(self, id, new_id, REQUEST=None):
00177         " "
00178         objidx = self.getObjectPosition(id)
00179         method = OrderedContainer.inheritedAttribute('manage_renameObject')
00180         result = method(self, id, new_id, REQUEST)
00181         self.moveObject(new_id, objidx)
00182 
00183         return result
00184 
00185 InitializeClass(OrderedContainer)
00186 

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObject (   self,
  id,
  position 
)

Definition at line 41 of file OrderedBaseFolder.py.

00041 
00042     def moveObject(self, id, position):
00043         obj_idx  = self.getObjectPosition(id)
00044         if obj_idx == position:
00045             return None
00046         elif position < 0:
00047             position = 0
00048 
00049         metadata = list(self._objects)
00050         obj_meta = metadata.pop(obj_idx)
00051         metadata.insert(position, obj_meta)
00052         self._objects = tuple(metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObjectsByDelta (   self,
  ids,
  delta,
  subset_ids = None 
)
Move specified sub-objects by delta.

Definition at line 58 of file OrderedBaseFolder.py.

00058 
00059     def moveObjectsByDelta(self, ids, delta, subset_ids=None):
00060         """ Move specified sub-objects by delta.
00061         """
00062         if type(ids) is StringType:
00063             ids = (ids,)
00064         min_position = 0
00065         objects = list(self._objects)
00066         if subset_ids == None:
00067             # OLD: subset_ids = [ obj['id'] for obj in objects ]
00068             subset_ids = self.getCMFObjectsSubsetIds(objects)
00069         else:
00070             subset_ids = list(subset_ids)
00071         # unify moving direction
00072         if delta > 0:
00073             ids = list(ids)
00074             ids.reverse()
00075             subset_ids.reverse()
00076         counter = 0
00077 
00078         for id in ids:
00079             try:
00080                 old_position = subset_ids.index(id)
00081             except ValueError:
00082                 continue
00083             new_position = max( old_position - abs(delta), min_position )
00084             if new_position == min_position:
00085                 min_position += 1
00086             if not old_position == new_position:
00087                 subset_ids.remove(id)
00088                 subset_ids.insert(new_position, id)
00089                 counter += 1
00090 
00091         if counter > 0:
00092             if delta > 0:
00093                 subset_ids.reverse()
00094             obj_dict = {}
00095             for obj in objects:
00096                 obj_dict[ obj['id'] ] = obj
00097             pos = 0
00098             for i in range( len(objects) ):
00099                 if objects[i]['id'] in subset_ids:
00100                     try:
00101                         objects[i] = obj_dict[ subset_ids[pos] ]
00102                         pos += 1
00103                     except KeyError:
00104                         raise ValueError('The object with the id "%s" does '
00105                                          'not exist.' % subset_ids[pos])
00106             self._objects = tuple(objects)
00107 
00108         return counter

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObjectsDown (   self,
  ids,
  delta = 1,
  RESPONSE = None 
)
move an object down 

Definition at line 136 of file OrderedBaseFolder.py.

00136 
00137     def moveObjectsDown(self, ids, delta=1, RESPONSE=None):
00138         """ move an object down """
00139         self.moveObjectsByDelta(ids, delta)
00140         if RESPONSE is not None:
00141             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObjectsToBottom (   self,
  ids,
  RESPONSE = None 
)
move an object to the bottom 

Definition at line 150 of file OrderedBaseFolder.py.

00150 
00151     def moveObjectsToBottom(self, ids, RESPONSE=None):
00152         """ move an object to the bottom """
00153         self.moveObjectsByDelta( ids, len(self._objects) )
00154         if RESPONSE is not None:
00155             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObjectsToTop (   self,
  ids,
  RESPONSE = None 
)
move an object to the top 

Definition at line 143 of file OrderedBaseFolder.py.

00143 
00144     def moveObjectsToTop(self, ids, RESPONSE=None):
00145         """ move an object to the top """
00146         self.moveObjectsByDelta( ids, -len(self._objects) )
00147         if RESPONSE is not None:
00148             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

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

Definition at line 129 of file OrderedBaseFolder.py.

00129 
00130     def moveObjectsUp(self, ids, delta=1, RESPONSE=None):
00131         """ Move an object up """
00132         self.moveObjectsByDelta(ids, -delta)
00133         if RESPONSE is not None:
00134             RESPONSE.redirect('manage_workspace')

Here is the call graph for this function:

Move specified object to absolute position.

Definition at line 157 of file OrderedBaseFolder.py.

00157 
00158     def moveObjectToPosition(self, id, position):
00159         """ Move specified object to absolute position.
00160         """
00161         delta = position - self.getObjectPosition(id)
00162         return self.moveObjectsByDelta(id, delta)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 164 of file OrderedBaseFolder.py.

00164 
00165     def orderObjects(self, key, reverse=None):
00166         """ Order sub-objects by key and direction.
00167         """
00168         ids = [ id for id, obj in sequence.sort( self.objectItems(),
00169                                         ( (key, 'cmp', 'asc'), ) ) ]
00170         if reverse:
00171             ids.reverse()
00172         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 Archetypes.OrderedBaseFolder.OrderedContainer.__implements__ = (IOrderedContainer, IZopeOrderedContainer) [static, private]

Reimplemented in Archetypes.OrderedBaseFolder.OrderedBaseFolder.

Definition at line 35 of file OrderedBaseFolder.py.

Definition at line 51 of file OrderedBaseFolder.py.

tuple Archetypes.OrderedBaseFolder.OrderedContainer.security = ClassSecurityInfo() [static]

Reimplemented in Archetypes.OrderedBaseFolder.OrderedBaseFolder.

Definition at line 38 of file OrderedBaseFolder.py.


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