What I am trying to do is on the fly when storing an image to the datastore, I would like to fill in a entry with the md5sum of the image for use later when outputting the image. I feel like it is a dummy error that I have over looked and just cant see right now.
Code snippet:
import hashlib
from google.appengine.api import urlfetch
from google.appengine.ext import db
def getimg(url):
result = urlfetch.fetch(url)
if result.status_code == 200:
return result.content
else:
return None
class ImageBlobs(db.Model):
img = db.BlobProperty(default=None)
last_update = db.DateTimeProperty(auto_now=True)
etag = db.StringProperty(default=hashlib.md5(img).hexdigest())
img = ImageBlobs(img=getimg('http://www.a-real-domain.com/a-working-image.png'))
img.put()
The error:
TypeError: must be convertible to a buffer, not BlobProperty
Ideas/Suggestions on what I can do to solve my little problem?