hi, I use Zope for my website with a Mysql Database. I just want to store a python dictionary to a blob column of my table. And my problem is that i don't know how to set and get var to a blob from a script for example... I see some blob example on the web but always with file variable (thumbnails ...) never with the other kind of variable. I hope anybody can help me with an "HelloWorld" example Thx Baptiste -- Derivexperts Paris Cyber Village 101-103 Boulevard Mac Donald 75019 Paris 01 44 89 47 49
You can convert a Python object to a byte stream by using Python's 'pickle' or 'cPickle' module -> see Python Library Reference for details and examples. -aj --On Freitag, 19. November 2004 11:47 Uhr +0100 baptiste Ancey <baptiste.ancey@derivexperts.com> wrote:
hi,
I use Zope for my website with a Mysql Database.
I just want to store a python dictionary to a blob column of my table.
And my problem is that i don't know how to set and get var to a blob from a script for example... I see some blob example on the web but always with file variable (thumbnails ...) never with the other kind of variable.
I hope anybody can help me with an "HelloWorld" example
Thx
Baptiste
-- Derivexperts Paris Cyber Village 101-103 Boulevard Mac Donald 75019 Paris 01 44 89 47 49 _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Is there a advantage to pickling a dictionary and storing it in a blob field rather than converting it to a string and storing it in a text field? -- David On Nov 19, 2004, at 2:52 AM, Andreas Jung wrote:
You can convert a Python object to a byte stream by using Python's 'pickle' or 'cPickle' module -> see Python Library Reference for details and examples.
-aj
--On Freitag, 19. November 2004 11:47 Uhr +0100 baptiste Ancey <baptiste.ancey@derivexperts.com> wrote:
I use Zope for my website with a Mysql Database.
I just want to store a python dictionary to a blob column of my table.
And my problem is that i don't know how to set and get var to a blob from a script for example... I see some blob example on the web but always with file variable (thumbnails ...) never with the other kind of variable.
How do you want to reverse the conversion from dict to string? -aj --On Samstag, 20. November 2004 22:53 Uhr -0800 David Siedband <david@calteg.org> wrote:
Is there a advantage to pickling a dictionary and storing it in a blob field rather than converting it to a string and storing it in a text field? -- David
On Nov 19, 2004, at 2:52 AM, Andreas Jung wrote:
You can convert a Python object to a byte stream by using Python's 'pickle' or 'cPickle' module -> see Python Library Reference for details and examples.
-aj
--On Freitag, 19. November 2004 11:47 Uhr +0100 baptiste Ancey <baptiste.ancey@derivexperts.com> wrote:
I use Zope for my website with a Mysql Database.
I just want to store a python dictionary to a blob column of my table.
And my problem is that i don't know how to set and get var to a blob from a script for example... I see some blob example on the web but always with file variable (thumbnails ...) never with the other kind of variable.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
I was thinking eval() combined with some sort of checking to make sure that the string being evaluated is in fact a valid dictionary... Seems like pickling is a more secure way to store dictionaries. -- David On Nov 20, 2004, at 11:59 PM, Andreas Jung wrote:
How do you want to reverse the conversion from dict to string?
-aj
--On Samstag, 20. November 2004 22:53 Uhr -0800 David Siedband <david@calteg.org> wrote:
Is there a advantage to pickling a dictionary and storing it in a blob field rather than converting it to a string and storing it in a text field?
On Sun, Nov 21, 2004 at 02:36:36PM -0800, David Siedband wrote:
I was thinking eval() combined with some sort of checking to make sure that the string being evaluated is in fact a valid dictionary... Seems like pickling is a more secure way to store dictionaries.
yeah, eval() should really be avoided unless you have some way to guarantee that the string you feed it cannot contain anything malicious. -- Paul Winkler http://www.slinkp.com
Paul Winkler wrote:
On Sun, Nov 21, 2004 at 02:36:36PM -0800, David Siedband wrote:
I was thinking eval() combined with some sort of checking to make sure that the string being evaluated is in fact a valid dictionary... Seems like pickling is a more secure way to store dictionaries.
yeah, eval() should really be avoided unless you have some way to guarantee that the string you feed it cannot contain anything malicious.
Malicious pickles (now *there's* a band name) can be problematic, too, but the effort to create one is much higher than to create Python code. Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
participants (5)
-
Andreas Jung -
baptiste Ancey -
David Siedband -
Paul Winkler -
Tres Seaver