def media_url(self): from base import media if self.media_id is not None: return media.url_for(media.get(self.media_id)) return None
def serialize(self, json_friendly=False): from base import media, tags dic = super(Item, self).serialize(json_friendly) if json_friendly: dic["tags"] = [x.tag for x in tags.get_tags(self)] if self.media_id is not None: dic["media_url"] = media.url_for(media.get(self.media_id)) else: dic["media_url"] = None return dic