[Checkins] SVN: CMF/trunk/CMFCore/DirectoryView.py - added BBB code in createDirectoryView

Yvo Schubbe y.2007- at wcm-solutions.de
Sat Feb 24 06:36:35 EST 2007


Log message for revision 72798:
  - added BBB code in createDirectoryView
  - improved deprecation warnings
  - some 'ignore' cleanup

Changed:
  U   CMF/trunk/CMFCore/DirectoryView.py

-=-
Modified: CMF/trunk/CMFCore/DirectoryView.py
===================================================================
--- CMF/trunk/CMFCore/DirectoryView.py	2007-02-23 23:09:33 UTC (rev 72797)
+++ CMF/trunk/CMFCore/DirectoryView.py	2007-02-24 11:36:33 UTC (rev 72798)
@@ -51,19 +51,19 @@
 # Ignore filesystem artifacts
 base_ignore = ('.', '..')
 # Ignore version control subdirectories
-ignore = ('CVS', 'SVN', '.', '..', '.svn')
+ignore = ('CVS', '.svn')
 # Ignore suspected backups and hidden files
 ignore_re = re.compile(r'\.|(.*~$)|#')
 
 # and special names.
-def _filtered_listdir(path, ignore=ignore):
+def _filtered_listdir(path, ignore):
     return [ name
              for name
              in listdir(path)
              if name not in ignore and not ignore_re.match(name) ]
 
 class _walker:
-    def __init__(self, ignore=ignore):
+    def __init__(self, ignore):
         # make a dict for faster lookup
         self.ignore = dict([(x, None) for x in ignore])
 
@@ -112,7 +112,7 @@
     def __init__(self, filepath, reg_key, ignore=ignore):
         self._filepath = filepath
         self._reg_key = reg_key
-        self.ignore=base_ignore + tuple(ignore)
+        self.ignore = base_ignore + tuple(ignore)
         if platform == 'win32':
             self._walker = _walker(self.ignore)
         subdirs = []
@@ -335,8 +335,9 @@
             package = getPackageName(_prefix)
             filepath = path.join(getPackageLocation(package), name)
         else:
-            warn('registerDirectory() called with a path; should be called '
-                 'with globals', DeprecationWarning, stacklevel=2)
+            warn('registerDirectory() called with deprecated _prefix type. '
+                 'Support for paths will be removed in CMF 2.3. Please use '
+                 'globals instead.', DeprecationWarning, stacklevel=2)
             filepath = path.join(_prefix, name)
             (package, name) = _findProductForPath(_prefix, name)
         reg_key = _generateKey(package, name)
@@ -584,7 +585,12 @@
     """
     info = _dirreg.getDirectoryInfo(reg_key)
     if info is None:
-        raise ValueError('Not a registered directory: %s' % reg_key)
+        reg_key = _dirreg.getCurrentKeyFormat(reg_key)
+        info = _dirreg.getDirectoryInfo(reg_key)
+        warn('createDirectoryView() called with deprecated reg_key format. '
+             'Support for old key formats will be removed in CMF 2.3. Please '
+             'use the new key format <product>:<subdir> instead.',
+             DeprecationWarning, stacklevel=2)
     if not id:
         id = reg_key.split('/')[-1]
     else:
@@ -602,8 +608,9 @@
     if not isinstance(_prefix, basestring):
         package = getPackageName(_prefix)
     else:
-        warn('addDirectoryViews() called with a path; should be called with '
-             'globals', DeprecationWarning, stacklevel=2)
+        warn('addDirectoryViews() called with deprecated _prefix type. '
+             'Support for paths will be removed in CMF 2.3. Please use '
+             'globals instead.', DeprecationWarning, stacklevel=2)
         (package, name) = _findProductForPath(_prefix, name)
     reg_key = _generateKey(package, name)
     info = _dirreg.getDirectoryInfo(reg_key)



More information about the Checkins mailing list