* src/GrampsDb/_GrampsDbBase.py: prevent null event types and

attribute types from being added
	* src/Editors/_EditAttribute.py: prevent null attribute types
	* src/Editors/_EditEvent.py: prevent null attribute types
	* src/AutoComp.py: filter out empty strings
	* src/ImgManip.py: check for file before attempting thumbnailer


svn: r6898
This commit is contained in:
Don Allingham 2006-06-16 03:32:51 +00:00
parent 8366c12818
commit 4cf930d039
6 changed files with 35 additions and 11 deletions

View File

@ -1,4 +1,10 @@
2006-06-15 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: prevent null event types and
attribute types from being added
* src/Editors/_EditAttribute.py: prevent null attribute types
* src/Editors/_EditEvent.py: prevent null attribute types
* src/AutoComp.py: filter out empty strings
* src/ImgManip.py: check for file before attempting thumbnailer
* src/ScratchPad.py: enable Text dnd
2006-06-15 Alex Roitman <shura@gramps-project.org>

View File

@ -139,6 +139,7 @@ class StandardCustomSelector:
self.active_key = active_key
self.active_index = 0
self.additional = additional
# make model
self.store = gtk.ListStore(int,str)
@ -176,8 +177,10 @@ class StandardCustomSelector:
if self.additional:
for event_type in self.additional:
if type(event_type) == str or type(event_type) == unicode :
if event_type:
self.store.append(row=[self.custom_key, event_type])
elif type(event_type) == tuple:
if event_type[1]:
self.store.append(row=[event_type[0], event_type[1]])
else:
self.store.append(row=[int(event_type), str(event_type)])

View File

@ -135,6 +135,14 @@ class EditAttribute(EditSecondary):
Called when the OK button is pressed. Gets data from the
form and updates the Attribute data structure.
"""
t = self.obj.get_type()
if t.is_custom() and str(t) == '':
from QuestionDialog import ErrorDialog
ErrorDialog(
_("Cannot save attribute"),
_("The attribute type cannot be empty"))
return
if self.callback:
self.callback(self.obj)
self.close()

View File

@ -204,6 +204,13 @@ class EditEvent(EditPrimary):
"enter data or cancel the edit."))
return
t = self.obj.get_type()
if t.is_custom() and str(t) == '':
ErrorDialog(
_("Cannot save event"),
_("The event type cannot be empty"))
return
if self.obj.handle == None:
trans = self.db.transaction_begin()
self.db.add_event(self.obj,trans)

View File

@ -448,7 +448,7 @@ class GrampsDbBase(GrampsDBCallback):
self.individual_attributes.update(
[str(attr.type) for attr in person.attribute_list
if attr.type.is_custom()])
if attr.type.is_custom() and str(attr.type)])
if person.marker.is_custom():
self.marker_names.add(str(person.marker))
@ -468,7 +468,7 @@ class GrampsDbBase(GrampsDBCallback):
attr_list = []
for mref in person.media_list:
attr_list += [str(attr.type) for attr in mref.attribute_list
if attr.type.is_custom()]
if attr.type.is_custom() and str(attr.type)]
self.media_attributes.update(attr_list)
def commit_media_object(self, obj, transaction, change_time=None):
@ -482,7 +482,7 @@ class GrampsDbBase(GrampsDBCallback):
transaction, change_time)
self.media_attributes.update(
[str(attr.type) for attr in obj.attribute_list
if attr.type.is_custom()])
if attr.type.is_custom() and str(attr.type)])
def commit_source(self, source, transaction, change_time=None):
"""
@ -501,7 +501,7 @@ class GrampsDbBase(GrampsDBCallback):
attr_list = []
for mref in source.media_list:
attr_list += [str(attr.type) for attr in mref.attribute_list
if attr.type.is_custom()]
if attr.type.is_custom() and str(attr.type)]
self.media_attributes.update(attr_list)
def commit_place(self, place, transaction, change_time=None):
@ -520,7 +520,7 @@ class GrampsDbBase(GrampsDBCallback):
attr_list = []
for mref in place.media_list:
attr_list += [str(attr.type) for attr in mref.attribute_list
if attr.type.is_custom()]
if attr.type.is_custom() and str(attr.type)]
self.media_attributes.update(attr_list)
def commit_personal_event(self, event, transaction, change_time=None):
@ -545,7 +545,7 @@ class GrampsDbBase(GrampsDBCallback):
attr_list = []
for mref in event.media_list:
attr_list += [str(attr.type) for attr in mref.attribute_list
if attr.type.is_custom()]
if attr.type.is_custom() and str(attr.type)]
self.media_attributes.update(attr_list)
def commit_family(self, family, transaction, change_time=None):
@ -560,7 +560,7 @@ class GrampsDbBase(GrampsDBCallback):
self.family_attributes.update(
[str(attr.type) for attr in family.attribute_list
if attr.type.is_custom()])
if attr.type.is_custom() and str(attr.type)])
rel_list = []
for ref in family.child_ref_list:
@ -580,7 +580,7 @@ class GrampsDbBase(GrampsDBCallback):
attr_list = []
for mref in family.media_list:
attr_list += [str(attr.type) for attr in mref.attribute_list
if attr.type.is_custom()]
if attr.type.is_custom() and str(attr.type)]
self.media_attributes.update(attr_list)
def commit_repository(self, repository, transaction, change_time=None):

View File

@ -116,7 +116,7 @@ def _build_thumb_path(path):
return os.path.join(const.thumb_dir, m.hexdigest()+'.png')
def run_thumbnailer(mtype, frm, to, size=const.thumbScale):
if const.use_thumbnailer:
if const.use_thumbnailer and os.path.isfile(frm):
sublist = {
'%s' : "%dx%d" % (int(size),int(size)),
'%u' : frm,