* src/plugins/NavWebPage.py: Catch invalid HomeNote object

svn: r4158
This commit is contained in:
Martin Hawlisch 2005-03-10 22:19:19 +00:00
parent 46da2d9a61
commit 1869866af9
2 changed files with 22 additions and 18 deletions

View File

@ -3,6 +3,7 @@
HaveAltFamilies,HavePhotos,HaveChildren,NeverMarried, HaveAltFamilies,HavePhotos,HaveChildren,NeverMarried,
MultipleMarriages,NoBirthdate): Add filter rules. MultipleMarriages,NoBirthdate): Add filter rules.
* src/gramps_main.py (init_filters): Add new filters to the menu. * src/gramps_main.py (init_filters): Add new filters to the menu.
* src/plugins/NavWebPage.py: Catch invalid HomeNote object
2005-03-09 Don Allingham <don@gramps-project.org> 2005-03-09 Don Allingham <don@gramps-project.org>
* src/ChooseParents.py: Fix widget sensitivity problem, assign * src/ChooseParents.py: Fix widget sensitivity problem, assign

View File

@ -398,24 +398,27 @@ class HomePage(BasePage):
if note_id: if note_id:
obj = db.get_object_from_gramps_id(note_id) obj = db.get_object_from_gramps_id(note_id)
if obj.get_mime_type()[0:5] == "image": if not obj:
newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1] print "%s object not found" % note_id
shutil.copyfile(obj.get_path(), else:
os.path.join(html_dir,newpath)) if obj.get_mime_type()[0:5] == "image":
of.write('<div align="center">\n') newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1]
of.write('<img border="0" ') shutil.copyfile(obj.get_path(),
of.write('src="%s" />' % newpath) os.path.join(html_dir,newpath))
of.write('</div>\n') of.write('<div align="center">\n')
of.write('<img border="0" ')
note_obj = obj.get_note_object() of.write('src="%s" />' % newpath)
if note_obj: of.write('</div>\n')
text = note_obj.get()
if note_obj.get_format(): note_obj = obj.get_note_object()
of.write('<pre>\n%s\n</pre>\n' % text) if note_obj:
else: text = note_obj.get()
of.write('<p>') if note_obj.get_format():
of.write('</p><p>'.join(text.split('\n'))) of.write('<pre>\n%s\n</pre>\n' % text)
of.write('</p>') else:
of.write('<p>')
of.write('</p><p>'.join(text.split('\n')))
of.write('</p>')
self.display_footer(of) self.display_footer(of)
of.close() of.close()