String Literal to Blob

Steve Holden steve at holdenweb.com
Sat Apr 12 17:44:23 EDT 2008


Victor Subervi wrote:
> in line...
> 
> On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden <steve at holdenweb.com 
> <mailto:steve at holdenweb.com>> wrote:
> 
>     Victor Subervi wrote:
>      > I have worked on this many hours a day for two weeks. If there is an
>      > easier way to do it, just take a minute or two and point it out. Have
>      > you heard of the Law of Diminishing Returns? I have passed it
>     long ago.
>      > I no longer want to waste time trying to guess at what you are
>     trying to
>      > tell me.
>      > Victor
>      >
>      > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden
>     <steve at holdenweb.com <mailto:steve at holdenweb.com>
>      > <mailto:steve at holdenweb.com <mailto:steve at holdenweb.com>>> wrote:
>     Where you have
> 
>                 content = col_fields[0][14].tostring()
>                 pic = "tmp" + str(i) + ".jpg"
>                 img = open(pic, "w")
>                 img.write(content)
>                 print '<img src="%s"><br /><br />' % pic
>                 img.close()
> 
>     instead write
> 
>                 print content
> 
>  
> Like this, I presume?
>  
Yes. You might need to use content.tostring() - I am not familiar with 
MySQL blobs.

>             img = open(pic, "w")
>             img.write(content)
>             print '<td><input type="hidden" name="%s"' % str(x), ' 
> value="%s">' % pic
>             print content
> #            print '<img src="%s"><br /><br /></td>\n' % pic
> Does not work _at_all LOL. You will recall, also, that you once gave me 
> a line similar to the one commented out (but without writing then 
> opening the file). THAT did not work, either. So now do you see why I am 
> frustrated??
> 
> 
> 
>     Then browse to the URL this program serves and you will see the image
>     (assuming you are still sending the image/jpeg content type). 
> 
>  
> Well, as I mentioned before, I am sending text/html because the page, 
> like almost all web pages, has a whole lot more content than just 
> images. Or, perhaps you are suggesting I build my pages in frames, and 
> have a frame for every image. Unsightly!
>  
Dear Victor:

If you cannot understand, after being told several times by different 
people, that pages with images in them are achieved by multiple HTTP 
requests, then there is little I can do to help you.

> 
>     Once you
>     can see the image, THEN you can write a page that refers to it. Until
>     you start serving the image (NOT pseudo-html with image data embedded in
>      it) nothing else will work.
> 
>  
> My solution works just fine, thank you. It is inelegant. But it now 
> appears to me, and I dare say rather clearly, that this inelegance is 
> the fault of python itself. Perhaps this should be brought to Guido´s 
> attention.
> Victor

You can say it as clearly as you like, but if you say it too loudly you 
will make a laughing stock of yourself.

You surely don't think that a language that supports Zope, TurboGears, 
Pylons and Django (to name but the first four that come to mind) is 
unsuitable for web programming?

Please, do yourself a big favor and persist with this until you 
understand what you are doing wrong and how to serve dynamic images. It 
appears that the learning may be painful, but I guarantee it will be 
worthwhile.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/



More information about the Python-list mailing list