More & More Fun w/ Pics & MySQL
victorsubervi at gmail.com
Sat Oct 17 18:31:23 CEST 2009
On Sat, Oct 17, 2009 at 11:33 AM, Carsten Haese <carsten.haese at gmail.com>wrote:
> Victor Subervi wrote:
> > Let me clarify. This prints out "all sorts of crap", which means an
> > image string, the image as a string, to the screen:
> > print 'Content-type: image/jpeg'
> > print 'Content-Encoding: base64'
> > print
> > print pic().encode('base64')
> > print '</body></html>'
> This has no hope of working, since you're sending data that's not valid
> base64 code and pretend that it's base64-encoded. A browser trying to
> display this result will produce something anywhere between
> unpredictable and garbage.
This was recommended to me previously on this list, so I tried it.
> > The following once upon a time printed images, but now it doesn't. Why
> > would that be? I would refresh the screen, and it would print. I'd
> > change a line and it wouldn't. I'd change it back to what it was and it
> > would no longer the image to the screen. Why is that? The same happens
> > with or without the base64 stuff. Commenting out a line seemed to make a
> > difference!
> Why would turning a comment into a statement NOT make a difference?!?
You misunderstood. Leaving in the __commented__ line __commented__ and
__not__uncommented__ made a difference. Why?
> > print 'Content-type: text/plain'
> > #print 'Content-type: image/jpeg'
> > print
> > print pic()
> > print '</body></html>'
> This should produce plain text, not an image.
> > The above prints out a broken image of correct dimensions.
> What the heck is a "broken image of correct dimensions"?
> Are you looking
> at the output of the script itself, or are you looking at an html page
> that uses this script as src-attribute for an img-tag? In the latter
> case, if you're also giving the img-tag width and height attributes, it
> shouldn't be surprising that you're getting the correct dimensions, and
> you're getting a broken image because your src is producing plain text
> instead of an image.
Before, when it produced plain text it printed the same to screen. Now it
> > Of course I try and figure out how things work once they get working.
> > Sometimes, however, there is __no__ logic to it __at__all__. Sorry.
> > After years of struggling with python I've come to realize that even
> > though I may not be a good programmer, it isn't me. It may not be python
> > itself. It may be the crappy hardware the server farms use. It may be
> > the way they tweak their python interpreter. But it isn't just me.
> I suppose it's possible that there is something quirky about the way the
> server has been set up, but so far, the more likely explanation is that
> you don't really know what you're doing.
Well, if I did, I wouldn't be asking for your help. I was hoping you could
> You can prove whether it's your server farm or you by running the same
> code on a different server.
> > It would be nice if I could get this code printing images to the screen
> > as it was before I had to put out another unnecessary fire when code
> > that previously uploaded the images in the first place inexplicably no
> > longer worked. Then, lo and behold, when I came back to this code that I
> > hadn't touched and was working fine earlier this week, it no longer
> > works. Lovely. My "plug-and-play" program has devoured two weeks of my
> > time and I'm still up the creek without a paddle. Sure would appreciate
> > any help you can give.
> Again, you have to help us help you. I have listed the three things you
> need to post together, and you haven't done that. You're giving us bits
> and pieces, but nothing that's sufficiently cohesive to do any
> meaningful troubleshooting on.
Forgive me. I must have misunderstood. I have deleted the old message. Would
you be so kind as to re-post those three things you need me to provide you?
> Carsten Haese
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list