+ def last_published(self):
+ try:
+ return self.publish_log.all()[0].timestamp
+ except IndexError:
+ return None
+
+ def assert_publishable(self):
+ from librarian.picture import WLPicture
+ from librarian import NoDublinCore, ParseError, ValidationError
+
+ class SelfImageStore(object):
+ def path(self_, slug, mime_type):
+ """Returns own file object. Ignores slug ad mime_type."""
+ return open(self.image.path)
+
+ publishable = self.publishable()
+ assert publishable, _("There is no publishable revision")
+ picture_xml = publishable.materialize()
+
+ try:
+ picture = WLPicture.from_string(picture_xml.encode('utf-8'),
+ image_store=SelfImageStore)
+ except ParseError, e:
+ raise AssertionError(_('Invalid XML') + ': ' + str(e))
+ except NoDublinCore:
+ raise AssertionError(_('No Dublin Core found.'))
+ except ValidationError, e:
+ raise AssertionError(_('Invalid Dublin Core') + ': ' + str(e))
+
+ valid_about = self.correct_about()
+ assert picture.picture_info.about in valid_about, \
+ _("rdf:about is not") + " " + valid_about[0]
+
+ def publishable_error(self):
+ try:
+ return self.assert_publishable()
+ except AssertionError, e:
+ return e
+ else:
+ return None
+