Philipp von Weitershausen wrote:
> Christian Theune wrote:
>> Hi,
>> as I stumbled over this recently, I'd like to bring this up for
>> discussion:
>> There is an interface called IWriteFile in the module
>> zope.filerepresentation.interfaces.
>> It defines one method "write(data)" with the doc string:
>> "Update the file data"
>> There are some problems I have with this:
>> a) The interface is yet another interface for doing a file-like object.
>> How many of those are around?
> Oh, which others are there?

Humm. Looks like it's only that one =).

>> b) It *seems intended* not to be really file-like but that "update the
>> file data" means: writing to this will replace all previous data
> Yes.

Too bad. :/

>> c) The doc string is IMHO underspecified (I asked 3 other developers in
>> the office. One of them said "it will replace the data on the second
>> call", one said "it will append data like the file object", the third
>> wasn't sure but was in favor of appending data)
>> This interface is used only in very few places in Zope.

Yup. That's what I saw.

>> I'm not sure what to do now, but I think something needs to be changed.
>> Here are some options:
>> - Make the doc string more explicit. (That should happen anyway)
>> - Keep the current behavior.
> I think we'll have to :(. There have been lots of documented uses of
> filerepresentation
>> - Change the current behavior and make write() act like Python's
>>   file.write()
> Perhaps in a new interface?

We probably have to. But to be honest? I totally understand every
programmer that will ask us "WTF?!?". Does anybody see a better way out
of that situation without deprecating anything again?


SchoolTool is using this infrastructure for it's RESTive views. And
yes the interface could get improved a bit. The file.write() method
could be more simmilar to IFileFactory.__call__ as else one has to
assume that updates to a file are not going to change the encoding as
the encoding from an HTTP PUT request is ignored (which got us a few
times when users were uploading ICal ics files with a different
encoding so we had to work around it with a custom view for updates).

Zope3-dev mailing list

Reply via email to