returnHttpResponseForbidden("No permission to write to event directory.")
else:
# Note: could also check whether e.errno==errno.EEXIST
++failedAttempts
iffailedAttempts>=MAX_FAILED_OPEN_ATTEMPTS:
returnHttpResponseServerError("Cannot open file for writing: %s"%e)
# Under race conditions, increment lastVersion.
ife.errno==errno.EACCES:
++lastVersion
# Still with me? Then write the file.
f=request.FILES['upload']
forchunkinf.chunks():
fdest.write(chunk)
fdest.close()
# Move the symlink. No temporal gaps, please.
# XXX Not sure what this call does with an *existing* symlink.
os.symlink(filename,linkpath)
elifos.path.isfile(filepath):
# The thing is a file. We will not allow a put request to the file
# resource (for now, anyway).
response=HttpResponseForbidden("%s is a file. Versioning is not supported with legacy data. Please change your filename to avoid clobbering."%filename)
elifnotfilename:
# Not good. There's nothing we can do without a filename.
response=HttpResponseBadRequest("Must have a filename for upload.")
elifos.path.isdir(filepath):
response=HttpResponseForbidden("%s is a directory"%filename)
else:
response=HttpResponseServerError("Should not happen.")