"""
$Id: note.py 27090 2005-07-26 21:34:13Z rmasse $
$URL: svn+ssh://svn/repos/trunk/dulcinea/lib/note.py $
"""

from dulcinea.attachable import Attachable
from dulcinea.base import DulcineaPersistent
from dulcinea.spec import any, require

class Note(DulcineaPersistent, Attachable):

    """
    Instance attributes:
       text: str
          Text for this note
    """

    text_is = any(str, None)

    def __init__(self, text=None):
        Attachable.__init__(self)
        self.set_text(text)

    def get_text(self):
        return self.text

    def set_text(self, text):
        require(text, self.text_is)
        self.text = text

    def is_empty(self):
        return not bool(self.text or self.get_attachments())

class Notable:

    """
    Instance attributes:
       note: Note
          a note with attachments
    """

    note_is = any(Note, None)

    def __init__(self, note=None):
        self.set_note(note)

    def set_note(self, note):
        require(note, self.note_is)
        self.note = note

    def get_note(self):
        return self.note
