2006-08-14 Alex Roitman <shura@gramps-project.org>

* src/GrampsDb/_GrampsBSDDB.py (gramps_upgrade_10): Add an upgrade
	path from 2.1.91.
	* src/RelLib/_AttributeType.py: Add new attribute types for events
	and event references.
	* src/RelLib/_EventRef.py: Add attribute list.
	* src/RelLib/_Event.py: Add attribute list.



svn: r7180
This commit is contained in:
Alex Roitman
2006-08-15 05:24:38 +00:00
parent 1a02c853c0
commit 45d0d40c2b
5 changed files with 202 additions and 38 deletions

View File

@@ -34,6 +34,11 @@ class AttributeType(GrampsType):
NUM_CHILD = 5
SSN = 6
NICKNAME = 7
CAUSE = 8
AGENCY = 9
AGE = 10
FATHER_AGE = 11
MOTHER_AGE = 12
_CUSTOM = CUSTOM
_DEFAULT = ID
@@ -49,6 +54,11 @@ class AttributeType(GrampsType):
(SSN , _("Social Security Number"), "Social Security Number"),
(NUM_CHILD , _("Number of Children"), "Number of Children"),
(NICKNAME , _("Nickname"), "Nickname"),
(CAUSE , _("Cause"), "Cause"),
(AGENCY , _("Agency"), "Agency"),
(AGE , _("Age"), "Age"),
(FATHER_AGE , _("Father's Age"), "Father Age"),
(MOTHER_AGE , _("Mother's Age"), "Mother Age"),
]
_I2SMAP = init_map(_DATAMAP, 0, 1)

View File

@@ -33,6 +33,7 @@ from _PrimaryObject import PrimaryObject
from _SourceBase import SourceBase
from _NoteBase import NoteBase
from _MediaBase import MediaBase
from _AttributeBase import AttributeBase
from _DateBase import DateBase
from _PlaceBase import PlaceBase
from _EventType import EventType
@@ -42,7 +43,8 @@ from _EventType import EventType
# Event class
#
#-------------------------------------------------------------------------
class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase,
DateBase,PlaceBase):
"""
Introduction
============
@@ -63,17 +65,16 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
SourceBase.__init__(self,source)
NoteBase.__init__(self,source)
MediaBase.__init__(self,source)
AttributeBase.__init__(self)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
if source:
self.description = source.description
self.type = source.type
self.cause = source.cause
else:
self.description = ""
self.type = EventType()
self.cause = ""
def serialize(self):
"""
@@ -93,10 +94,11 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
"""
return (self.handle, self.gramps_id, self.type.serialize(),
DateBase.serialize(self),
self.description, self.place, self.cause,
self.description, self.place,
SourceBase.serialize(self),
NoteBase.serialize(self),
MediaBase.serialize(self),
AttributeBase.serialize(self),
self.change, self.marker.serialize(), self.private)
def unserialize(self,data):
@@ -109,14 +111,15 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@type data: tuple
"""
(self.handle, self.gramps_id, the_type, date,
self.description, self.place, self.cause,
source_list, note, media_list,
self.description, self.place,
source_list, note, media_list, attribute_list,
self.change, marker, self.private) = data
self.marker.unserialize(marker)
self.type.unserialize(the_type)
DateBase.unserialize(self,date)
MediaBase.unserialize(self,media_list)
AttributeBase.unserialize(self,attribute_list)
SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note)
@@ -140,9 +143,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.description,str(self.type),self.cause,self.gramps_id]
#return [self.description,self.type[1],self.cause,
# self.get_date(),self.gramps_id]
return [self.description,str(self.type),self.gramps_id]
def get_text_data_child_list(self):
"""
@@ -151,7 +152,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
check_list = self.media_list + self.source_list
check_list = self.media_list + self.source_list + self.attribute_list
if self.note:
check_list.append(self.note)
return check_list
@@ -163,7 +164,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
@return: Returns the list of child secondary child objects that may refer sources.
@rtype: list
"""
return self.media_list
return self.media_list + self.attribute_list
def get_referenced_handles(self):
"""
@@ -198,10 +199,9 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
date = self.get_date_object()
place = self.get_place_handle()
description = self.description
cause = self.cause
the_type = self.type
return (the_type == EventType.CUSTOM and date.is_empty()
and not place and not description and not cause)
and not place and not description)
def are_equal(self,other):
"""
@@ -217,7 +217,7 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
if self.type != other.type or \
((self.place or other.place) and (self.place != other.place)) or \
self.description != other.description or self.cause != other.cause \
self.description != other.description \
or self.private != other.private or \
(not self.get_date_object().is_equal(other.get_date_object())) or \
len(self.get_source_references()) != len(other.get_source_references()):
@@ -250,25 +250,6 @@ class Event(PrimaryObject,SourceBase,NoteBase,MediaBase,DateBase,PlaceBase):
"""
return self.type
def set_cause(self,cause):
"""
Sets the cause of the Event to the passed string. The string
may contain any information.
@param cause: Cause to assign to the Event
@type cause: str
"""
self.cause = cause
def get_cause(self):
"""
Returns the cause of the Event.
@return: Returns the cause of the Event
@rtype: str
"""
return self.cause
def set_description(self,description):
"""
Sets the description of the Event to the passed string. The string

View File

@@ -32,6 +32,7 @@ Event Reference class for GRAMPS
from _SecondaryObject import SecondaryObject
from _PrivacyBase import PrivacyBase
from _NoteBase import NoteBase
from _AttributeBase import AttributeBase
from _RefBase import RefBase
from _EventRoleType import EventRoleType
@@ -40,7 +41,7 @@ from _EventRoleType import EventRoleType
# Event References for Person/Family
#
#-------------------------------------------------------------------------
class EventRef(SecondaryObject,PrivacyBase,NoteBase,RefBase):
class EventRef(SecondaryObject,PrivacyBase,NoteBase,AttributeBase,RefBase):
"""
Event reference class.
@@ -55,6 +56,7 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,RefBase):
SecondaryObject.__init__(self)
PrivacyBase.__init__(self)
NoteBase.__init__(self)
AttributeBase.__init__(self)
RefBase.__init__(self)
if source:
self.role = source.role
@@ -65,14 +67,16 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,RefBase):
return (
PrivacyBase.serialize(self),
NoteBase.serialize(self),
AttributeBase.serialize(self),
RefBase.serialize(self),
self.role.serialize()
)
def unserialize(self,data):
(privacy,note,ref,role) = data
(privacy,note,attribute_list,ref,role) = data
PrivacyBase.unserialize(self,privacy)
NoteBase.unserialize(self,note)
AttributeBase.unserialize(self,attribute_list)
RefBase.unserialize(self,ref)
self.role.unserialize(role)
return self
@@ -93,9 +97,19 @@ class EventRef(SecondaryObject,PrivacyBase,NoteBase,RefBase):
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
check_list = self.attribute_list[:]
if self.note:
return [self.note]
return []
check_list.append(self.note)
return check_list
def get_sourcref_child_list(self):
"""
Returns the list of child secondary objects that may refer sources.
@return: Returns the list of child secondary child objects that may refer sources.
@rtype: list
"""
return self.attribute_list[:]
def get_referenced_handles(self):
"""