Back to index

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

List of all members.

Public Member Functions

def __init__
def Title
def Description
def Type
def setTitle
def setDescription
def edit
def allowedContentTypes
def contentItems
def contentIds
def contentValues
def listFolderContents
def listDAVObjects
def encodeFolderFilter
def decodeFolderFilter
def content_type
def indexObject
def unindexObject
def reindexObject
def reindexObjectSecurity
def PUT_factory
def invokeFactory
def checkIdAvailable
def MKCOL_handler
def manage_addFolder

Public Attributes

 id
 title
 description

Static Public Attributes

tuple security = ClassSecurityInfo()
string description = ''
tuple manage_options

Private Member Functions

def _filteredItems
def _checkId
def _verifyObjectPaste

Static Private Attributes

tuple __implements__

Detailed Description

Base class for portal folder.

Definition at line 52 of file PortalFolder.py.


Constructor & Destructor Documentation

def CMFCore.PortalFolder.PortalFolderBase.__init__ (   self,
  id,
  title = '',
  description = '' 
)

Definition at line 72 of file PortalFolder.py.

00072 
00073     def __init__(self, id, title='', description=''):
00074         self.id = id
00075         self.title = title
00076         self.description = description


Member Function Documentation

def CMFCore.PortalFolder.PortalFolderBase._checkId (   self,
  id,
  allow_dup = 0 
) [private]

Definition at line 332 of file PortalFolder.py.

00332 
00333     def _checkId(self, id, allow_dup=0):
00334         PortalFolderBase.inheritedAttribute('_checkId')(self, id, allow_dup)
00335 
00336         if allow_dup:
00337             return
00338 
00339         # FIXME: needed to allow index_html for join code
00340         if id == 'index_html':
00341             return
00342 
00343         # Another exception: Must allow "syndication_information" to enable
00344         # Syndication...
00345         if id == 'syndication_information':
00346             return
00347 
00348         # IDs starting with '@@' are reserved for views.
00349         if id[:2] == '@@':
00350             raise BadRequest('The id "%s" is invalid because it begins with '
00351                              '"@@".' % id)
00352 
00353         # This code prevents people other than the portal manager from
00354         # overriding skinned names and tools.
00355         if not getSecurityManager().checkPermission(ManagePortal, self):
00356             ob = aq_inner(self)
00357             while ob is not None:
00358                 if ISiteRoot.providedBy(ob):
00359                     break
00360                 # BBB
00361                 if getattr(ob, '_isPortalRoot', False):
00362                     warn("The '_isPortalRoot' marker attribute for site "
00363                          "roots is deprecated and will be removed in "
00364                          "CMF 2.3;  please mark the root object with "
00365                          "'ISiteRoot' instead.",
00366                          DeprecationWarning, stacklevel=2)
00367                     break
00368                 ob = aq_parent(ob)
00369 
00370             if ob is not None:
00371                 # If the portal root has a non-contentish object by this name,
00372                 # don't allow an override.
00373                 if (hasattr(ob, id) and
00374                     id not in ob.contentIds() and
00375                     # Allow root doted prefixed object name overrides
00376                     not id.startswith('.')):
00377                     raise BadRequest('The id "%s" is reserved.' % id)
00378             # Don't allow ids used by Method Aliases.
00379             ti = self.getTypeInfo()
00380             if ti and ti.queryMethodID(id, context=self):
00381                 raise BadRequest('The id "%s" is reserved.' % id)
00382         # Otherwise we're ok.

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase._filteredItems (   self,
  ids,
  filt 
) [private]
    Apply filter, a mapping, to child objects indicated by 'ids',
    returning a sequence of ( id, obj ) tuples.

Definition at line 144 of file PortalFolder.py.

00144 
00145     def _filteredItems( self, ids, filt ):
00146         """
00147             Apply filter, a mapping, to child objects indicated by 'ids',
00148             returning a sequence of ( id, obj ) tuples.
00149         """
00150         # Restrict allowed content types
00151         if filt is None:
00152             filt = {}
00153         else:
00154             # We'll modify it, work on a copy.
00155             filt = filt.copy()
00156         pt = filt.get('portal_type', [])
00157         if isinstance(pt, basestring):
00158             pt = [pt]
00159         types_tool = getToolByName(self, 'portal_types')
00160         allowed_types = types_tool.listContentTypes()
00161         if not pt:
00162             pt = allowed_types
00163         else:
00164             pt = [t for t in pt if t in allowed_types]
00165         if not pt:
00166             # After filtering, no types remain, so nothing should be
00167             # returned.
00168             return []
00169         filt['portal_type'] = pt
00170 
00171         query = ContentFilter(**filt)
00172         result = []
00173         append = result.append
00174         get = self._getOb
00175         for id in ids:
00176             obj = get( id )
00177             if query(obj):
00178                 append( (id, obj) )
00179         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase._verifyObjectPaste (   self,
  object,
  validate_src = 1 
) [private]

Definition at line 383 of file PortalFolder.py.

00383 
00384     def _verifyObjectPaste(self, object, validate_src=1):
00385         # This assists the version in OFS.CopySupport.
00386         # It enables the clipboard to function correctly
00387         # with objects created by a multi-factory.
00388         mt = getattr(object, '__factory_meta_type__', None)
00389         meta_types = getattr(self, 'all_meta_types', None)
00390 
00391         if mt is not None and meta_types is not None:
00392             method_name = None
00393             mt_permission = None
00394 
00395             if callable(meta_types):
00396                 meta_types = meta_types()
00397 
00398             for d in meta_types:
00399                 if d['name'] == mt:
00400                     method_name = d['action']
00401                     mt_permission = d.get('permission')
00402                     break
00403 
00404             if mt_permission is not None:
00405                 sm = getSecurityManager()
00406 
00407                 if sm.checkPermission(mt_permission, self):
00408                     if validate_src:
00409                         # Ensure the user is allowed to access the object on
00410                         # the clipboard.
00411                         parent = aq_parent(aq_inner(object))
00412 
00413                         if not sm.validate(None, parent, None, object):
00414                             raise AccessControl_Unauthorized(object.getId())
00415 
00416                         if validate_src == 2: # moving
00417                             if not sm.checkPermission(DeleteObjects, parent):
00418                                 raise AccessControl_Unauthorized('Delete not '
00419                                                                  'allowed.')
00420                 else:
00421                     raise AccessControl_Unauthorized('You do not possess the '
00422                             '%r permission in the context of the container '
00423                             'into which you are pasting, thus you are not '
00424                             'able to perform this operation.' % mt_permission)
00425             else:
00426                 raise AccessControl_Unauthorized('The object %r does not '
00427                         'support this operation.' % object.getId())
00428         else:
00429             # Call OFS' _verifyObjectPaste if necessary
00430             PortalFolderBase.inheritedAttribute(
00431                 '_verifyObjectPaste')(self, object, validate_src)
00432 
00433         # Finally, check allowed content types
00434         if hasattr(aq_base(object), 'getPortalTypeName'):
00435 
00436             type_name = object.getPortalTypeName()
00437 
00438             if type_name is not None:
00439 
00440                 pt = getToolByName(self, 'portal_types')
00441                 myType = pt.getTypeInfo(self)
00442 
00443                 if myType is not None and not myType.allowType(type_name):
00444                     raise ValueError('Disallowed subobject type: %s'
00445                                         % type_name)

Here is the call graph for this function:

    List type info objects for types which can be added in
    this folder.

Definition at line 124 of file PortalFolder.py.

00124 
00125     def allowedContentTypes( self ):
00126         """
00127             List type info objects for types which can be added in
00128             this folder.
00129         """
00130         result = []
00131         portal_types = getToolByName(self, 'portal_types')
00132         myType = portal_types.getTypeInfo(self)
00133 
00134         if myType is not None:
00135             for contentType in portal_types.listTypeInfo(self):
00136                 if myType.allowType( contentType.getId() ):
00137                     result.append( contentType )
00138         else:
00139             result = portal_types.listTypeInfo()
00140 
00141         return filter( lambda typ, container=self:
00142                           typ.isConstructionAllowed( container )
00143                      , result )

Here is the call graph for this function:

Definition at line 318 of file PortalFolder.py.

00318 
00319     def checkIdAvailable(self, id):
00320         try:
00321             self._checkId(id)
00322         except BadRequest:
00323             return False
00324         else:
00325             return True

Here is the call graph for this function:

    WebDAV needs this to do the Right Thing (TM).

Definition at line 260 of file PortalFolder.py.

00260 
00261     def content_type( self ):
00262         """
00263             WebDAV needs this to do the Right Thing (TM).
00264         """
00265         return None

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.contentIds (   self,
  filter = None 
)

Definition at line 192 of file PortalFolder.py.

00192 
00193     def contentIds(self, filter=None):
00194         # List IDs of contentish and folderish sub-objects.
00195         # (method is without docstring to disable publishing)
00196         #
00197         return [ item[0] for item in self.contentItems(filter) ]

Here is the call graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.contentItems (   self,
  filter = None 
)

Definition at line 184 of file PortalFolder.py.

00184 
00185     def contentItems(self, filter=None):
00186         # List contentish and folderish sub-objects and their IDs.
00187         # (method is without docstring to disable publishing)
00188         #
00189         ids = self.objectIds()
00190         return self._filteredItems(ids, filter)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.contentValues (   self,
  filter = None 
)

Definition at line 199 of file PortalFolder.py.

00199 
00200     def contentValues(self, filter=None):
00201         # List contentish and folderish sub-objects.
00202         # (method is without docstring to disable publishing)
00203         #
00204         return [ item[1] for item in self.contentItems(filter) ]

Here is the call graph for this function:

    Parse cookie string for using variables in dtml.

Definition at line 251 of file PortalFolder.py.

00251 
00252     def decodeFolderFilter(self, encoded):
00253         """
00254             Parse cookie string for using variables in dtml.
00255         """
00256         filter = {}
00257         if encoded:
00258             filter.update(marshal.loads(base64.decodestring(encoded)))
00259         return filter

Dublin Core Description element - resource summary.

Definition at line 87 of file PortalFolder.py.

00087 
00088     def Description(self):
00089         """ Dublin Core Description element - resource summary.
00090         """
00091         return self.description

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.edit (   self,
  title = '',
  description = '' 
)
Edit the folder title (and possibly other attributes later)

Definition at line 115 of file PortalFolder.py.

00115 
00116     def edit(self, title='', description=''):
00117         """
00118         Edit the folder title (and possibly other attributes later)
00119         """
00120         self.setTitle( title )
00121         self.setDescription( description )
00122         self.reindexObject()

Here is the call graph for this function:

Here is the caller graph for this function:

    Parse cookie string for using variables in dtml.

Definition at line 238 of file PortalFolder.py.

00238 
00239     def encodeFolderFilter(self, REQUEST):
00240         """
00241             Parse cookie string for using variables in dtml.
00242         """
00243         filter = {}
00244         for key, value in REQUEST.items():
00245             if key[:10] == 'filter_by_':
00246                 filter[key[10:]] = value
00247         encoded = base64.encodestring( marshal.dumps(filter) ).strip()
00248         encoded = ''.join( encoded.split('\n') )
00249         return encoded

Here is the call graph for this function:

Definition at line 269 of file PortalFolder.py.

00269 
00270     def indexObject(self):
00271         pass

def CMFCore.PortalFolder.PortalFolderBase.invokeFactory (   self,
  type_name,
  id,
  RESPONSE = None,
  args,
  kw 
)
Invokes the portal_types tool.

Definition at line 305 of file PortalFolder.py.

00305 
00306     def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
00307         """ Invokes the portal_types tool.
00308         """
00309         pt = getToolByName(self, 'portal_types')
00310         myType = pt.getTypeInfo(self)
00311 
00312         if myType is not None:
00313             if not myType.allowType( type_name ):
00314                 raise ValueError('Disallowed subobject type: %s' % type_name)
00315 
00316         return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file PortalFolder.py.

00225 
00226     def listDAVObjects(self):
00227         # List sub-objects for PROPFIND requests.
00228         # (method is without docstring to disable publishing)
00229         #
00230         if _checkPermission(ManagePortal, self):
00231             return self.objectValues()
00232         else:
00233             return self.listFolderContents()

Here is the call graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.listFolderContents (   self,
  contentFilter = None 
)
List viewable contentish and folderish sub-objects.

Definition at line 206 of file PortalFolder.py.

00206 
00207     def listFolderContents(self, contentFilter=None):
00208         """ List viewable contentish and folderish sub-objects.
00209         """
00210         l = []
00211         for id, obj in self.contentItems(contentFilter):
00212             # validate() can either raise Unauthorized or return 0 to
00213             # mean unauthorized.
00214             try:
00215                 if getSecurityManager().validate(self, self, id, obj):
00216                     l.append(obj)
00217             except zExceptions_Unauthorized:  # Catch *all* Unauths!
00218                 pass
00219         return l

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.manage_addFolder (   self,
  id,
  title = '',
  REQUEST = None 
)
Add a new folder-like object with id *id*.

IF present, use the parent object's 'mkdir' alias; otherwise, just add
a PortalFolder.

Definition at line 453 of file PortalFolder.py.

00453 
00454                         ):
00455         """ Add a new folder-like object with id *id*.
00456 
00457         IF present, use the parent object's 'mkdir' alias; otherwise, just add
00458         a PortalFolder.
00459         """
00460         ti = self.getTypeInfo()
00461         method_id = ti and ti.queryMethodID('mkdir', context=self)
00462         if method_id:
00463             # call it
00464             getattr(self, method_id)(id=id)
00465         else:
00466             self.invokeFactory( type_name='Folder', id=id )
00467 
00468         ob = self._getOb( id )
00469         ob.setTitle( title )
00470         try:
00471             ob.reindexObject()
00472         except AttributeError:
00473             pass
00474 
00475         if REQUEST is not None:
00476             return self.manage_main(self, REQUEST, update_menu=1)
00477 
00478 InitializeClass(PortalFolderBase)
00479 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.MKCOL_handler (   self,
  id,
  REQUEST = None,
  RESPONSE = None 
)
    Handle WebDAV MKCOL.

Definition at line 326 of file PortalFolder.py.

00326 
00327     def MKCOL_handler(self,id,REQUEST=None,RESPONSE=None):
00328         """
00329             Handle WebDAV MKCOL.
00330         """
00331         self.manage_addFolder( id=id, title='' )

Here is the call graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.PUT_factory (   self,
  name,
  typ,
  body 
)
Factory for PUT requests to objects which do not yet exist.

Used by NullResource.PUT.

Returns -- Bare and empty object of the appropriate type (or None, if
we don't know what to do)

Definition at line 281 of file PortalFolder.py.

00281 
00282     def PUT_factory( self, name, typ, body ):
00283         """ Factory for PUT requests to objects which do not yet exist.
00284 
00285         Used by NullResource.PUT.
00286 
00287         Returns -- Bare and empty object of the appropriate type (or None, if
00288         we don't know what to do)
00289         """
00290         registry = getToolByName(self, 'content_type_registry', None)
00291         if registry is None:
00292             return None
00293 
00294         typeObjectName = registry.findTypeName( name, typ, body )
00295         if typeObjectName is None:
00296             return None
00297 
00298         self.invokeFactory( typeObjectName, name )
00299 
00300         # invokeFactory does too much, so the object has to be removed again
00301         obj = aq_base( self._getOb( name ) )
00302         self._delObject( name )
00303         return obj

Here is the call graph for this function:

def CMFCore.PortalFolder.PortalFolderBase.reindexObject (   self,
  idxs = [] 
)

Definition at line 275 of file PortalFolder.py.

00275 
00276     def reindexObject(self, idxs=[]):
00277         pass

Here is the caller graph for this function:

Definition at line 278 of file PortalFolder.py.

00278 
00279     def reindexObjectSecurity(self):
00280         pass

def CMFCore.PortalFolder.PortalFolderBase.setDescription (   self,
  description 
)
Set Dublin Core Description element - resource summary.

Definition at line 106 of file PortalFolder.py.

00106 
00107     def setDescription(self, description):
00108         """ Set Dublin Core Description element - resource summary.
00109         """
00110         self.description = description

Here is the caller graph for this function:

Set Dublin Core Title element - resource name.

Definition at line 100 of file PortalFolder.py.

00100 
00101     def setTitle(self, title):
00102         """ Set Dublin Core Title element - resource name.
00103         """
00104         self.title = title

Here is the caller graph for this function:

Dublin Core Title element - resource name.

Definition at line 81 of file PortalFolder.py.

00081 
00082     def Title(self):
00083         """ Dublin Core Title element - resource name.
00084         """
00085         return self.title

Here is the caller graph for this function:

Dublin Core Type element - resource type.

Definition at line 93 of file PortalFolder.py.

00093 
00094     def Type(self):
00095         """ Dublin Core Type element - resource type.
00096         """
00097         ti = self.getTypeInfo()
00098         return ti is not None and ti.Title() or 'Unknown'

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 272 of file PortalFolder.py.

00272 
00273     def unindexObject(self):
00274         pass


Member Data Documentation

Initial value:
(z2IFolderish, DynamicType.__implements__,
                      Folder.__implements__)

Reimplemented in CMFCore.PortalFolder.PortalFolder.

Definition at line 58 of file PortalFolder.py.

Definition at line 63 of file PortalFolder.py.

Definition at line 75 of file PortalFolder.py.

Definition at line 73 of file PortalFolder.py.

Initial value:
( Folder.manage_options[:1]
                     + ({'label': 'Components',
                         'action': 'manage_components'},)
                     + Folder.manage_options[1:]
                     + CMFCatalogAware.manage_options
                     )

Reimplemented in CMFCore.PortalFolder.PortalFolder.

Definition at line 65 of file PortalFolder.py.

tuple CMFCore.PortalFolder.PortalFolderBase.security = ClassSecurityInfo() [static]

Reimplemented in CMFCore.PortalFolder.PortalFolder.

Definition at line 61 of file PortalFolder.py.

Definition at line 74 of file PortalFolder.py.


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