Notifier API
This module contains the core notification functionality.
- 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:
- icon
Path/URI to the notification icon.
- Type:
Methods:
- __init__()[source]
Initialize the GrowlNotifier with settings from Django configuration.
Reads the following settings:
GROWL_HOSTS- Required list of hostsGROWL_APP_NAME- Optional application nameGROWL_ENABLED- Optional enable/disable flagGROWL_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:
- 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:
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:
- Returns:
None
This is the main function you’ll use to send notifications from your code.
Icon Priority:
iconparameterGROWL_ICONenvironment variableGROWL_ICONsettingPackage 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')