def does_image_id_exist(self, image_id): q = InstaStore.all(keys_only=True) q.filter('image_id =', image_id) result = q.get() if result: return True return False
def insert_to_datastore(self, image): try: caption = image['caption']['text'] except TypeError: caption = '' insta_img = InstaStore( caption=caption, created=datetime.datetime.fromtimestamp(int(image['created_time'])), image_id=image['id'], image_photo_url=image['images']['standard_resolution']['url'], image_photo_thumbnail_url=image['images']['thumbnail']['url'], image_url=image['link'], user_avatar_url=image['user']['profile_picture'], user_id=image['user']['id'], user_name=image['user']['username'], user_real_name=image['user']['full_name'], user_url='http://instagram.com/%s' % image['user']['username'] ) insta_img.put() print 'Added %s to the datastore' % image['link']
def get(self): query = InstaStore.all(keys_only=True) entries =query.fetch(1000) db.delete(entries)