[Zope] Upload File to a different Folder with python

Harry Wilkinson harryw@nipltd.com
Fri, 26 Apr 2002 13:06:24 +0100


Methods in Zope have to have docstrings in order to be publishable over the 
web.  So, you need to add a docstring.  I'm not sure why this behaviour is 
desirable, but that's the way it is.  Just an empty docstring will do.  Try 
this:

def addFile(self,file):
        "This method adds a file"
        #create the file
        self.manage_addFile(id, file=file, title="")
                
        self.manage_addProduct['OFSP'].manage_addFile(id='', title='', 
file=file)
        # create a success message
        message="File '%s' uploaded successfully." % file.filename

        # redirect to main page - this is necessary to make all the URLs
        # on the main page work correctly.
        return self.REQUEST.RESPONSE.redirect("%s?message=%s" %
(self.absolute_url(), url_quote(message)))


On Friday 26 April 2002 12:51 pm, Roger Ineichen wrote:
> Hello together
> How can I add a file with a Python Class/Method. I have to call this
> Method from a other folder like:
>
> Python_product_instance
>
> |-FileFolder
> |
> |  |-addFile()
> |
> |-skin
> |
>    |--uploadForm action addFile
>
> My uploadForm
> ------------
> <form action="../FileFolder/addFile" method="post"
> enctype="multipart/form-data">
> <input type="file" name="file">
> <input type="submit" value="Hochladen">
> </form>
>
>
> My addFile:
> ------------
> def addFile(self,file):
> 	# create the file
> 	self.manage_addFile(id, file=file, title="")
>
> 	self.manage_addProduct['OFSP'].manage_addFile(id='', title='',
> file=file)
> 	# create a success message
> 	message="File '%s' uploaded successfully." % file.filename
>
> 	# redirect to main page - this is necessary to make all the URLs
> 	# on the main page work correctly.
> 	return self.REQUEST.RESPONSE.redirect("%s?message=%s" %
> (self.absolute_url(), url_quote(message)))
>
>
> The error is:
> -------------
> The object at Url---FileFolder/addFile has an empty or missing
> docstring. Objects must have a docstring to be published.
>
>
> Thanks a lot friends
> Roger Ineichen
> ___________________________
>
> Projekt01 GmbH
> www.projekt01.ch
> Langackerstrasse 8
> 6330 Cham
> phone  +41 (0)41 781 01 78
> mobile +41 (0)79 340 52 32
> fax    +41 (0)41 781 00 78
> email  r.ineichen@projekt01.ch
> ___________________________
> END OF MESSAGE
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )