Exemplo n.º 1
0
    def __init__(self,
                 object_id,
                 revision=None,
                 notebook_id=None,
                 user_id=None,
                 name=None,
                 description=None,
                 value=None):
        """
    Create a Tag with the given id.

    @type object_id: unicode
    @param object_id: id of the Tag
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook whose namespace this tag is in, if any
    @type user_id: unicode or NoneType
    @param user_id: id of the user who most recently updated this tag, if any
    @type name: unicode or NoneType
    @param name: name of the tag (optional)
    @type description: unicode or NoneType
    @param description: brief description of the tag (optional)
    @type value: unicode or NoneType
    @param value: per-note or per-notebook value of the tag (optional)
    @rtype: Tag
    @return: newly constructed Tag
    """
        Persistent.__init__(self, object_id, revision)
        self.__notebook_id = notebook_id
        self.__user_id = user_id
        self.__name = name
        self.__description = description
        self.__value = value
Exemplo n.º 2
0
  def __init__( self, object_id, revision = None, notebook_id = None, note_id = None,
                filename = None, size_bytes = None, content_type = None ):
    """
    Create a File with the given id.

    @type object_id: unicode
    @param object_id: id of the File
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook containing the file
    @type note_id: unicode or NoneType
    @param note_id: id of the note linking to the file
    @type filename: unicode
    @param filename: name of the file on the client
    @type size_bytes: int
    @param size_bytes: length of the file data in bytes
    @type content_type: unicode
    @param content_type: value of the Content-Type HTTP header for this file
    @rtype: File
    @return: newly constructed File
    """
    Persistent.__init__( self, object_id, revision )
    self.__notebook_id = notebook_id
    self.__note_id = note_id
    self.__filename = filename
    self.__size_bytes = size_bytes
    self.__content_type = content_type
Exemplo n.º 3
0
  def __init__( self, object_id, revision = None, notebook_id = None, user_id = None, name = None, description = None, value = None ):
    """
    Create a Tag with the given id.

    @type object_id: unicode
    @param object_id: id of the Tag
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook whose namespace this tag is in, if any
    @type user_id: unicode or NoneType
    @param user_id: id of the user who most recently updated this tag, if any
    @type name: unicode or NoneType
    @param name: name of the tag (optional)
    @type description: unicode or NoneType
    @param description: brief description of the tag (optional)
    @type value: unicode or NoneType
    @param value: per-note or per-notebook value of the tag (optional)
    @rtype: Tag
    @return: newly constructed Tag
    """
    Persistent.__init__( self, object_id, revision )
    self.__notebook_id = notebook_id
    self.__user_id = user_id
    self.__name = name
    self.__description = description
    self.__value = value
Exemplo n.º 4
0
    def __init__(self,
                 object_id,
                 revision=None,
                 notebook_id=None,
                 note_id=None,
                 filename=None,
                 size_bytes=None,
                 content_type=None):
        """
    Create a File with the given id.

    @type object_id: unicode
    @param object_id: id of the File
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook containing the file
    @type note_id: unicode or NoneType
    @param note_id: id of the note linking to the file
    @type filename: unicode
    @param filename: name of the file on the client
    @type size_bytes: int
    @param size_bytes: length of the file data in bytes
    @type content_type: unicode
    @param content_type: value of the Content-Type HTTP header for this file
    @rtype: File
    @return: newly constructed File
    """
        Persistent.__init__(self, object_id, revision)
        self.__notebook_id = notebook_id
        self.__note_id = note_id
        self.__filename = filename
        self.__size_bytes = size_bytes
        self.__content_type = content_type
Exemplo n.º 5
0
  def __init__( self, object_id, revision = None, username = None, salt = None, password_hash = None,
                email_address = None, storage_bytes = None, rate_plan = None ):
    """
    Create a new user with the given credentials and information.

    @type object_id: unicode
    @param object_id: id of the user
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type username: unicode or NoneType
    @param username: unique user identifier for login purposes (optional)
    @type salt: unicode or NoneType
    @param salt: salt to use when hashing the password (optional, defaults to random)
    @type password_hash: unicode or NoneType
    @param password_hash: cryptographic hash of secret password for login purposes (optional)
    @type email_address: unicode or NoneType
    @param email_address: a hopefully valid email address (optional)
    @type storage_bytes: int or NoneType
    @param storage_bytes: count of bytes that the user is currently using for storage (optional)
    @type rate_plan: int or NoneType
    @param rate_plan: index into the rate plan array in config/Common.py (optional, defaults to 0)
    @rtype: User
    @return: newly created user
    """
    Persistent.__init__( self, object_id, revision )
    self.__username = username
    self.__salt = salt
    self.__password_hash = password_hash
    self.__email_address = email_address
    self.__storage_bytes = storage_bytes or 0
    self.__group_storage_bytes = 0
    self.__rate_plan = rate_plan or 0
Exemplo n.º 6
0
  def __init__( self, object_id, revision = None, from_user_id = None, notebook_id = None,
                email_address = None, read_write = False, owner = False, redeemed_user_id = None,
                redeemed_username = None ):
    """
    Create an invitation with the given id.

    @type object_id: unicode
    @param object_id: id of the invitation
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type from_user_id: unicode or NoneType
    @param from_user_id: id of the user who sent the invite (optional)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook that the invitation is for
    @type email_address: unicode or NoneType
    @param email_address: where the invitation was emailed (optional)
    @type read_write: bool or NoneType
    @param read_write: whether the invitation is for read-write access (optional, defaults to False)
    @type owner: bool or NoneType
    @param owner: whether the invitation is for owner-level access (optional, defaults to False)
    @type redeemed_user_id: unicode or NoneType
    @param redeemed_user_id: id of the user who has redeemed this invitation, if any (optional)
    @type redeemed_username: unicode or NoneType
    @param redeemed_username: username of the user who has redeemed this invitation, if any (optional)
    @rtype: Invite
    @return: newly constructed notebook invitation
    """
    Persistent.__init__( self, object_id, revision )
    self.__from_user_id = from_user_id
    self.__notebook_id = notebook_id
    self.__email_address = email_address
    self.__read_write = read_write
    self.__owner = owner
    self.__redeemed_user_id = redeemed_user_id
    self.__redeemed_username = redeemed_username
Exemplo n.º 7
0
  def __init__( self, object_id, revision = None, name = None, trash_id = None, deleted = False,
                user_id = None, read_write = None, owner = True, rank = None, own_notes_only = False, note_count = None ):
    """
    Create a new notebook with the given id and name.

    @type object_id: unicode
    @param object_id: id of the notebook
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type name: unicode or NoneType
    @param name: name of this notebook (optional)
    @type trash_id: Notebook or NoneType
    @param trash_id: id of the notebook where deleted notes from this notebook go to die (optional)
    @type deleted: bool or NoneType
    @param deleted: whether this notebook is currently deleted (optional, defaults to False)
    @type user_id: unicode or NoneType
    @param user_id: id of the user who most recently updated this notebook object (optional)
    @type read_write: bool or NoneType
    @param read_write: whether this view of the notebook is currently read-write. one of:
                       READ_ONLY, READ_WRITE, READ_WRITE_FOR_OWN_NOTES (optional, defaults to READ_WRITE)
    @type owner: bool or NoneType
    @param owner: whether this view of the notebook currently has owner-level access (optional, defaults to True)
    @type rank: float or NoneType
    @param rank: indicates numeric ordering of this note in relation to other notebooks
    @type own_notes_only: bool or NoneType
    @param own_notes_only: True makes read_write be READ_WRITE_FOR_OWN_NOTES (optional, defaults to False)
    @type note_count: int or NoneType
    @param note_count: a count of the number of notes within this notebook (optional)
    @rtype: Notebook
    @return: newly constructed notebook
    """
    Persistent.__init__( self, object_id, revision )
    self.__name = name
    self.__trash_id = trash_id
    self.__deleted = deleted
    self.__user_id = user_id

    read_write = {
      None: Notebook.READ_WRITE,
      True: Notebook.READ_WRITE,
      False: Notebook.READ_ONLY,
    }.get( read_write, read_write )

    if own_notes_only is True and read_write != Notebook.READ_ONLY:
      read_write = Notebook.READ_WRITE_FOR_OWN_NOTES

    self.__read_write = read_write
    self.__owner = owner
    self.__rank = rank
    self.__note_count = note_count
    self.__tags = []
Exemplo n.º 8
0
  def to_dict( self ):
    d = Persistent.to_dict( self )

    d.update( dict(
      name = self.__name,
      admin = self.__admin,
    ) )

    return d
Exemplo n.º 9
0
  def __init__( self, object_id, revision = None, name = None, admin = None ):
    """
    Create a new group with the given id and name.

    @type object_id: unicode
    @param object_id: id of the group
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type name: unicode or NoneType
    @param name: name of this group (optional)
    @type admin: bool
    @param admin: whether access to this group includes admin capabilities
    @rtype: Group
    @return: newly constructed group
    """
    Persistent.__init__( self, object_id, revision )
    self.__name = name
    self.__admin = admin
Exemplo n.º 10
0
  def __init__( self, object_id, revision = None, email_address = None, redeemed = False ):
    """
    Create a password reset request with the given id.

    @type object_id: unicode
    @param object_id: id of the password reset
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type email_address: unicode or NoneType
    @param email_address: where the reset confirmation was emailed (optional)
    @type redeemed: bool or NoneType
    @param redeemed: whether this password reset has been redeemed yet (optional, defaults to False)
    @rtype: Password_reset
    @return: newly constructed password reset
    """
    Persistent.__init__( self, object_id, revision )
    self.__email_address = email_address
    self.__redeemed = redeemed
Exemplo n.º 11
0
  def __init__( self, object_id, revision = None, title = None, contents = None, notebook_id = None,
                startup = None, deleted_from_id = None, rank = None, user_id = None,
                username = None, creation = None, summary = None ):
    """
    Create a new note with the given id and contents.

    @type object_id: unicode
    @param object_id: id of the note
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type title: unicode or NoneType
    @param title: textual title of the note (optional, defaults to derived from contents)
    @type contents: unicode or NoneType
    @param contents: HTML contents of the note (optional)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of notebook containing this note (optional)
    @type startup: bool or NoneType
    @param startup: whether this note should be displayed upon startup (optional, defaults to False)
    @type deleted_from_id: unicode or NoneType
    @param deleted_from_id: id of the notebook that this note was deleted from (optional)
    @type rank: float or NoneType
    @param rank: indicates numeric ordering of this note in relation to other startup notes
    @type user_id: unicode or NoneType
    @param user_id: id of the user who most recently updated this note object (optional)
    @type username: unicode or NoneType
    @param username: username of the user who most recently updated this note object (optional)
    @type creation: datetime or NoneType
    @param creation: creation timestamp of the object (optional, defaults to None)
    @type summary: unicode or NoneType
    @param summary: textual summary of the note's contents (optional, defaults to None)
    @rtype: Note
    @return: newly constructed note
    """
    Persistent.__init__( self, object_id, revision )
    self.__title = title
    self.__contents = contents
    self.__summary = summary
    self.__notebook_id = notebook_id
    self.__startup = startup or False
    self.__deleted_from_id = deleted_from_id
    self.__rank = rank
    self.__user_id = user_id
    self.__username = username
    self.__creation = creation
Exemplo n.º 12
0
    def __init__(self, object_id, revision=None, item_number=None, transaction_id=None):
        """
    Create a download access record with the given id.

    @type object_id: unicode
    @param object_id: id of the download access
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type item_number: unicode or NoneType
    @param item_number: number of the item to which download access is granted (optional)
    @type transaction_id: unicode or NoneType
    @param transaction_id: payment processor id for the transaction used to pay for this download
                           (optional)
    @rtype: Download_access
    @return: newly constructed download access object
    """
        Persistent.__init__(self, object_id, revision)
        self.__item_number = item_number
        self.__transaction_id = transaction_id
Exemplo n.º 13
0
    def __init__(self,
                 object_id,
                 revision=None,
                 from_user_id=None,
                 notebook_id=None,
                 email_address=None,
                 read_write=False,
                 owner=False,
                 redeemed_user_id=None,
                 redeemed_username=None):
        """
    Create an invitation with the given id.

    @type object_id: unicode
    @param object_id: id of the invitation
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type from_user_id: unicode or NoneType
    @param from_user_id: id of the user who sent the invite (optional)
    @type notebook_id: unicode or NoneType
    @param notebook_id: id of the notebook that the invitation is for
    @type email_address: unicode or NoneType
    @param email_address: where the invitation was emailed (optional)
    @type read_write: bool or NoneType
    @param read_write: whether the invitation is for read-write access (optional, defaults to False)
    @type owner: bool or NoneType
    @param owner: whether the invitation is for owner-level access (optional, defaults to False)
    @type redeemed_user_id: unicode or NoneType
    @param redeemed_user_id: id of the user who has redeemed this invitation, if any (optional)
    @type redeemed_username: unicode or NoneType
    @param redeemed_username: username of the user who has redeemed this invitation, if any (optional)
    @rtype: Invite
    @return: newly constructed notebook invitation
    """
        Persistent.__init__(self, object_id, revision)
        self.__from_user_id = from_user_id
        self.__notebook_id = notebook_id
        self.__email_address = email_address
        self.__read_write = read_write
        self.__owner = owner
        self.__redeemed_user_id = redeemed_user_id
        self.__redeemed_username = redeemed_username
Exemplo n.º 14
0
  def to_dict( self ):
    d = Persistent.to_dict( self )
    d.update( dict(
      notebook_id = self.__notebook_id,
      note_id = self.__note_id,
      filename = self.__filename,
      size_bytes = self.__size_bytes,
      content_type = self.__content_type,
    ) )

    return d
Exemplo n.º 15
0
  def to_dict( self ):
    d = Persistent.to_dict( self )
    d.update( dict(
      username = self.username,
      email_address = self.__email_address,
      storage_bytes = self.__storage_bytes,
      group_storage_bytes = self.__group_storage_bytes,
      rate_plan = self.__rate_plan,
    ) )

    return d
Exemplo n.º 16
0
  def to_dict( self ):
    d = Persistent.to_dict( self )
    d.update( dict(
      notebook_id = self.__notebook_id,
      user_id = self.__user_id,
      name = self.__name,
      description = self.__description,
      value = self.__value,
    ) )

    return d
Exemplo n.º 17
0
    def to_dict(self):
        d = Persistent.to_dict(self)
        d.update(
            dict(
                notebook_id=self.__notebook_id,
                user_id=self.__user_id,
                name=self.__name,
                description=self.__description,
                value=self.__value,
            ))

        return d
Exemplo n.º 18
0
    def to_dict(self):
        d = Persistent.to_dict(self)
        d.update(
            dict(
                username=self.username,
                email_address=self.__email_address,
                storage_bytes=self.__storage_bytes,
                group_storage_bytes=self.__group_storage_bytes,
                rate_plan=self.__rate_plan,
            ))

        return d
Exemplo n.º 19
0
    def to_dict(self):
        d = Persistent.to_dict(self)
        d.update(
            dict(
                notebook_id=self.__notebook_id,
                note_id=self.__note_id,
                filename=self.__filename,
                size_bytes=self.__size_bytes,
                content_type=self.__content_type,
            ))

        return d
Exemplo n.º 20
0
    def __init__(self,
                 object_id,
                 revision=None,
                 username=None,
                 salt=None,
                 password_hash=None,
                 email_address=None,
                 storage_bytes=None,
                 rate_plan=None):
        """
    Create a new user with the given credentials and information.

    @type object_id: unicode
    @param object_id: id of the user
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type username: unicode or NoneType
    @param username: unique user identifier for login purposes (optional)
    @type salt: unicode or NoneType
    @param salt: salt to use when hashing the password (optional, defaults to random)
    @type password_hash: unicode or NoneType
    @param password_hash: cryptographic hash of secret password for login purposes (optional)
    @type email_address: unicode or NoneType
    @param email_address: a hopefully valid email address (optional)
    @type storage_bytes: int or NoneType
    @param storage_bytes: count of bytes that the user is currently using for storage (optional)
    @type rate_plan: int or NoneType
    @param rate_plan: index into the rate plan array in config/Common.py (optional, defaults to 0)
    @rtype: User
    @return: newly created user
    """
        Persistent.__init__(self, object_id, revision)
        self.__username = username
        self.__salt = salt
        self.__password_hash = password_hash
        self.__email_address = email_address
        self.__storage_bytes = storage_bytes or 0
        self.__group_storage_bytes = 0
        self.__rate_plan = rate_plan or 0
Exemplo n.º 21
0
    def __init__(self,
                 object_id,
                 revision=None,
                 email_address=None,
                 redeemed=False):
        """
    Create a password reset request with the given id.

    @type object_id: unicode
    @param object_id: id of the password reset
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type email_address: unicode or NoneType
    @param email_address: where the reset confirmation was emailed (optional)
    @type redeemed: bool or NoneType
    @param redeemed: whether this password reset has been redeemed yet (optional, defaults to False)
    @rtype: Password_reset
    @return: newly constructed password reset
    """
        Persistent.__init__(self, object_id, revision)
        self.__email_address = email_address
        self.__redeemed = redeemed
Exemplo n.º 22
0
  def to_dict( self ):
    d = Persistent.to_dict( self )
    d.update( dict(
      from_user_id = self.__from_user_id,
      notebook_id = self.__notebook_id,
      email_address = self.__email_address,
      read_write = self.__read_write,
      owner = self.__owner,
      redeemed_user_id = self.__redeemed_user_id,
      redeemed_username = self.__redeemed_username,
    ) )

    return d
Exemplo n.º 23
0
    def __init__(self,
                 object_id,
                 revision=None,
                 item_number=None,
                 transaction_id=None):
        """
    Create a download access record with the given id.

    @type object_id: unicode
    @param object_id: id of the download access
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type item_number: unicode or NoneType
    @param item_number: number of the item to which download access is granted (optional)
    @type transaction_id: unicode or NoneType
    @param transaction_id: payment processor id for the transaction used to pay for this download
                           (optional)
    @rtype: Download_access
    @return: newly constructed download access object
    """
        Persistent.__init__(self, object_id, revision)
        self.__item_number = item_number
        self.__transaction_id = transaction_id
Exemplo n.º 24
0
    def to_dict(self):
        d = Persistent.to_dict(self)
        d.update(
            dict(
                from_user_id=self.__from_user_id,
                notebook_id=self.__notebook_id,
                email_address=self.__email_address,
                read_write=self.__read_write,
                owner=self.__owner,
                redeemed_user_id=self.__redeemed_user_id,
                redeemed_username=self.__redeemed_username,
            ))

        return d
Exemplo n.º 25
0
  def to_dict( self ):
    d = Persistent.to_dict( self )
    d.update( dict(
      contents = self.__contents,
      summary = self.__summary,
      notebook_id = self.__notebook_id,
      title = self.__title,
      deleted_from_id = self.__deleted_from_id,
      user_id = self.__user_id,
      username = self.__username,
      creation = self.__creation,
    ) )

    return d
Exemplo n.º 26
0
  def to_dict( self ):
    d = Persistent.to_dict( self )

    d.update( dict(
      name = self.__name,
      friendly_id = self.friendly_id,
      trash_id = self.__trash_id,
      read_write = self.__read_write,
      owner = self.__owner,
      deleted = self.__deleted,
      user_id = self.__user_id,
      note_count = self.__note_count,
      tags = self.__tags,
    ) )

    return d
Exemplo n.º 27
0
    def to_dict(self):
        d = Persistent.to_dict(self)

        d.update(
            dict(
                name=self.__name,
                friendly_id=self.friendly_id,
                trash_id=self.__trash_id,
                read_write=self.__read_write,
                owner=self.__owner,
                deleted=self.__deleted,
                user_id=self.__user_id,
                note_count=self.__note_count,
                tags=self.__tags,
            ))

        return d
Exemplo n.º 28
0
    def __init__(self,
                 object_id,
                 revision=None,
                 name=None,
                 trash_id=None,
                 deleted=False,
                 user_id=None,
                 read_write=None,
                 owner=True,
                 rank=None,
                 own_notes_only=False,
                 note_count=None):
        """
    Create a new notebook with the given id and name.

    @type object_id: unicode
    @param object_id: id of the notebook
    @type revision: datetime or NoneType
    @param revision: revision timestamp of the object (optional, defaults to now)
    @type name: unicode or NoneType
    @param name: name of this notebook (optional)
    @type trash_id: Notebook or NoneType
    @param trash_id: id of the notebook where deleted notes from this notebook go to die (optional)
    @type deleted: bool or NoneType
    @param deleted: whether this notebook is currently deleted (optional, defaults to False)
    @type user_id: unicode or NoneType
    @param user_id: id of the user who most recently updated this notebook object (optional)
    @type read_write: bool or NoneType
    @param read_write: whether this view of the notebook is currently read-write. one of:
                       READ_ONLY, READ_WRITE, READ_WRITE_FOR_OWN_NOTES (optional, defaults to READ_WRITE)
    @type owner: bool or NoneType
    @param owner: whether this view of the notebook currently has owner-level access (optional, defaults to True)
    @type rank: float or NoneType
    @param rank: indicates numeric ordering of this note in relation to other notebooks
    @type own_notes_only: bool or NoneType
    @param own_notes_only: True makes read_write be READ_WRITE_FOR_OWN_NOTES (optional, defaults to False)
    @type note_count: int or NoneType
    @param note_count: a count of the number of notes within this notebook (optional)
    @rtype: Notebook
    @return: newly constructed notebook
    """
        Persistent.__init__(self, object_id, revision)
        self.__name = name
        self.__trash_id = trash_id
        self.__deleted = deleted
        self.__user_id = user_id

        read_write = {
            None: Notebook.READ_WRITE,
            True: Notebook.READ_WRITE,
            False: Notebook.READ_ONLY,
        }.get(read_write, read_write)

        if own_notes_only is True and read_write != Notebook.READ_ONLY:
            read_write = Notebook.READ_WRITE_FOR_OWN_NOTES

        self.__read_write = read_write
        self.__owner = owner
        self.__rank = rank
        self.__note_count = note_count
        self.__tags = []