Author: leidel
Date: Sat Jan  3 16:56:41 2009
New Revision: 127

Modified:
    wiki/IntegratingNotification.wiki

Log:
Edited wiki page through web user interface.

Modified: wiki/IntegratingNotification.wiki
==============================================================================
--- wiki/IntegratingNotification.wiki   (original)
+++ wiki/IntegratingNotification.wiki   Sat Jan  3 16:56:41 2009
@@ -20,17 +20,18 @@


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

  try:
-    from notification import models as notification
+    notification = get_app('notification')

      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")

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

@@ -52,14 +53,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 module has been loaded before  
sending a notice.
+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.

  For example:

  {{{
+from django.db.models import get_app
+from django.core.exceptions import ImproperlyConfigured
+
  try:
-    from notification import models as notification
-except ImportError:
+    notification = get_app('notification')
+except ImproperlyConfigured:
      notification = None
  }}}


--~--~---------~--~----~------------~-------~--~----~
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