1.1 --- a/WebStack/Repositories/Directory.py Sun Nov 20 21:19:14 2005 +0000
1.2 +++ b/WebStack/Repositories/Directory.py Sun Nov 20 21:35:45 2005 +0000
1.3 @@ -102,6 +102,8 @@
1.4 for name in os.listdir(self.path):
1.5 if name.endswith(".edit"):
1.6 l.append(name[:-5])
1.7 + elif name == self.new_filename:
1.8 + pass
1.9 else:
1.10 l.append(name)
1.11 return map(self._convert_fsname, l)
1.12 @@ -199,7 +201,16 @@
1.13 # special file in an attempt to impose some kind of atomic "bottleneck".
1.14
1.15 elif create:
1.16 - self.lock(self.new_filename)
1.17 +
1.18 + # NOTE: Avoid failure case where no __new__ file exists for some
1.19 + # NOTE: reason.
1.20 +
1.21 + try:
1.22 + self.lock(self.new_filename)
1.23 + except KeyError:
1.24 + f = open(self.edit_path(self.new_filename), "wb")
1.25 + f.close()
1.26 +
1.27 try:
1.28 if opener is None:
1.29 f = open(edit_path, "wb")
1.30 @@ -209,6 +220,9 @@
1.31 f.close()
1.32 finally:
1.33 self.unlock(self.new_filename)
1.34 +
1.35 + # Where no creation is requested, raise an exception.
1.36 +
1.37 else:
1.38 raise KeyError, key
1.39