예제 #1
0
파일: event.py 프로젝트: marian42/journal
	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
예제 #2
0
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()