Beispiel #1
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)
Beispiel #2
0
    def add_metadata(self, fragment, nasp):
    
        """ Adds metadata to a given fragment 
            with an optional namespace attribute 
        """ 

        try:
            imgmeta = Metadata.get(imgfrag=fragment, namespace=nasp)
            newimgmetaversion = imgmeta.version
            newimgmetaversion = newimgmetaversion + 1
            up_query = Metadata.update(version=newimgmetaversion).where(imgfrag=fragment, namespace=nasp)
            up_query.execute()
            return imgmeta
        except Metadata.DoesNotExist:

            imgmeta = Metadata.create(
                                imgfrag = fragment,
                                version = 1,
                                namespace = nasp,)
            imgmeta.save()
            return imgmeta