Example #1
0
    def testExifPageVariables(self):
        """exif page template variables"""
        self._setTemplate("group basic;\n" \
                'page(gallery, css, js, class, tmpl, rootdir, copyright,' \
                '           album, photo, prev, next) ::=' \
                ' "\'$gallery.title$\'' \
                ' $css$' \
                ' $js$' \
                ' $class$' \
                ' $tmpl$' \
                ' $rootdir$' \
                ' $copyright$' \
                ' p:$prev.title$' \
                ' n:$next.title$' \
                ' $album.title$' \
                ' $photo.exif: {e | n:$e.name$v:$e.value$}$"')

        f = StringIO()
        album = Album()
        album.title = 'a title'
        album.dir = 'a/b/c'
        parent = self.tmpl.gallery
        parent.subalbums.append(album)

        p1 = Photo()
        p1.title = 'p1'
        p1.name = 'n1'
        p1.album = album

        p1.exif.append(Exif('ea', 'ev'))
        p1.exif.append(Exif('ez', 'eq'))

        p2 = Photo()
        p2.title = 'p2'
        p2.name = 'n2'
        p2.album = album

        album.photos.extend([p1, p2])

        self.tmpl.photoPage(f, p1)

        expected = '\'danlann title test\'' \
                ' css/danlann.css' \
                ' js/jquery.jsjs/danlann.js' \
                ' photo' \
                ' basic/photo' \
                ' ../../..' \
                ' (cc)' \
                ' p:' \
                ' n:p2' \
                ' a title' \
                ' n:eav:evn:ezv:eq\n'
        self.assertEquals(expected, f.getvalue())
Example #2
0
    def n_photo(self, node):
        """
        Add photo to current album.
        """
        photo             = Photo()
        photo.name        = node.data[0]
        photo.title       = node.data[1]
        photo.description = node.data[2]

        photo.album       = self.album
        photo.gallery     = self.gallery

        if not self.album:
            global filename, lineno
            raise ParseError('photo %s cannot exist' \
                    ' without album' % photo.name, filename, lineno)
        self.album.photos.append(photo)