The notify module

Notifications are generated when important changes to the SeaIce dictionary are made and relevant users neeed to be informed. For example, when the owner of a term modifies the definition, users who have voted on the term must be notified so that they can recast their vote if necessary. Another useful application of notifications is when users comment on your term. BaseNotification comprises the basis and requires at a minimum the time when the event occured and the surrogate ID of the term it pertains to. A few basic notifications are implemented here; undoubtedly more will prove to be useful.

Notifications are handled by the function seaice.user.User.notify(). There is a table and schema (SI_Notify.Notfiy) in the SeaIce database for persistent storage of notifications. insertNotifciation() and removeNotification() are called in seaice.user.User.notify() for handling insertion and deletion respectively. Note that this is meant to be optional, however; omitting the db_con parameter will skip this.

digraph inheritanced6000f55ea { rankdir=LR; size="8.0, 12.0"; "seaice.notify.BaseNotification" [style="setlinewidth(0.5)",URL="#seaice.notify.BaseNotification",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Base class for notifications in the SeaIce web interface Each sub class ",height=0.25,shape=box,fontsize=10]; "seaice.notify.Comment" [style="setlinewidth(0.5)",URL="#seaice.notify.Comment",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Notification object for comments. ",height=0.25,shape=box,fontsize=10]; "seaice.notify.BaseNotification" -> "seaice.notify.Comment" [arrowsize=0.5,style="setlinewidth(0.5)"]; "seaice.notify.TermRemoved" [style="setlinewidth(0.5)",URL="#seaice.notify.TermRemoved",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Notification object for term removals. ",height=0.25,shape=box,fontsize=10]; "seaice.notify.BaseNotification" -> "seaice.notify.TermRemoved" [arrowsize=0.5,style="setlinewidth(0.5)"]; "seaice.notify.TermUpdate" [style="setlinewidth(0.5)",URL="#seaice.notify.TermUpdate",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",tooltip="Notification object for term updates. ",height=0.25,shape=box,fontsize=10]; "seaice.notify.BaseNotification" -> "seaice.notify.TermUpdate" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

class seaice.notify.BaseNotification(term_id, T_notify)[source]

Base class for notifications in the SeaIce web interface Each sub class should implement __init__(), __str__(), and getAsHTML(db_con) This data structure only stores surrogate keys for users, terms, and comments. so that a notification is never inconsistent. As a result, getAsHTML causes a query to the DB.

Parameters:
  • term_id (int) – Term ID.
  • T_notify (datetime.datetime) – The time at which the notification was produced.
getAsHTML(db_con)[source]

Return an HTML-formatted notification string. To avoid dereferencing something that has been deleted (term, comment, user, etc.), return None if the database has no results.

Parameters:db_con (seaice.SeaIceConnector.SeaIceConnector) – Connection to database.
Return type:str or None
getAsPlaintext(db_con)[source]

Return a notification string. To avoid dereferencing something that has been deleted (term, comment, user, etc.), return None if the database has no results.

Parameters:db_con (seaice.SeaIceConnector.SeaIceConnector) – Connection to database.
Return type:str or None
class seaice.notify.Comment(term_id, user_id, comment_string, T_notify)[source]

Bases: seaice.notify.BaseNotification

Notification object for comments.

Parameters:
  • term_id (int) – Term ID.
  • user_id (int) – ID of the user has commented on a term.
  • T_notify (datetime.datetime) – The time at which the notification was produced.
class seaice.notify.TermUpdate(term_id, user_id, T_notify)[source]

Bases: seaice.notify.BaseNotification

Notification object for term updates.

Parameters:
  • term_id (int) – Term ID.
  • user_id (int) – ID of the user who has updated the term.
  • T_notify (datetime.datetime) – The time at which the notification was produced.
class seaice.notify.TermRemoved(user_id, term_string, T_notify)[source]

Bases: seaice.notify.BaseNotification

Notification object for term removals.

Parameters:
  • user_id (int) – ID of the user who has updated the term.
  • term_string (str) – Term string before the term was deleted. We can’t use the ID since it has been removed from the database.
  • T_notify (datetime.datetime) – The time at which the notification was produced.

Previous topic

The auth module

Next topic

The pretty module

This Page