[CMF-checkins] CVS: CMF/CMFSetup - skins.py:1.3 utils.py:1.7

Tres Seaver tseaver at zope.com
Tue May 25 18:36:21 EDT 2004


Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv3195

Modified Files:
	skins.py utils.py 
Log Message:


  - skins.py:

    o Dump / reload skins tool properties.


=== CMF/CMFSetup/skins.py 1.2 => 1.3 ===
--- CMF/CMFSetup/skins.py:1.2	Tue May 25 18:06:18 2004
+++ CMF/CMFSetup/skins.py	Tue May 25 18:35:51 2004
@@ -32,11 +32,24 @@
         self._encoding = encoding
         self._skin_dirs = []
         self._skin_paths = []
+        self._default_skin = None
+        self._request_var = None
+        self._allow_arbitrary = False
+        self._persist_cookie = False
 
     def startElement( self, name, attrs ):
 
         if name == 'skins-tool':
-            pass
+            self._default_skin = self._extract( attrs, 'default_skin' )
+            self._request_var = self._extract( attrs, 'request_varname' )
+            self._allow_arbitrary = self._extractBoolean( attrs
+                                                        , 'allow_any'
+                                                        , False
+                                                        )
+            self._persist_cookie = self._extractBoolean( attrs
+                                                       , 'cookie_persistence'
+                                                       , False
+                                                       )
 
         elif name == 'skin-directory':
 
@@ -60,6 +73,10 @@
     def endDocument( self ):
 
         tool = self._skins_tool
+        tool.default_skin = str( self._default_skin )
+        tool.request_varname = str( self._request_var )
+        tool.allow_any =  self._allow_arbitrary and 1 or 0
+        tool.cookie_persistence =  self._persist_cookie and 1 or 0
 
         for id, directory in self._skin_dirs:
 
@@ -123,6 +140,35 @@
 
         return result
 
+    security.declareProtected(ManagePortal, 'getDefaultSkin' )
+    def getDefaultSkin( self ):
+
+        """ Return the tool's default skin name.
+        """
+        return self._skins_tool.default_skin
+
+    security.declareProtected(ManagePortal, 'getRequestVarName' )
+    def getRequestVarName( self ):
+
+        """ Return the tool's skin request variable name.
+        """
+        return self._skins_tool.request_varname
+
+    security.declareProtected(ManagePortal, 'getAllowAny' )
+    def getAllowAny( self ):
+
+        """ Return the tool's "allow arbitrary skin paths" setting (a boolean).
+        """
+        return self._skins_tool.allow_any
+
+    security.declareProtected(ManagePortal, 'getCookiePersistence' )
+    def getCookiePersistence( self ):
+
+        """ Return the tool's cookie persistence setting (a boolean).
+        """
+        return self._skins_tool.cookie_persistence
+
+    security.declarePrivate( '_skinsConfig' )
     _skinsConfig = PageTemplateFile( 'stcExport.xml'
                                    , _xmldir
                                    , __name__='skinsConfig'


=== CMF/CMFSetup/utils.py 1.6 => 1.7 ===
--- CMF/CMFSetup/utils.py:1.6	Tue May 25 18:06:18 2004
+++ CMF/CMFSetup/utils.py	Tue May 25 18:35:51 2004
@@ -90,6 +90,16 @@
 
         return self._encode( result )
 
+    def _extractBoolean( self, attrs, key, default ):
+
+        result = attrs.get( key, self._MARKER )
+
+        if result is self._MARKER:
+            return default
+
+        result = result.lower()
+        return result in ( '1', 'yes', 'true' )
+
     def _encode( self, content ):
 
         if self._encoding is None:




More information about the CMF-checkins mailing list