Hi I wonder why my image doesn't appear. I think it is stored both as a blobproperty and in the blobstore since it appears like a thumbnail on the list page. The address to the page where the image doesn't appear is http://www.koolbusiness.com/servead/4125209
And the thumbnail from the same image appears in the list http://www.koolbusiness.com/li
Some of my template code to display image is:
{% if ad.matched_images.get %} <table><tr>
<td>
<div class="ad_pict" id="display_image"><img src="{{url}}" alt="" onload="show_hidden_elements();return false;"></div>
</td> <td>
{% ifequal len 1 %}
{% else %}
{% for im in imv %}
<div id="thumb0" class="ad_thumb ad_border_solid_black" onclick="showLargeImage('{{im}}');thumbnailBorder(this, 5 )">
<table class="clean_table shadowed_thumb" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><img src="/_/img/thumb_left_top.gif"></td>
<td class="top_middle" align="left" valign="bottom"></td>
<td></td>
</tr>
<tr>
<td class="middle_left"></td>
<td><img src="{{im}}=s120" alt="">
</td>
<td class="single_middle_right" valign="top"><img src="/_/img/thumb_single_right_top.gif"></td>
</tr>
<tr>
<td></td>
<td class="single_bottom_center" valign="top"><img src="/_/img/thumb_single_left_bottom.gif"></td>
<td valign="top"><img src="/_/img/thumb_single_right_bottom.gif"></td>
</tr>
</tbody>
</table>
</div>
开发者_C百科 {% endfor %}
{% endifequal %}
Ans som eof my serverside python to load the template is:
class AdHandler(I18NHandler):
def get(self, id):
ad = Ad.get_by_id(long(id))
if not ad:
self.error(404)
return
image = ad.matched_images.get()
url=''
if image:
if image.primary_image:
url = images.get_serving_url(str(image.primary_image.key()))
imv = []
table=''
for i in ad.matched_images:
if i.primary_image:
i1=images.get_serving_url(str(i.primary_image.key()))
imv.append(i1)
self.render_template("imageinfo.html", {'url':url,
'imv':imv,'len':len(imv),
'ad':ad,
'image': image,
'logout_url': users.create_logout_url('/'),
})
If I use the old version of the page the image does appear so it's clear that I have it in the database, I've just written a bug and need to structure my migration from the blobproperty to the blobstore: http://www.koolbusiness.com/4125209
Since the image appears at the later url I know it's there and it's just a bug in my code somewhere that I can't reproduce that makes the image not appear. Thanks for any help
I would guess that one of these two if statements is evaluating to false:
if image:
if image.primary_image:
url = images.get_serving_url(str(image.primary_image.key()))
If you were actually calling get_serving_url, you would either get a valid serving URL or an exception. Instead, url still has its starting value, a blank string.
精彩评论