Appending to a file via manage_edit?
I've been looking around for this, but can't seem to find anything. I'm assuming that it is just not possible, but thought I'd ask just in case. For File objects, I see that manage_edit() has the parameters: title, content_type, precondition, filedata & REQUEST. Setting something in the filedata parameter will replace the file's current data with that. This implies (to me at least) that the only way one can edit a file is a complete rewrite. Does there exist a way to simply append data to the end of the file? For instance, if one wanted to write to a file line by line, is that possible in Zope? Thanks
--On 11. Dezember 2007 12:04:36 -0500 Jeff Gentry <jgentry@jimmy.harvard.edu> wrote:
I've been looking around for this, but can't seem to find anything. I'm assuming that it is just not possible, but thought I'd ask just in case.
For File objects, I see that manage_edit() has the parameters: title, content_type, precondition, filedata & REQUEST. Setting something in the filedata parameter will replace the file's current data with that.
This implies (to me at least) that the only way one can edit a file is a complete rewrite. Does there exist a way to simply append data to the end of the file? For instance, if one wanted to write to a file line by line, is that possible in Zope?
out-of-the-box: NO Appending data would require the manipulation of the linked list of Pdata elements. There is no API for this available...so basically forget it. -aj
I've been looking around for this, but can't seem to find anything. I'm assuming that it is just not possible, but thought I'd ask just in case.
For File objects, I see that manage_edit() has the parameters: title, content_type, precondition, filedata & REQUEST. Setting something in the filedata parameter will replace the file's current data with that.
This implies (to me at least) that the only way one can edit a file is a complete rewrite. Does there exist a way to simply append data to the end of the file? For instance, if one wanted to write to a file line by line, is that possible in Zope?
out-of-the-box: NO
Appending data would require the manipulation of the linked list of Pdata elements. There is no API for this available...so basically forget it. What about the python pickle/cpickle and marshal modules? If I'm not wrong zope uses cpickle to append data to the Data.fs, or am I wrong?
I haven't read the module documetation deeply, but as I understand, pickle/cpickle is used for serializing python objects, while marshal is for binary data. http://docs.python.org/lib/module-pickle.html http://docs.python.org/lib/module-marshal.html Anyway, you still need to load the whole file into a temporal memory. Best regards Josef
--On 11. Dezember 2007 18:33:14 +0100 Josef Meile <jmeile@hotmail.com> wrote:
I've been looking around for this, but can't seem to find anything. I'm assuming that it is just not possible, but thought I'd ask just in case.
For File objects, I see that manage_edit() has the parameters: title, content_type, precondition, filedata & REQUEST. Setting something in the filedata parameter will replace the file's current data with that.
This implies (to me at least) that the only way one can edit a file is a complete rewrite. Does there exist a way to simply append data to the end of the file? For instance, if one wanted to write to a file line by line, is that possible in Zope?
out-of-the-box: NO
Appending data would require the manipulation of the linked list of Pdata elements. There is no API for this available...so basically forget it. What about the python pickle/cpickle and marshal modules? If I'm not wrong zope uses cpickle to append data to the Data.fs, or am I wrong?
I haven't read the module documetation deeply, but as I understand, pickle/cpickle is used for serializing python objects, while marshal is for binary data.
http://docs.python.org/lib/module-pickle.html http://docs.python.org/lib/module-marshal.html
Anyway, you still need to load the whole file into a temporal memory.
Completely unrelated at this point. You can only update a file as a whole with the existing functionality. You are of course free to write your own file implementation. -aj
On Tue, 11 Dec 2007, Andreas Jung wrote:
Appending data would require the manipulation of the linked list of Pdata elements. There is no API for this available...so basically forget it.
I figured it'd be a lot more obvious if it was possible. Ah well. Thanks -J
--On 11. Dezember 2007 15:37:27 -0500 Jeff Gentry <jgentry@jimmy.harvard.edu> wrote:
On Tue, 11 Dec 2007, Andreas Jung wrote:
Appending data would require the manipulation of the linked list of Pdata elements. There is no API for this available...so basically forget it.
I figured it'd be a lot more obvious if it was possible. Ah well.
Sorry, but that's a pretty uncommon usecase. If you upload a file you're basically interested to store/replace it as a whole. That's how OFS.File is implemented. Andreas
Andreas Jung wrote:
Sorry, but that's a pretty uncommon usecase. If you upload a file you're basically interested to store/replace it as a whole. That's how OFS.File is implemented.
Although it probably would be *that* hard to hack an external method or some such that *did* update the PData chain in the right way ;-) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Andreas Jung -
Chris Withers -
Jeff Gentry -
Josef Meile