Hi folks, I've run into a problem using an External Method with reads an mp3 info tag from a *file* and expects a file name argument as such. Then, the function happily calls os.stat on the argument and so on, which all break because the mp3 file is actually an object in a zope folder and not something living in the file system. Is there an easy way to modify the function to operate on a zope file object? I'm using the python snippet I found here: https://sourceforge.net/snippet/download.php?type=snippet&id=100048 I've also looked at the audio object, but it seems that I would have to re-upload all mp3's in order to have properties added, right? Cheers & thanks in advance, Uwe -- Uwe Schuerkamp http://www.schuerkamp.de/ GnuPG Fingerprint: 2093 20B8 B861 9358 A356 B01A E145 9249 5D27 33EA PGP Fingerprint: 2E 13 20 22 9A 3F 63 7F 67 6F E9 B1 A8 36 A4 61
Uwe Schuerkamp writes:
I've run into a problem using an External Method with reads an mp3 info tag from a *file* and expects a file name argument as such. Then, the function happily calls os.stat on the argument and so on, which all break because the mp3 file is actually an object in a zope folder and not something living in the file system.
Is there an easy way to modify the function to operate on a zope file object? Probably, but I did not look at the code.
I expect, the function uses "os.stat", maybe some other "os" functions, opens the file and looks at its header. You should skip everything until ofter the file is open and read. Zope file objects have an attribute "data". This is a string, when the file is sufficiently small, otherwise, it is a more complex object (that stores the file contents in chunks). You can use "str" on this attribute to always convert it into a string (containing the files content). However, you will then be less efficient. The best approach would be to just use the first chunk in this case. Please look at the objects method to learn how to do this. Once, you have the first chunk of the file object, you proceed as the original method did after it have opened and read the file. Dieter
participants (2)
-
Dieter Maurer -
Uwe Schuerkamp