Пример #1
0
 def add_annotation(self, metadata, key, value):
 
     """ Adds an Annotation to a Metadata Object
         of one namespace
         if the key is already included the value
         will be updated. if the key is not there, a new annotation
         will be created
     """ 
     
     try: 
         Annotation.get(imgmeta=metadata, an_key=key)
         newimgmetaversion = metadata.version
         newimgmetaversion = newimgmetaversion + 1
         meta_query = metadata.update(version=newimgmetaversion)
         meta_query.execute()
         
         anno_query = Annotation.update(an_value=value).where(imgmeta=metadata, an_key=key)
         anno_query.execute()
         return
     except Annotation.DoesNotExist:
         imganno = Annotation.create(
                             imgmeta = metadata,
                             an_key = key,
                             an_value = value,)
         imganno.save()
         return imganno
Пример #2
0
def image_detail(imageid):

    """
        function that is when a specific image is requested
        the metadata of the requested image is loaded (if there is one)
        and given to the template
    """

    try: 
        image = Image.get(id=imageid)
        imgfrag = ImageFragment.get(image=image, x=0, y=0, visible=True)
        imgmeta = Metadata.get(imgfrag=imgfrag, namespace="http://www.w3.org/ns/ma-ont#")
        annos = Annotation.get(imgmeta=imgmeta)
        return render_template('image_detail.html', img=image,imgmeta=imgmeta)
    except Imageuri.DoesNotExist:
        flash('Die Bildnummer wurde nicht gefunden. Bitte waehle ein anderes Bild.', 'error')
        return render_template('images.html')
    except ImageFragment.DoesNotExist:
        return render_template('image_detail.html', img=image)