Back to index

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

List of all members.

Public Member Functions

def index_html
def __call__
def manage_addPloneFolder
def manage_delObjects
def __browser_default__
def contentValues
def listFolderContents
def folderlistingFolderContents
def invokeFactory
def moveObject
def moveObjectsByDelta
def getCMFObjectsSubsetIds
def getObjectPosition
def moveObjectsUp
def moveObjectsDown
def moveObjectsToTop
def moveObjectsToBottom
def moveObjectToPosition
def orderObjects
def manage_renameObject

Public Attributes

 id
 title

Static Public Attributes

string meta_type = 'Plone Folder'
tuple security = ClassSecurityInfo()
 manage_renameObject = OrderedContainer.manage_renameObject
 manage_options = Folder.manage_options+\
 view = __call__
tuple index_html = ComputedAttribute(index_html, 1)
 manage_addFolder = manage_addPloneFolder

Static Private Attributes

 __implements__ = BasePloneFolder.__implements__+\

Detailed Description

A Plone Folder.

Definition at line 355 of file PloneFolder.py.


Member Function Documentation

def CMFPlone.PloneFolder.BasePloneFolder.__browser_default__ (   self,
  request 
) [inherited]
Set default so we can return whatever we want instead
of index_html.

Definition at line 297 of file PloneFolder.py.

00297 
00298     def __browser_default__(self, request):
00299         """Set default so we can return whatever we want instead
00300         of index_html."""
00301         return getToolByName(self, 'plone_utils').browserDefault(self)

Here is the call graph for this function:

Invokes the default view.

Definition at line 234 of file PloneFolder.py.

00234 
00235     def __call__(self):
00236         """Invokes the default view."""
00237         ti = self.getTypeInfo()
00238         method_id = ti and ti.queryMethodId('(Default)', context=self)
00239         if method_id:
00240             method = getattr(self, method_id)
00241             # XXX view is not defined!
00242             if getattr(aq_base(view), 'isDocTemp', 0):
00243                 return method(self, self.REQUEST, self.REQUEST['RESPONSE'])
00244             else:
00245                 return method()
00246         else:
00247             raise NotFound( 'Cannot find default view for "%s"' %
00248                             '/'.join( self.getPhysicalPath() ) )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.BasePloneFolder.contentValues (   self,
  filter = None,
  sort_on = None,
  reverse = 0 
) [inherited]
Able to sort on field.

Definition at line 303 of file PloneFolder.py.

00303 
00304     def contentValues(self, filter=None, sort_on=None, reverse=0):
00305         """Able to sort on field."""
00306         values = PortalFolderBase.contentValues(self, filter=filter)
00307         if sort_on is not None:
00308             values.sort(lambda x, y,
00309                         sort_on=sort_on: safe_cmp(getattr(x,sort_on),
00310                                                   getattr(y,sort_on)))
00311         if reverse:
00312             values.reverse()
00313 
00314         return values

Here is the call graph for this function:

def CMFPlone.PloneFolder.BasePloneFolder.folderlistingFolderContents (   self,
  contentFilter = None,
  suppressHiddenFiles = 0 
) [inherited]
Calls listFolderContents in protected only by ACI so that
folder_listing can work without the List folder contents permission,
as in CMFDefault.

Definition at line 330 of file PloneFolder.py.

00330 
00331                                     suppressHiddenFiles=0):
00332         """Calls listFolderContents in protected only by ACI so that
00333         folder_listing can work without the List folder contents permission,
00334         as in CMFDefault.
00335         """
00336         return self.listFolderContents(contentFilter, suppressHiddenFiles)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.getCMFObjectsSubsetIds (   self,
  objs 
) [inherited]
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:

def CMFPlone.PloneFolder.OrderedContainer.getObjectPosition (   self,
  id 
) [inherited]

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:

Acquire if not present.

Definition at line 252 of file PloneFolder.py.

00252 
00253     def index_html(self):
00254         """Acquire if not present."""
00255         request = getattr(self, 'REQUEST', None)
00256         if request and request.has_key('REQUEST_METHOD'):
00257             if request.maybe_webdav_client:
00258                 method = request['REQUEST_METHOD']
00259                 if method in ('PUT',):
00260                     # Very likely a WebDAV client trying to create something
00261                     return ReplaceableWrapper(NullResource(self, 'index_html'))
00262                 elif method in ('GET', 'HEAD', 'POST'):
00263                     # Do nothing, let it go and acquire.
00264                     pass
00265                 else:
00266                     raise AttributeError, 'index_html'
00267         # Acquire from parent
00268         _target = aq_parent(aq_inner(self)).aq_acquire('index_html')
00269         return ReplaceableWrapper(aq_base(_target).__of__(self))

def CMFPlone.PloneFolder.BasePloneFolder.invokeFactory (   self,
  type_name,
  id,
  RESPONSE = None,
  args,
  kw 
) [inherited]
Invokes the portal_types tool.

Definition at line 340 of file PloneFolder.py.

00340 
00341     def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
00342         """Invokes the portal_types tool."""
00343         pt = getToolByName(self, 'portal_types')
00344         myType = pt.getTypeInfo(self)
00345         if myType is not None:
00346             if not myType.allowType(type_name):
00347                 raise ValueError, 'Disallowed subobject type: %s' % type_name
00348         args = (type_name, self, id, RESPONSE) + args
00349         new_id = pt.constructContent(*args, **kw)
00350         if new_id is None or new_id == '':
00351             new_id = id
00352         return new_id
00353 
00354 InitializeClass(BasePloneFolder)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.BasePloneFolder.listFolderContents (   self,
  contentFilter = None,
  suppressHiddenFiles = 0 
) [inherited]
Optionally you can suppress "hidden" files, or files that
begin with .

Definition at line 317 of file PloneFolder.py.

00317 
00318                            suppressHiddenFiles=0):
00319         """Optionally you can suppress "hidden" files, or files that
00320         begin with .
00321         """
00322         contents = PortalFolderBase.listFolderContents(self,
00323                                                   contentFilter=contentFilter)
00324         if suppressHiddenFiles:
00325             contents = [obj for obj in contents if obj.getId()[:1]!='.']
00326         return contents

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.BasePloneFolder.manage_addPloneFolder (   self,
  id,
  title = '',
  REQUEST = None 
) [inherited]
Adds a new PloneFolder.

Definition at line 273 of file PloneFolder.py.

00273 
00274     def manage_addPloneFolder(self, id, title='', REQUEST=None):
00275         """Adds a new PloneFolder."""
00276         ob = PloneFolder(id, title)
00277         self._setObject(id, ob)
00278         if REQUEST is not None:
00279             # TODO HARDCODED FIXME!
00280             return self.folder_contents(self, REQUEST)

Here is the call graph for this function:

def CMFPlone.PloneFolder.BasePloneFolder.manage_delObjects (   self,
  ids = [],
  REQUEST = None 
) [inherited]
We need to enforce security.

Definition at line 285 of file PloneFolder.py.

00285 
00286     def manage_delObjects(self, ids=[], REQUEST=None):
00287         """We need to enforce security."""
00288         mt = getToolByName(self, 'portal_membership')
00289         if type(ids) is StringType:
00290             ids = [ids]
00291         for id in ids:
00292             item = self._getOb(id)
00293             if not mt.checkPermission(Permissions.delete_objects, item):
00294                 raise Unauthorized, (
00295                     "Do not have permissions to remove this object")
00296         return PortalFolderBase.manage_delObjects(self, ids, REQUEST=REQUEST)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneFolder.OrderedContainer.manage_renameObject (   self,
  id,
  new_id,
  REQUEST = None 
) [inherited]
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 
) [inherited]

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

Reimplemented from CMFPlone.PloneFolder.OrderedContainer.

Definition at line 359 of file PloneFolder.py.

Definition at line 231 of file PloneFolder.py.

tuple CMFPlone.PloneFolder.BasePloneFolder.index_html = ComputedAttribute(index_html, 1) [static, inherited]

Definition at line 270 of file PloneFolder.py.

Definition at line 281 of file PloneFolder.py.

CMFPlone.PloneFolder.BasePloneFolder.manage_options = Folder.manage_options+\ [static, inherited]

Definition at line 216 of file PloneFolder.py.

Reimplemented from CMFPlone.PloneFolder.BasePloneFolder.

Definition at line 362 of file PloneFolder.py.

string CMFPlone.PloneFolder.PloneFolder.meta_type = 'Plone Folder' [static]

Definition at line 357 of file PloneFolder.py.

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

Reimplemented from CMFPlone.PloneFolder.OrderedContainer.

Definition at line 358 of file PloneFolder.py.

Definition at line 232 of file PloneFolder.py.

Definition at line 250 of file PloneFolder.py.


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