Back to index

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

List of all members.

Public Member Functions

def getSkinsFolderName
def __getattr__
def getSkin
def getSkinNameFromRequest
def changeSkin
def getCurrentSkinName
def clearCurrentSkin
def setupCurrentSkin

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _checkId

Detailed Description

Definition at line 61 of file Skinnable.py.


Member Function Documentation

Looks for the name in an object with wrappers that only reach
up to the root skins folder.

This should be fast, flexible, and predictable.

Definition at line 70 of file Skinnable.py.

00070 
00071     def __getattr__(self, name):
00072         '''
00073         Looks for the name in an object with wrappers that only reach
00074         up to the root skins folder.
00075 
00076         This should be fast, flexible, and predictable.
00077         '''
00078         if not name.startswith('_') and not name.startswith('aq_'):
00079             sd = SKINDATA.get(get_ident())
00080             if sd is not None:
00081                 ob, skinname, ignore, resolve = sd
00082                 if not ignore.has_key(name):
00083                     if resolve.has_key(name):
00084                         return resolve[name]
00085                     subob = getattr(ob, name, _MARKER)
00086                     if subob is not _MARKER:
00087                         # Return it in context of self, forgetting
00088                         # its location and acting as if it were located
00089                         # in self.
00090                         retval = aq_base(subob)
00091                         resolve[name] = retval
00092                         return retval
00093                     else:
00094                         ignore[name] = 1
00095         if superGetAttr is None:
00096             raise AttributeError, name
00097         return superGetAttr(self, name)

Here is the caller graph for this function:

def CMFCore.Skinnable.SkinnableObjectManager._checkId (   self,
  id,
  allow_dup = 0 
) [private]
Override of ObjectManager._checkId().

Allows the user to create objects with IDs that match the ID of
a skin object.

Definition at line 201 of file Skinnable.py.

00201 
00202     def _checkId(self, id, allow_dup=0):
00203         '''
00204         Override of ObjectManager._checkId().
00205 
00206         Allows the user to create objects with IDs that match the ID of
00207         a skin object.
00208         '''
00209         superCheckId = SkinnableObjectManager.inheritedAttribute('_checkId')
00210         if not allow_dup:
00211             # Temporarily disable skindata.
00212             # Note that this depends heavily on Zope's current thread
00213             # behavior.
00214             tid = get_ident()
00215             sd = SKINDATA.get(tid)
00216             if sd is not None:
00217                 del SKINDATA[tid]
00218             try:
00219                 base = getattr(self,  'aq_base', self)
00220                 if not hasattr(base, id):
00221                     # Cause _checkId to not check for duplication.
00222                     return superCheckId(self, id, allow_dup=1)
00223             finally:
00224                 if sd is not None:
00225                     SKINDATA[tid] = sd
00226         return superCheckId(self, id, allow_dup)
00227 
00228 InitializeClass(SkinnableObjectManager)

Here is the caller graph for this function:

def CMFCore.Skinnable.SkinnableObjectManager.changeSkin (   self,
  skinname,
  REQUEST = _MARKER 
)
Change the current skin.

Can be called manually, allowing the user to change
skins in the middle of a request.

Definition at line 128 of file Skinnable.py.

00128 
00129     def changeSkin(self, skinname, REQUEST=_MARKER):
00130         '''Change the current skin.
00131 
00132         Can be called manually, allowing the user to change
00133         skins in the middle of a request.
00134         '''
00135         skinobj = self.getSkin(skinname)
00136         if skinobj is not None:
00137             tid = get_ident()
00138             SKINDATA[tid] = (skinobj, skinname, {}, {})
00139             if REQUEST is _MARKER:
00140                 REQUEST = getattr(self, 'REQUEST', None)
00141                 warn("changeSkin should be called with 'REQUEST' as second "
00142                      "argument. The BBB code will be removed in CMF 2.3.",
00143                      DeprecationWarning, stacklevel=2)
00144             if REQUEST is not None:
00145                 REQUEST._hold(SkinDataCleanup(tid))

Here is the call graph for this function:

Here is the caller graph for this function:

Clear the current skin.

Definition at line 165 of file Skinnable.py.

00165 
00166     def clearCurrentSkin(self):
00167         """Clear the current skin."""
00168         tid = get_ident()
00169         if SKINDATA.has_key(tid):
00170             del SKINDATA[tid]

Return the current skin name.

Definition at line 147 of file Skinnable.py.

00147 
00148     def getCurrentSkinName(self):
00149         '''Return the current skin name.
00150         '''
00151         sd = SKINDATA.get(get_ident())
00152         if sd is not None:
00153             ob, skinname, ignore, resolve = sd
00154             if skinname is not None:
00155                 return skinname
00156         # nothing here, so assume the default skin
00157         sfn = self.getSkinsFolderName()
00158         if sfn is not None:
00159             sf = getattr(self, sfn, None)
00160             if sf is not None:
00161                 return sf.getDefaultSkin()
00162         # and if that fails...
00163         return None

Here is the call graph for this function:

def CMFCore.Skinnable.SkinnableObjectManager.getSkin (   self,
  name = None 
)
Returns the requested skin.

Definition at line 99 of file Skinnable.py.

00099 
00100     def getSkin(self, name=None):
00101         """Returns the requested skin.
00102         """
00103         skinob = None
00104         sfn = self.getSkinsFolderName()
00105 
00106         if sfn is not None:
00107             sf = getattr(self, sfn, None)
00108             if sf is not None:
00109                if name is not None:
00110                    skinob = sf.getSkinByName(name)
00111                if skinob is None:
00112                    skinob = sf.getSkinByName(sf.getDefaultSkin())
00113                    if skinob is None:
00114                        skinob = sf.getSkinByPath('')
00115         return skinob

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the skin name from the Request.

Definition at line 117 of file Skinnable.py.

00117 
00118     def getSkinNameFromRequest(self, REQUEST=None):
00119         '''Returns the skin name from the Request.'''
00120         if REQUEST is None:
00121             return None
00122         sfn = self.getSkinsFolderName()
00123         if sfn is not None:
00124             sf = getattr(self, sfn, None)
00125             if sf is not None:
00126                 return REQUEST.get(sf.getRequestVarname(), None)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file Skinnable.py.

00066 
00067     def getSkinsFolderName(self):
00068         # Not implemented.
00069         return None

Here is the caller graph for this function:

Sets up skindata so that __getattr__ can find it.

Can NOT be called manually to change skins in the middle of a
request! Use changeSkin for that.

Definition at line 172 of file Skinnable.py.

00172 
00173     def setupCurrentSkin(self, REQUEST=_MARKER):
00174         '''
00175         Sets up skindata so that __getattr__ can find it.
00176 
00177         Can NOT be called manually to change skins in the middle of a
00178         request! Use changeSkin for that.
00179         '''
00180         if REQUEST is _MARKER:
00181             REQUEST = getattr(self, 'REQUEST', None)
00182             warn("setupCurrentSkin should be called with 'REQUEST' as "
00183                  "argument. The BBB code will be removed in CMF 2.3.",
00184                  DeprecationWarning, stacklevel=2)
00185         if REQUEST is None:
00186             # self is not fully wrapped at the moment.  Don't
00187             # change anything.
00188             return
00189         if SKINDATA.has_key(get_ident()):
00190             # Already set up for this request.
00191             return
00192         skinname = self.getSkinNameFromRequest(REQUEST)
00193         try:
00194             self.changeSkin(skinname, REQUEST)
00195         except ConflictError:
00196             raise
00197         except:
00198             # This shouldn't happen, even if the requested skin
00199             # does not exist.
00200             logger.exception("Unable to setupCurrentSkin()")

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple CMFCore.Skinnable.SkinnableObjectManager.security = ClassSecurityInfo() [static]

Definition at line 63 of file Skinnable.py.


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