String Literal to Blob

Victor Subervi victorsubervi at gmail.com
Wed Apr 9 19:29:58 CEST 2008


On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden <steve at holdenweb.com> wrote:

> Victor Subervi wrote:
>
> > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden <steve at holdenweb.com<mailto:
> > steve at holdenweb.com>> wrote:
> >
> > I'm having a problem believing this, but I don't think you are lying.
> Are you *sure* you have stored the correct omages in your database?


Well, the Plesk PHP/MySQL interface indicates that a blob has been
successfully stored. Furthermore, the output I get has strings like either
'Adobe Photoshop' or 'GIMP', depending on the editor I used. And the output
is like I have seen before from incorrectly rendered images. And images are
what I loaded into those fields through my form. So I believe they are
indeed images.


> The fact remains that cursor.fetchall() will return a list containing one
> tuple containing (what you believe is) your image, so there is NO way your
> code above can do what you want.


Right. I used your suggestion of cursor.fetchall()[0][0] and the result was
*still* the image of the url. (I also used the other suggestion.)


>
>
> I can therefore only assume that this is a CGI script and that your web
> server does something *extremely* funky when it gets a CGI output it isn't
> expecting. But this doesn't make a lot of sense.


Okay. How trouble-shoot this? Pass it on to the techies where I host?
Generally they are less than receptive, but maybe if I show them this thread
I can get their attention.


>
>
> Stupidity and ignorance are entirely different things, and you (current)
> ignorance in no way implies stupidity. We all have to learn.
>

True. I have never found programming easy. But I have been very persistent.
It still is not easy for me.


> However, if you bring up one of the pages from one of your many web sites
> containing an image, and get your browser to display the HTML of that page
> you will surely find that the image does not appear direectly in the HTML,
> but instead appears as a tag in the HTML. Something like:
>
>    <img src="http://server/path/image.jpg">
>
> though the src attribute doesn't really need to be that complex.
>

Of course.


>
>
> In my stupidity, I have assumed you meant this:
> >
> >            content = col_fields[0][14].tostring()
> >            print '<img src="', content, '"><br /><br />'
> >
> > Well, here I have no idea what the content of your database might be,
> but if the fifteenth column you retrieve is the web server path to the
> graphic, that should be right except for the spaces around it, which might
> give trouble. You might consider instead
>
>            content = col_fields[0][14].tostring()
>            print '<img src="%s"><br /><br />' % content


Great suggestion! Those spaces always mess me up. Unfortunately, it *still*
did not render properly :(


>
>
> Forget HTML for now. If you direct your browser to the URL on which your
> server is serving the graphic then it should be displayed in the browser
> window. Until that happy condition pertains, we are stabbing around in the
> dark.


Again...time to alert the teckies where I host?


>
> It's not that I mind, but I do feel that this knowledge is already
> available, though clearly I might be wrong ...


Well, I may have missed it in all my googling, but I thought I was pretty
thorough. At any rate, it certainly cannot hurt to document it again (if it
is indeed 'again')
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080409/8128d9be/attachment.html>


More information about the Python-list mailing list