Author: leidel
Date: Sat Jan  3 17:18:42 2009
New Revision: 128

Modified:
    trunk/docs/usage.txt

Log:
Updated docs to use Django's app cache to detect if notification is  
installed

Modified: trunk/docs/usage.txt
==============================================================================
--- trunk/docs/usage.txt        (original)
+++ trunk/docs/usage.txt        Sat Jan  3 17:18:42 2009
@@ -26,17 +26,18 @@
  ``management.py`` file for your app, attached to the syncdb signal.
  Here is an example::

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

  Notice that the code is wrapped in a try clause so if django-notification  
is
@@ -135,9 +136,12 @@

  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

  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