Commits

Andy Mikhailenko committed fe21d0b

Added "breadcrumb" decorator (syntax sugar for the pre-existing approach).

  • Participants
  • Parent commits 344d281

Comments (0)

Files changed (3)

 \.pyc$
 \.mo$
 ^\.directory$
+^build/
+^dist/
+.egg-info

File navigation/__init__.py

 __author__  = 'Andy Mikhailenko'
 __license__ = 'GNU Lesser General Public License (GPL), Version 3'
 __url__     = 'http://bitbucket.org/neithere/django-navigation/'
-__version__ = '0.1.2'
+__version__ = '0.2.0'

File navigation/decorators.py

+# -*- coding: utf-8 -*-
+#
+#  Copyright (c) 2008-2009 Andy Mikhailenko and contributors
+#
+#  Django Navigation is free software under terms of the GNU Lesser
+#  General Public License version 3 (LGPLv3) as published by the Free
+#  Software Foundation. See the file README for copying conditions.
+#
+
+def breadcrumb(crumb):
+    """
+    Usage:
+
+        from navigation.decorators import breadcrumb
+
+        @breadcrumb('greeting')
+        def some_view(request):
+            return 'Hello world!'
+
+        @breadcrumb(lambda request: 'greeting for %s' % request.user.username)
+        def some_view(request):
+            return 'Hello %s!' % request.user.username
+    """
+    def wrapper(view):
+        def inner(request, *args, **kwargs):
+            return view(request, *args, **kwargs)
+        inner.navigation = crumb              # TODO: rename "navigation" to "breadcrumb"
+        return inner
+    return wrapper