Back to index

plone3  3.1.7
PortalObject.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ PortalObject: The portal root object class
00014 
00015 $Id: PortalObject.py 82072 2007-12-01 18:11:06Z fschulze $
00016 """
00017 
00018 from Acquisition import aq_base
00019 from five.localsitemanager import find_next_sitemanager
00020 from five.localsitemanager.registry import FiveVerifyingAdapterLookup
00021 from five.localsitemanager.registry import PersistentComponents
00022 from Globals import InitializeClass
00023 from Products.Five.component.interfaces import IObjectManagerSite
00024 from zope.app.publication.zopepublication import BeforeTraverseEvent
00025 from zope.component.globalregistry import base
00026 from zope.event import notify
00027 from zope.interface import implements
00028 from zope.app.component.hooks import setSite
00029 
00030 from interfaces import ISiteRoot
00031 from permissions import AddPortalMember
00032 from permissions import SetOwnPassword
00033 from permissions import SetOwnProperties
00034 from permissions import MailForgottenPassword
00035 from permissions import RequestReview
00036 from permissions import ReviewPortalContent
00037 from PortalFolder import PortalFolder
00038 from Skinnable import SkinnableObjectManager
00039 
00040 PORTAL_SKINS_TOOL_ID = 'portal_skins'
00041 
00042 
00043 class PortalObjectBase(PortalFolder, SkinnableObjectManager):
00044 
00045     implements(ISiteRoot, IObjectManagerSite)
00046     meta_type = 'Portal Site'
00047 
00048     # Ensure certain attributes come from the correct base class.
00049     __getattr__ = SkinnableObjectManager.__getattr__
00050     _checkId = SkinnableObjectManager._checkId
00051 
00052     # Ensure all necessary permissions exist.
00053     __ac_permissions__ = (
00054         (AddPortalMember, ()),
00055         (SetOwnPassword, ()),
00056         (SetOwnProperties, ()),
00057         (MailForgottenPassword, ()),
00058         (RequestReview, ()),
00059         (ReviewPortalContent, ()),
00060         )
00061 
00062     def getSkinsFolderName(self):
00063         return PORTAL_SKINS_TOOL_ID
00064 
00065     def getSiteManager(self):
00066         if self._components is None:
00067             # BBB: for CMF 2.0 instances
00068             next = find_next_sitemanager(self)
00069             if next is None:
00070                 next = base
00071             name = '/'.join(self.getPhysicalPath())
00072             self._components = components = PersistentComponents(name, (next,))
00073             components.__parent__ = self
00074             setSite(self)
00075         elif self._components.utilities.LookupClass \
00076                 != FiveVerifyingAdapterLookup:
00077             # BBB: for CMF 2.1 beta instances
00078             # XXX: should be removed again after the CMF 2.1 release
00079             components = aq_base(self._components)
00080             components.__parent__ = self
00081             utilities = aq_base(components.utilities)
00082             utilities.LookupClass = FiveVerifyingAdapterLookup
00083             utilities._createLookup()
00084             utilities.__parent__ = components
00085             
00086         return self._components
00087 
00088     def __before_publishing_traverse__(self, arg1, arg2=None):
00089         """ Pre-traversal hook.
00090         """
00091         # XXX hack around a bug(?) in BeforeTraverse.MultiHook
00092         REQUEST = arg2 or arg1
00093 
00094         notify(BeforeTraverseEvent(self, REQUEST))
00095         self.setupCurrentSkin(REQUEST)
00096 
00097         super(PortalObjectBase,
00098               self).__before_publishing_traverse__(arg1, arg2)
00099 
00100 InitializeClass(PortalObjectBase)