[Zope-CMF] Directory view and backup files

Lalo Martins lalo@laranja.org
Wed, 4 Sep 2002 15:52:07 -0300


--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

DirectoryView was giving me a lot of pain while I was editing some skins:

2002-09-04T18:26:12 ERROR(200) DirectoryView Error checking for directory modification
(...)
OSError: [Errno 2] No such file or directory:
'/usr/lib/zope/lib/python/Products/CMFPlone/skins/plone_3rdParty/CMFCollector/.#collector_edit_form.pt'

(For the non-Emacs-enlightened, this is a backup file.)

I finally got tired and patched it so that it doesn't try to check backup
and hidden files for changes. Patch attached.

[]s,
                                               |alo
                                               +----
--
            Those who trade freedom for security
               lose both and deserve neither.
--
http://www.laranja.org/                mailto:lalo@laranja.org
         pgp key: http://www.laranja.org/pessoal/pgp

Eu jogo RPG! (I play RPG)         http://www.eujogorpg.com.br/
Python Foundry Guide http://www.sf.net/foundry/python-foundry/

--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="cmf-core-nobackups.diff"

--- DirectoryView.py.~1.30.~	Mon Sep  2 08:37:32 2002
+++ DirectoryView.py	Wed Sep  4 15:35:35 2002
@@ -32,6 +32,7 @@
 from zLOG import LOG, ERROR
 from sys import exc_info
 from types import StringType
+import re
 
 _dtmldir = path.join( package_home( globals() ), 'dtml' )
 
@@ -39,6 +40,8 @@
 
 # Ignore version control subdirectories
 ignore = ('CVS', 'SVN', '.', '..')
+# Ignore backups and hidden files
+ignore_re = re.compile(r'\.|(.*~$)|#')
 
 # and special names.
 def _filtered_listdir(path):
@@ -51,7 +54,7 @@
     names = [ (name, stat(path.join(dirname,name))[8])
               for name
               in names
-              if name not in ignore ]
+              if name not in ignore and not ignore_re.match(name)]
     listdir.extend(names)
 
 class DirectoryInformation:

--HlL+5n6rz5pIUxbD--