Re : Re : Re : [Zope3-Users] Uploading files
Thanks Frank, I'll try that, Stéphane - Message d'origine De : Frank Burkhardt <[EMAIL PROTECTED]> À : Stéphane Brault <[EMAIL PROTECTED]>; zope3-users@zope.org Envoyé le : Mardi, 20 Juin 2006, 12h40mn 23s Objet : Re: Re : Re : [Zope3-Users] Uploading files Hi, On Tue, Jun 20, 2006 at 10:10:52AM +, 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 to get a file upload view. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Re : Re : [Zope3-Users] Uploading files
Hi, On Tue, Jun 20, 2006 at 10:10:52AM +, 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 to get a file upload view. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re : Re : [Zope3-Users] Uploading files
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. Thanks, Stéphane ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re : Re : [Zope3-Users] Uploading files
Thanks Tarek, in fact I just need a simple thing: the user upload a text file which I then parse and update a database. I also need to let the user upload images which I then put in a folder (this will probably be done with ftp). So my main concern is to let the user upload text files, which I don't need to save. I'm sure I only need a simple thing to do but I don't know the techniques. Also if there's no simple way in ajax, I don't mind going another way, I still need to know how to do it though. Stéphane - Message d'origine De : Tarek Ziadé <[EMAIL PROTECTED]> À : Stéphane Brault <[EMAIL PROTECTED]> Cc : zope3-users@zope.org Envoyé le : Jeudi, 1 Juin 2006, 4h59mn 42s Objet : Re: Re : [Zope3-Users] Uploading files Stéphane Brault wrote: >Thanks Stephan, > could you indicate me another way to upload files ? > > Stéphane > >- Message d'origine >De : Stephan Richter <[EMAIL PROTECTED]> >À : zope3-users@zope.org; Stéphane Brault <[EMAIL PROTECTED]> >Envoyé le : Jeudi, 1 Juin 2006, 2h53mn 32s >Objet : Re: [Zope3-Users] Uploading files > >On Tuesday 30 May 2006 09:30, Stéphane Brault wrote: > > >> for my application I mainly use sqlos and jsonserver, which means that I >>don't use much standard Zope components, I need to let users upload a file >>which I parse to update the database. I don't see how to upload files with >>AJAX. Is there a way or should I go another way. I must say I don't know >>how to do it the standard way. >> >> > >While I hate AJAX with a passion, you could certainly do this. If JS has a way >to access a local file once it has been selected, then you can use the >XmlHttpRequest class to PUT the file on the server, for example. I certainly >would not use JSON for this task. > >Regards, >Stephan > > You cannot upload file directly in javascript, because it can't reach the file system to get the file (it's all about security) the recipe is to use an IFrame in your form, to get back the hand into the client, then do what you need to do on client side while your file is beeing uploaded. What your precise use case ? Tarek ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Re : [Zope3-Users] Uploading files
Stéphane Brault wrote: >Thanks Stephan, > could you indicate me another way to upload files ? > > Stéphane > >- Message d'origine >De : Stephan Richter <[EMAIL PROTECTED]> >À : zope3-users@zope.org; Stéphane Brault <[EMAIL PROTECTED]> >Envoyé le : Jeudi, 1 Juin 2006, 2h53mn 32s >Objet : Re: [Zope3-Users] Uploading files > >On Tuesday 30 May 2006 09:30, Stéphane Brault wrote: > > >> for my application I mainly use sqlos and jsonserver, which means that I >>don't use much standard Zope components, I need to let users upload a file >>which I parse to update the database. I don't see how to upload files with >>AJAX. Is there a way or should I go another way. I must say I don't know >>how to do it the standard way. >> >> > >While I hate AJAX with a passion, you could certainly do this. If JS has a way >to access a local file once it has been selected, then you can use the >XmlHttpRequest class to PUT the file on the server, for example. I certainly >would not use JSON for this task. > >Regards, >Stephan > > You cannot upload file directly in javascript, because it can't reach the file system to get the file (it's all about security) the recipe is to use an IFrame in your form, to get back the hand into the client, then do what you need to do on client side while your file is beeing uploaded. What your precise use case ? Tarek ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users