'Virtual field for the project_activity table
@ToDo: Deprecate: replace with computed field'

@staticmethod
def project_activity_year(row):

    if hasattr(row, 'project_activity'):
        row = row.project_activity
    try:
        activity_id = row.id
    except AttributeError:
        return []
    if hasattr(row, 'date'):
        start_date = row.date
    else:
        start_date = False
    if hasattr(row, 'end_date'):
        end_date = row.end_date
    else:
        end_date = False
    if ((start_date is False) or (end_date is False)):
        s3db = current.s3db
        table = s3db.project_activity
        activity = current.db((table.id == activity_id)).select(table.date, table.end_date, cache=s3db.cache, limitby=(0, 1)).first()
        if activity:
            start_date = activity.date
            end_date = activity.end_date
    if ((not start_date) and (not end_date)):
        return []
    elif (not end_date):
        return [start_date.year]
    elif (not start_date):
        return [end_date.year]
    else:
        return list(xrange(start_date.year, (end_date.year + 1)))
