Author: leidel
Date: Wed Jan 21 00:58:50 2009
New Revision: 141

Modified:
    wiki/IntegratingNotification.wiki

Log:
Edited wiki page through web user interface.

Modified: wiki/IntegratingNotification.wiki
==============================================================================
--- wiki/IntegratingNotification.wiki   (original)
+++ wiki/IntegratingNotification.wiki   Wed Jan 21 00:58:50 2009
@@ -20,18 +20,17 @@


  {{{
-from django.db.models import signals, get_app
-from django.core.exceptions import ImproperlyConfigured
+from django.conf import settings

-try:
-    notification = get_app('notification')
+if "notification" in settings.INSTALLED_APPS:
+    from notification.models import create_notice_type

      def create_notice_types(app, created_models, verbosity, **kwargs):
-        notification.create_notice_type("friends_invite", "Invitation  
Received", "you have received an invitation")
-        notification.create_notice_type("friends_accept", "Acceptance  
Received", "an invitation you sent has been accepted")
+        create_notice_type("friends_invite", "Invitation Received", "you  
have received an invitation")
+        create_notice_type("friends_accept", "Acceptance Received", "an  
invitation you sent has been accepted")

      signals.post_syncdb.connect(create_notice_types, sender=notification)
-except ImproperlyConfigured:
+else:
      print "Skipping creation of NoticeTypes as notification app not found"
  }}}

@@ -53,18 +52,17 @@

  `issue_notice` is `True` by default but you can set it to `False` if you  
want a notification sent but not persisted as a `Notice` object in the  
database.

-To allow your app to still function without notification, you can wrap  
your import in a try clause and test that the notification app has been  
successfully installed in Django's internal app cache before sending a  
notice.
+In case you want to use django-notification in your reusable app, you can  
wrap the import of django-notification in a conditional clause that tests  
if it's installed before sending a notice. As a result your app or project  
still functions without notification.

  For example:

  {{{
-from django.db.models import get_app
-from django.core.exceptions import ImproperlyConfigured
+from django.conf import settings

-try:
-    notification = get_app('notification')
-except ImproperlyConfigured:
-    notification = None
+if "notification" in settings.INSTALLED_APPS:
+    from notification import models as notification
+else:
+   notification = None
  }}}

  and then, later:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to