def get_value(self, key): from model.key import Key from model.keyvaluepair import KeyValuePair try: return KeyValuePair.get((KeyValuePair.key == Key.get_key(key)) & (KeyValuePair.event == self)).value except DoesNotExist: return None
def add(summary, time, tags=[], kvps={}, hash=None, latitude=None, longitude=None, images=[]): result = Event(summary=summary, time=time, latitude=latitude, longitude=longitude, hash=hash) result.save() for tag in tags: result.add_tag(tag) for key in kvps.keys(): db_key = Key.get_key(key) kvp = KeyValuePair(key=db_key, value=kvps[key], event=result) kvp.save(force_insert=True) for image_path in images: image = Image(event=result, file=image_path) image.save()