Package musicbrainz2 :: Module model :: Class Relation
[frames | no frames]

Type Relation

object --+
         |
        Relation


Represents a relation between two Entities.

There may be an arbitrary number of relations between all first class objects in MusicBrainz. The Relation itself has multiple attributes, which may or may not be used for a given relation type.

Note that a Relation object only contains the target but not the source end of the relation.

To Do: Add some examples.

Method Summary
  __init__(self, relationType, targetType, targetId, direction, attributes, beginDate, endDate, target)
Constructor.
  addAttribute(self, attribute)
Adds an attribute to the list.
  getAttributes(self)
Returns a list of attributes describing this relation.
  getBeginDate(self)
Returns the begin date.
  getDirection(self)
Returns the reading direction.
  getEndDate(self)
Returns the end date.
  getTarget(self)
Returns this relation's target object.
  getTargetId(self)
Returns the target's ID.
  getTargetType(self)
Returns the target's type.
  getType(self)
Returns this relation's type.
  setBeginDate(self, dateStr)
Sets the begin date.
  setDirection(self, direction)
Sets the reading direction.
  setEndDate(self, dateStr)
Sets the end date.
  setTarget(self, target)
Sets this relation's target object.
  setTargetId(self, targetId)
Sets the target's ID.
  setTargetType(self, targetType)
Sets the target's type.
  setType(self, type_)
Sets this relation's type.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  attributes: The list of attributes describing this relation.
  beginDate: The begin date.
  direction: The reading direction.
  endDate: The end date.
  target: The relation's target object.
  targetId: The type of target this relation points to.
  type: The relation's type.

Class Variable Summary
str DIR_BACKWARD: Relation reading direction is from target to source.
str DIR_BOTH: Relation reading direction doesn't matter.
str DIR_FORWARD: Relation reading direction is from source to target.
str TO_ARTIST: Identifies relations linking to an artist.
str TO_RELEASE: Identifies relations linking to a release.
str TO_TRACK: Identifies relations linking to a track.
str TO_URL: Identifies relations linking to an URL.

Method Details

__init__(self, relationType=None, targetType=None, targetId=None, direction='both', attributes=None, beginDate=None, endDate=None, target=None)
(Constructor)

Constructor.
Parameters:
relationType - a string containing an absolute URI
targetType - a string containing an absolute URI
targetId - a string containing an absolute URI
direction - one of Relation.DIR_FORWARD, Relation.DIR_BACKWARD, or Relation.DIR_BOTH
attributes - a list of strings containing absolute URIs
beginDate - a string containing a date
endDate - a string containing a date
target - an instance of a subclass of Entity
Overrides:
__builtin__.object.__init__

addAttribute(self, attribute)

Adds an attribute to the list.
Parameters:
attribute - a string containing an absolute URI

getAttributes(self)

Returns a list of attributes describing this relation.

The attributes permitted depend on the relation type.
Returns:
a list of strings containing absolute URIs

getBeginDate(self)

Returns the begin date.

The definition depends on the relation's type. It may for example be the day of a marriage or the year an artist joined a band. For other relation types this may be undefined.
Returns:
a string containing a date

getDirection(self)

Returns the reading direction.

The direction may be one of Relation.DIR_FORWARD, Relation.DIR_BACKWARD, or Relation.DIR_BOTH, depending on how the relation should be read. For example, if direction is Relation.DIR_FORWARD for a cover relation, it is read as "X is a cover of Y". Some relations are bidirectional, like marriages. In these cases, the direction is Relation.DIR_BOTH.
Returns:
Relation.DIR_FORWARD, Relation.DIR_BACKWARD, or Relation.DIR_BOTH

getEndDate(self)

Returns the end date.

As with the begin date, the definition depends on the relation's type. Depending on the relation type, this may or may not be defined.
Returns:
a string containing a date

See Also: getBeginDate

getTarget(self)

Returns this relation's target object.

Note that URL relations never have a target object. Use the getTargetId method to get the URL.
Returns:
a subclass of Entity, or None

getTargetId(self)

Returns the target's ID.

This is the ID the relation points to. It is an absolute URI, and in case of an URL relation, it is a URL.
Returns:
a string containing an absolute URI

getTargetType(self)

Returns the target's type.

For MusicBrainz data, the following target types are defined:
Returns:
a string containing an absolute URI

getType(self)

Returns this relation's type.
Returns:
a string containing an absolute URI, or None

setBeginDate(self, dateStr)

Sets the begin date.
Parameters:
dateStr - a string containing a date

See Also: getBeginDate

setDirection(self, direction)

Sets the reading direction.
Parameters:
direction - Relation.DIR_FORWARD, Relation.DIR_BACKWARD, or Relation.DIR_BOTH

See Also: getDirection

setEndDate(self, dateStr)

Sets the end date.
Parameters:
dateStr - a string containing a date

See Also: getBeginDate

setTarget(self, target)

Sets this relation's target object.

Note that URL relations never have a target object, they are set using setTargetId.
Parameters:
target - a subclass of Entity

setTargetId(self, targetId)

Sets the target's ID.
Parameters:
targetId - a string containing an absolute URI

See Also: getTargetId

setTargetType(self, targetType)

Sets the target's type.
Parameters:
targetType - a string containing an absolute URI

See Also: getTargetType

setType(self, type_)

Sets this relation's type.
Parameters:
type_ - a string containing an absolute URI

Property Details

attributes

The list of attributes describing this relation.
Get Method:
getAttributes(self)

beginDate

The begin date.
Get Method:
getBeginDate(self)
Set Method:
setBeginDate(self, dateStr)

direction

The reading direction.
Get Method:
getDirection(self)
Set Method:
setDirection(self, direction)

endDate

The end date.
Get Method:
getEndDate(self)
Set Method:
setEndDate(self, dateStr)

target

The relation's target object.
Get Method:
getTarget(self)
Set Method:
setTarget(self, target)

targetId

The type of target this relation points to.
Get Method:
getTargetId(self)
Set Method:
setTargetId(self, targetId)

type

The relation's type.
Get Method:
getType(self)
Set Method:
setType(self, type_)

Class Variable Details

DIR_BACKWARD

Relation reading direction is from target to source.
Type:
str
Value:
'backward'                                                             

DIR_BOTH

Relation reading direction doesn't matter.
Type:
str
Value:
'both'                                                                 

DIR_FORWARD

Relation reading direction is from source to target.
Type:
str
Value:
'forward'                                                              

TO_ARTIST

Identifies relations linking to an artist.
Type:
str
Value:
'http://musicbrainz.org/ns/rel-1.0#Artist'                             

TO_RELEASE

Identifies relations linking to a release.
Type:
str
Value:
'http://musicbrainz.org/ns/rel-1.0#Release'                            

TO_TRACK

Identifies relations linking to a track.
Type:
str
Value:
'http://musicbrainz.org/ns/rel-1.0#Track'                              

TO_URL

Identifies relations linking to an URL.
Type:
str
Value:
'http://musicbrainz.org/ns/rel-1.0#Url'                                

Generated by Epydoc 2.1 on Sat Aug 26 18:34:31 2006 http://epydoc.sf.net