[CMF-checkins] CVS: CMF/CMFSetup - skins.py:1.2 utils.py:1.6
Tres Seaver
tseaver at zope.com
Tue May 25 18:06:54 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv29399
Modified Files:
skins.py utils.py
Log Message:
- skins.py:
o Finish out skins tool export (import still untested in "real life").
=== CMF/CMFSetup/skins.py 1.1 => 1.2 ===
--- CMF/CMFSetup/skins.py:1.1 Tue May 25 08:23:36 2004
+++ CMF/CMFSetup/skins.py Tue May 25 18:06:18 2004
@@ -4,8 +4,9 @@
$Id$
"""
-
-from xml.sax import parse
+import os
+import re
+from xml.sax import parseString
from AccessControl import ClassSecurityInfo
from Acquisition import Implicit
@@ -13,10 +14,13 @@
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import minimalpath
from Products.CMFCore.DirectoryView import createDirectoryView
+from Products.CMFCore.DirectoryView import DirectoryView
from permissions import ManagePortal
from utils import HandlerBase
+from utils import _resolveDottedName
from utils import _xmldir
class _SkinsParser( HandlerBase ):
@@ -37,7 +41,7 @@
elif name == 'skin-directory':
self._skin_dirs.append( ( self._extract( attrs, 'id' )
- , self._extract( attrs, 'path' )
+ , self._extract( attrs, 'directory' )
) )
elif name == 'skin-path':
@@ -57,8 +61,9 @@
tool = self._skins_tool
- for id, path in self._skin_dirs:
- createDirectoryView( tool, path, id )
+ for id, directory in self._skin_dirs:
+
+ createDirectoryView( tool, directory, id )
for path_name, layers in self._skin_paths:
tool.addSkinSelection( path_name, ', '.join( layers ) )
@@ -67,6 +72,8 @@
security = ClassSecurityInfo()
security.setDefaultAccess('allow')
+
+ _COMMA_SPLITTER = re.compile( r',[ ]*' )
def __init__( self, site ):
@@ -84,15 +91,37 @@
'path' -- sequence of layer IDs
"""
- return [ { 'id' : k, 'path' : v }
- for k, v in self._skins_tool.getSkinPaths() ]
+ return [ { 'id' : k
+ , 'path' : self._COMMA_SPLITTER.split( v )
+ } for k, v in self._skins_tool.getSkinPaths() ]
+
+ security.declareProtected(ManagePortal, 'listFSDirectoryViews' )
+ def listFSDirectoryViews( self ):
+
+ """ Return a sequence of mappings for each FSDV.
+
+ o Keys include:
- security.declareProtected(ManagePortal, 'getDirPath' )
- def getDirPath( self, dir ):
+ 'id' -- FSDV ID
- """Return the private _dirpath variable
+ 'directory' -- filesystem path of the FSDV.
"""
- return dir._dirpath
+ result = []
+ fsdvs = self._skins_tool.objectItems( DirectoryView.meta_type )
+ fsdvs.sort()
+
+ for id, fsdv in fsdvs:
+
+ dirpath = fsdv._dirpath
+
+ if dirpath.startswith( '/' ):
+ dirpath = minimalpath( fsdv._dirpath )
+
+ result.append( { 'id' : id
+ , 'directory' : dirpath
+ } )
+
+ return result
_skinsConfig = PageTemplateFile( 'stcExport.xml'
, _xmldir
@@ -156,7 +185,7 @@
skins_tool._getSelections().clear()
- for id in skins_tool.objectIds('Filesystem Directory View'):
+ for id in skins_tool.objectIds( DirectoryView.meta_type ):
skins_tool._delObject(id)
text = context.readDataFile( _FILENAME )
=== CMF/CMFSetup/utils.py 1.5 => 1.6 ===
--- CMF/CMFSetup/utils.py:1.5 Tue May 25 08:48:53 2004
+++ CMF/CMFSetup/utils.py Tue May 25 18:06:18 2004
@@ -75,13 +75,20 @@
return title, description
+
class HandlerBase( ContentHandler ):
_encoding = None
+ _MARKER = object()
+
+ def _extract( self, attrs, key, default=None ):
+
+ result = attrs.get( key, self._MARKER )
- def _extract( self, attrs, key ):
+ if result is self._MARKER:
+ return default
- return self._encode( attrs[ key ] )
+ return self._encode( result )
def _encode( self, content ):
More information about the CMF-checkins
mailing list