I have a javascript file located at my local harddisk and I want it to become an object in zope. I have already tried to use manage_addFile, but it doesnt seem to find the file. In Zope mangement view its easy enough to create a txt-file and get it on working, but when I want to do the exact same thing in a Product created with Python, it just wont!
So far I have also tried to find some other objects that I might use instead of manage_addFile, but havent succeded yet.
I'm mildly confused as to what you're trying to do here, and I suspect that's because you are too. If you want to simply create a single object in your ZODB containing the text of your javascript file, do it through the web as a File, selecting your js file for upload. Change the content type to text/plain or whatever MIME type Javascript might be, and you're done. I do this with CSS all the time. To add a File from python code, you must give it a fileish object or a string containing the contents as the 'file' parameter. That means that you must find the file via its path and create a Python file-ish object (usually by way of the built-in open() method) or read its contents into a string. This you can pass to manage_addFile. It won't deal with a path. Selecting the file and getting the data in the proper format is done automatically by your browser for the input type of 'file'. Outside it, you must do it yourself. If you're subclassing File (to make, say, a JavascriptFile) you'll have to write your own 'manage_addWhatever' function to be called from the web or other Products. It can be almost identical to manage_addFile, but you must call your new Product's class constructor, and not the File one. --jcc