[Zope3-Users] Uploading files

Frank Burkhardt fbo2 at gmx.net
Tue Jun 20 06:40:23 EDT 2006


Hi,

On Tue, Jun 20, 2006 at 10:10:52AM +0000, Stéphane Brault wrote:
> Hi all,
>  I'm sorry to bother you with what must be a simple problem but I still can't see
>  how to upload files with zope 3. If ajax is not a good way to go, how should I go ?
>  I just need that to upload csv files which I parse to update my database (MySQL) and
>  to upload image files.

You could use the Bytes() -schema whose InputWidget is a file upload field by default.
The content class or adapter for your form should look like this:

class IMyClass(Interface):
   [...]
   csv=Bytes(
       [...]
   )

class MyClass(object):
   [...]
   get_file(self):
      [... put database code here that returns a csv file - if you like ...]
   set_file(self,data):
      [... data contains you file's content. process it as you like ...]
   csv=property(get_file,set_file)

Just use an <editform> to get a file upload view.

Regards,

Frank


More information about the Zope3-users mailing list