Back to index

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

List of all members.

Public Member Functions

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

Static Public Attributes

tuple security = ClassSecurityInfo()

Static Private Attributes

 __implements__ = OrderedContainer.__implements__,\

Detailed Description

An ordered base folder implementation 

Definition at line 187 of file OrderedBaseFolder.py.


Constructor & Destructor Documentation

def Archetypes.OrderedBaseFolder.OrderedBaseFolder.__init__ (   self,
  oid,
  kwargs 
)

Definition at line 195 of file OrderedBaseFolder.py.

00195 
00196     def __init__(self, oid, **kwargs):
00197         #call skinned first cause baseobject will set new defaults on
00198         #those attributes anyway
00199         BaseFolder.__init__(self, oid, **kwargs)
00200         ExtensibleMetadata.__init__(self)

Here is the caller graph for this function:


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.OrderedBaseFolder.manage_renameObject (   self,
  id,
  new_id,
  REQUEST = None 
)
rename the object 

Reimplemented from Archetypes.OrderedBaseFolder.OrderedContainer.

Definition at line 202 of file OrderedBaseFolder.py.

00202 
00203     def manage_renameObject(self, id, new_id, REQUEST=None):
00204         """ rename the object """
00205         objidx = self.getObjectPosition(id)
00206         result = BaseFolder.manage_renameObject(self, id, new_id, REQUEST)
00207         self.moveObject(new_id, objidx)
00208 
00209         return result
00210 
00211 InitializeClass(OrderedBaseFolder)

Here is the call graph for this function:

Here is the caller graph for this function:

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

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 
) [inherited]
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 
) [inherited]
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 
) [inherited]
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 
) [inherited]
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 
) [inherited]
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:

def Archetypes.OrderedBaseFolder.OrderedContainer.moveObjectToPosition (   self,
  id,
  position 
) [inherited]
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 
) [inherited]
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

Reimplemented from Archetypes.OrderedBaseFolder.OrderedContainer.

Definition at line 190 of file OrderedBaseFolder.py.

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

Reimplemented from Archetypes.OrderedBaseFolder.OrderedContainer.

Definition at line 193 of file OrderedBaseFolder.py.


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