SVN: CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py - made sure we can set up the skin *before* the site manager (maybe we can/should set it up *after* the sm?)

Yvo Schubbe <[email protected]> Mon, 29 Jan 2007 12:55:54 -0500 (EST)
Newsgroups gmane.comp.web.zope.cmf.cvs
Message-ID <20070129175554.7281B203309__27473.2446800501$1170093374$gmane$org@mail.zope.org>
Log message for revision 72251:
  - made sure we can set up the skin *before* the site manager (maybe we can/should set it up *after* the sm?)

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py	2007-01-29 16:42:04 UTC (rev 72250)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py	2007-01-29 17:55:53 UTC (rev 72251)
@@ -21,6 +21,7 @@
 import logging
 from thread import get_ident
 from warnings import warn
+from zope.component import getSiteManager
 
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
@@ -107,6 +108,11 @@
         """
         skinob = None
         sf = queryUtility(ISkinsTool)
+        if sf is None:
+            # XXX: Maybe we can set up the skin *after* the sm?
+            # try again with self as explicit site
+            sm = getSiteManager(self)
+            sf = sm.queryUtility(ISkinsTool)
 
         if sf is not None:
            if name is not None:
@@ -122,6 +128,11 @@
     def getSkinNameFromRequest(self, REQUEST=None):
         '''Returns the skin name from the Request.'''
         sf = queryUtility(ISkinsTool)
+        if sf is None:
+            # XXX: Maybe we can set up the skin *after* the sm?
+            # try again with self as explicit site
+            sm = getSiteManager(self)
+            sf = sm.queryUtility(ISkinsTool)
         if sf is not None:
             return REQUEST.get(sf.getRequestVarname(), None)