bug#0005370: Error creating website; photo was not being checked to see if it exists or not.

svn: r18446
This commit is contained in:
Rob G. Healey 2011-11-15 09:38:48 +00:00
parent c9c05d97a0
commit 09bc6f73f6

View File

@ -1535,59 +1535,59 @@ class BasePage(object):
# begin individualgallery division and section title # begin individualgallery division and section title
with Html("div", class_ = "subsection", id = "indivgallery") as section: with Html("div", class_ = "subsection", id = "indivgallery") as section:
section += Html("h4", _("Media"), inline = True) section += Html("h4", _("Media"), inline =True)
displayed = [] displayed = []
for mediaref in photolist_ordered: for mediaref in photolist_ordered:
photo_handle = mediaref.get_reference_handle() photo_handle = mediaref.get_reference_handle()
photo = self.report.database.get_object_from_handle(photo_handle) photo = self.report.database.get_object_from_handle(photo_handle)
if photo:
if photo_handle in displayed: if photo_handle in displayed:
continue continue
mime_type = photo.get_mime_type() mime_type = photo.get_mime_type()
# get media description # get media description
descr = photo.get_description() descr = photo.get_description()
if mime_type: if mime_type:
try: try:
lnkref = (self.report.cur_fname, self.page_title, self.gid) lnkref = (self.report.cur_fname, self.page_title, self.gid)
self.report.add_lnkref_to_photo(photo, lnkref) self.report.add_lnkref_to_photo(photo, lnkref)
real_path, newpath = self.report.prepare_copy_media(photo) real_path, newpath = self.report.prepare_copy_media(photo)
# create thumbnail url # create thumbnail url
# extension needs to be added as it is not already there # extension needs to be added as it is not already there
url = self.report.build_url_fname(photo_handle, "thumb", True) + ".png" url = self.report.build_url_fname(photo_handle, "thumb", True) + ".png"
# begin hyperlink # begin hyperlink
section += self.media_link(photo_handle, url, descr, True) section += self.media_link(photo_handle, url, descr, True)
except (IOError, OSError), msg: except (IOError, OSError), msg:
WarningDialog(_("Could not add photo to page"), str(msg)) WarningDialog(_("Could not add photo to page"), str(msg))
else: else:
try: try:
# begin hyperlink # begin hyperlink
section += self.doc_link(photo_handle, descr, up = True) section += self.doc_link(photo_handle, descr, up = True)
lnk = (self.report.cur_fname, self.page_title, self.gid) lnk = (self.report.cur_fname, self.page_title, self.gid)
# FIXME. Is it OK to add to the photo_list of report? # FIXME. Is it OK to add to the photo_list of report?
photo_list = self.report.photo_list photo_list = self.report.photo_list
if photo_handle in photo_list: if photo_handle in photo_list:
if lnk not in photo_list[photo_handle]: if lnk not in photo_list[photo_handle]:
photo_list[photo_handle].append(lnk) photo_list[photo_handle].append(lnk)
else: else:
photo_list[photo_handle] = [lnk] photo_list[photo_handle] = [lnk]
except (IOError, OSError), msg: except (IOError, OSError), msg:
WarningDialog(_("Could not add photo to page"), str(msg)) WarningDialog(_("Could not add photo to page"), str(msg))
displayed.append(photo_handle) displayed.append(photo_handle)
# add fullclear for proper styling # add fullclear for proper styling
section += fullclear section += fullclear
# return indivgallery division to its caller
return section return section
def display_note_list(self, notelist = None): def display_note_list(self, notelist = None):