Mercurial > p > roundup > code
diff roundup/backends/blobfiles.py @ 2089:93f03c6714d8
A few big changes in this commit:
1. The current indexer has been moved to backends/indexer_dbm in
anticipation of my writing an indexer_rdbms,
2. Changed indexer invocation during create / set to follow the pattern
set by the metakit backend, which was much cleaner, and
3. The "content" property of FileClass is now mutable in all but the
metakit backend.
Metakit needs to be changed to support the editing of "content". Hey, and
I learnt today that the metakit backend implements its own indexer. How
about that... :)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 19 Mar 2004 04:47:59 +0000 |
| parents | fc52d57c6c3e |
| children | 682eefe8ef23 4d112730e02f |
line wrap: on
line diff
--- a/roundup/backends/blobfiles.py Thu Mar 18 22:47:00 2004 +0000 +++ b/roundup/backends/blobfiles.py Fri Mar 19 04:47:59 2004 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: blobfiles.py,v 1.11 2004-02-11 23:55:09 richard Exp $ +#$Id: blobfiles.py,v 1.12 2004-03-19 04:47:59 richard Exp $ '''This module exports file storage for roundup backends. Files are stored into a directory hierarchy. ''' @@ -77,12 +77,14 @@ if not os.path.exists(os.path.dirname(name)): os.makedirs(os.path.dirname(name)) - # open the temp file for writing - open(name + '.tmp', 'wb').write(content) - - # save off the commit action - self.transactions.append((self.doStoreFile, (classname, nodeid, - property))) + # save to a temp file + name = name + '.tmp' + # make sure we don't register the rename action more than once + if not os.path.exists(name): + # save off the rename action + self.transactions.append((self.doStoreFile, (classname, nodeid, + property))) + open(name, 'wb').write(content) def getfile(self, classname, nodeid, property): '''Get the content of the file in the database. @@ -115,6 +117,11 @@ # determine the name of the file to write to name = self.filename(classname, nodeid, property) + # content is being updated (and some platforms, eg. win32, won't + # let us rename over the top of the old file) + if os.path.exists(name): + os.remove(name) + # the file is currently ".tmp" - move it to its real name to commit os.rename(name+".tmp", name)
