'Compute the age of a person
@param row: a Row containing the person record
@return: age in years (integer)'

@staticmethod
def pr_age(row):

    if hasattr(row, 'pr_person'):
        row = row.pr_person
    if hasattr(row, 'date_of_birth'):
        dob = row.date_of_birth
    elif hasattr(row, 'id'):
        table = current.s3db.pr_person
        person = current.db((table.id == row.id)).select(table.date_of_birth, limitby=(0, 1)).first()
        dob = (person.date_of_birth if person else None)
    else:
        dob = None
    if dob:
        from dateutil.relativedelta import relativedelta
        return relativedelta(current.request.utcnow.date(), dob).years
    else:
        return None
