File saving with PloneFormGen in MySQL

7 messages Options
Embed this post
Permalink
bad_my84 () File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
Hi all,

I'm using PloneFormGen (1.2.4) to add & extract data to/form an MySQL-database (5.0.51).
It works fine with strings and integers, but I'm having problems trying to add a file with the 'File-field' from PloneFormGen.

I'm using 'ZSQL Method' to add the data to the database.
The corresponding column-name is exactly the same as the 'File-field'-name with type 'LONGBLOB'.

What steps am I missing? Should I use some sort of Python-script?

Thanks in advance!

Bas.
ajung () Re: File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
On 13.11.2008 10:20 Uhr, bad_my84 wrote:
> Hi all,
>
> I'm using PloneFormGen (1.2.4) to add&  extract data to/form an
> MySQL-database (5.0.51).
> It works fine with strings and integers, but I'm having problems trying to
> add a file with the 'File-field' from PloneFormGen.

And the problem is what in detail?

-aj

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () Re: File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
The problem is that I don't know how I can add a file via the 'File field' into the database.

With strings & integers I use the 'ZSQL Method' with:
INSERT INTO tabel VALUES(
  <dtml-sqlvar voornaam type=string>,
  <dtml-sqlvar achternaam type=string>
)

But what kind of type should I use for a file? Or isn't it that ease?
ajung () Re: File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
On 13.11.2008 10:41 Uhr, bad_my84 wrote:

> The problem is that I don't know how I can add a file via the 'File field'
> into the database.
>
> With strings&  integers I use the 'ZSQL Method' with:
> INSERT INTO tabel VALUES(
>    <dtml-sqlvar voornaam type=string>,
>    <dtml-sqlvar achternaam type=string>
> )
>
> But what kind of type should I use for a file? Or isn't it that ease?
No idea about MySQL but a blob-ish type is likely the right choice.
You have to check your MySQL documentation how to insert binary data
into a blob. This is not a Zope issue since Zope generates only the SQL
_you are writing_. If you upload a file you should be able to get hold
of the binary data of the file through something like

binary_data = context.REQUEST['name-of-file-field'].read()

-aj

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () Re: File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink

Andreas Jung-5 wrote:
On 13.11.2008 10:41 Uhr, bad_my84 wrote:
> The problem is that I don't know how I can add a file via the 'File field'
> into the database.
>
> With strings&  integers I use the 'ZSQL Method' with:
> INSERT INTO tabel VALUES(
>    <dtml-sqlvar voornaam type=string>,
>    <dtml-sqlvar achternaam type=string>
> )
>
> But what kind of type should I use for a file? Or isn't it that ease?

No idea about MySQL but a blob-ish type is likely the right choice.
You have to check your MySQL documentation how to insert binary data
into a blob. This is not a Zope issue since Zope generates only the SQL
_you are writing_. If you upload a file you should be able to get hold
of the binary data of the file through something like

binary_data = context.REQUEST['name-of-file-field'].read()

-aj

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:info@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
Thanks, now I know how to get the binary data!
bribon () Re: File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
bad_my84 wrote:
Andreas Jung-5 wrote:
On 13.11.2008 10:41 Uhr, bad_my84 wrote:
> The problem is that I don't know how I can add a file via the 'File field'
> into the database.
>
> With strings&  integers I use the 'ZSQL Method' with:
> INSERT INTO tabel VALUES(
>    <dtml-sqlvar voornaam type=string>,
>    <dtml-sqlvar achternaam type=string>
> )
>
> But what kind of type should I use for a file? Or isn't it that ease?

No idea about MySQL but a blob-ish type is likely the right choice.
You have to check your MySQL documentation how to insert binary data
into a blob. This is not a Zope issue since Zope generates only the SQL
_you are writing_. If you upload a file you should be able to get hold
of the binary data of the file through something like

binary_data = context.REQUEST['name-of-file-field'].read()

-aj

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:info@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
Thanks, now I know how to get the binary data!

I have the same problem and cannot go on with my project. How did you get it??
bad_my84 () RE: [Product-Developers] File saving with PloneFormGen in MySQL
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
With the line Andreas gave ("binary_data = context.REQUEST['name-of-file-field'].read()") or some small variation of that.
I can't tell you exactly because I lost all my code.
 


Van: bribon (via Nabble) [mailto:[hidden email]]
Verzonden: donderdag 10 september 2009 20:49
Aan: Roijen, Bas
Onderwerp: Re: [Product-Developers] File saving with PloneFormGen in MySQL


bad_my84 wrote:
Andreas Jung-5 wrote:
On 13.11.2008 10:41 Uhr, bad_my84 wrote:

> The problem is that I don't know how I can add a file via the 'File field'
> into the database.
>
> With strings&  integers I use the 'ZSQL Method' with:
> INSERT INTO tabel VALUES(
>    <dtml-sqlvar voornaam type=string>,
>    <dtml-sqlvar achternaam type=string>
> )
>
> But what kind of type should I use for a file? Or isn't it that ease?

No idea about MySQL but a blob-ish type is likely the right choice.
You have to check your MySQL documentation how to insert binary data
into a blob. This is not a Zope issue since Zope generates only the SQL
_you are writing_. If you upload a file you should be able to get hold
of the binary data of the file through something like

binary_data = context.REQUEST['name-of-file-field'].read()

-aj

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Thanks, now I know how to get the binary data!

How did you get it?? ================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
================================================ ================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
================================================