Notifier API

This module contains the core notification functionality.

class django_growl.notifier.GrowlNotifier[source]

Bases: object

__init__()[source]
notify(title, message, note_type='Info', sticky=False, icon=None)[source]

Send notification to all Growl hosts

django_growl.notifier.get_growl_notifier()[source]
django_growl.notifier.send_notification(title, message, note_type='Info', sticky=False, icon=None)[source]

Helper function to send notifications

Parameters:
  • title – Notification title

  • message – Message content

  • note_type – Notification type (‘Info’, ‘Error’, ‘Server Status’)

  • sticky – Whether the notification stays visible (True/False)

  • icon – Icon file path or URI (file://, http[s]://)

Classes

GrowlNotifier

class django_growl.notifier.GrowlNotifier[source]

Main class for managing Growl notifications.

Attributes:

growl_hosts

List of configured Growl host addresses.

Type:

list

app_name

Application name shown in Growl.

Type:

str

enabled

Whether notifications are enabled.

Type:

bool

icon

Path/URI to the notification icon.

Type:

pathlib.Path

notifiers

List of registered GNTP notifiers.

Type:

list

Methods:

__init__()[source]

Initialize the GrowlNotifier with settings from Django configuration.

Reads the following settings:

  • GROWL_HOSTS - Required list of hosts

  • GROWL_APP_NAME - Optional application name

  • GROWL_ENABLED - Optional enable/disable flag

  • GROWL_ICON - Optional icon path

Automatically registers with all configured Growl hosts.

notify(title, message, note_type='Info', sticky=False, icon=None)[source]

Send notification to all Growl hosts

Send a notification to all registered Growl hosts.

Parameters:
  • title (str) – Notification title

  • message (str) – Notification message body

  • note_type (str) – Type of notification (‘Info’, ‘Error’, ‘Server Status’)

  • sticky (bool) – Whether notification should stay visible until dismissed

  • icon (str or None) – Custom icon for this notification (overrides default)

Returns:

None

Example:

notifier = GrowlNotifier()
notifier.notify(
    title="Task Complete",
    message="Processing finished",
    note_type='Info',
    sticky=False,
    icon='/path/to/icon.png'
)
__init__()[source]
notify(title, message, note_type='Info', sticky=False, icon=None)[source]

Send notification to all Growl hosts

Functions

get_growl_notifier

django_growl.notifier.get_growl_notifier()[source]

Get or create the singleton GrowlNotifier instance.

Returns:

Singleton GrowlNotifier instance

Return type:

GrowlNotifier

This function ensures only one notifier instance exists throughout the application lifecycle. Subsequent calls return the same instance.

Example:

from django_growl import get_growl_notifier

notifier = get_growl_notifier()
if notifier.enabled:
    notifier.notify("Hello", "World")

send_notification

django_growl.notifier.send_notification(title, message, note_type='Info', sticky=False, icon=None)[source]

Helper function to send notifications

Parameters:
  • title – Notification title

  • message – Message content

  • note_type – Notification type (‘Info’, ‘Error’, ‘Server Status’)

  • sticky – Whether the notification stays visible (True/False)

  • icon – Icon file path or URI (file://, http[s]://)

Send a notification using the singleton GrowlNotifier.

Parameters:
  • title (str) – Notification title

  • message (str) – Notification message

  • note_type (str) – Notification type (‘Info’, ‘Error’, ‘Server Status’)

  • sticky (bool) – Keep notification visible until dismissed

  • icon (str, pathlib.Path, or None) – Icon path/URI (optional)

Returns:

None

This is the main function you’ll use to send notifications from your code.

Icon Priority:

  1. icon parameter

  2. GROWL_ICON environment variable

  3. GROWL_ICON setting

  4. Package default icon

Example:

from django_growl import send_notification

# Basic notification
send_notification("Task Done", "Completed successfully")

# With all options
send_notification(
    title="Error Occurred",
    message="Database connection failed",
    note_type='Error',
    sticky=True,
    icon='/path/to/error-icon.png'
)

Constants

Notification Types

The following notification types are available:

  • 'Info' - General information notifications (default)

  • 'Error' - Error notifications

  • 'Server Status' - Server status notifications

Example usage:

send_notification("Info", "Process started", note_type='Info')
send_notification("Error", "Process failed", note_type='Error')
send_notification("Status", "Server restarted", note_type='Server Status')