savannah-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-cvs] [SCM] Savane-cleanup framework branch, master, updated. 1


From: Sylvain Beucler
Subject: [Savannah-cvs] [SCM] Savane-cleanup framework branch, master, updated. 13f44c2d03f645cb906dd1feaefdb890c7b57e77
Date: Wed, 29 Jul 2009 13:36:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Savane-cleanup framework".

The branch, master has been updated
       via  13f44c2d03f645cb906dd1feaefdb890c7b57e77 (commit)
      from  dc1a5cd96ded77638df05915c3718561f7cec003 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=13f44c2d03f645cb906dd1feaefdb890c7b57e77

commit 13f44c2d03f645cb906dd1feaefdb890c7b57e77
Author: Sylvain Beucler <address@hidden>
Date:   Wed Jul 29 15:36:26 2009 +0200

    Use batch-decoration to apply @login_required to all /my

diff --git a/src/savane/my/urls.py b/src/savane/my/urls.py
index 1c30dee..9fd2182 100644
--- a/src/savane/my/urls.py
+++ b/src/savane/my/urls.py
@@ -33,8 +33,27 @@ def only_mine(f):
         return f(request, queryset, *args, **kwargs)
     return _dec
 
-urlpatterns = patterns ('',
-  url(r'^$', login_required(direct_to_template),
+# Batch-decorator for urlpatterns
+# http://www.djangosnippets.org/snippets/532/
+from django.core.urlresolvers import RegexURLPattern
+class DecoratedURLPattern(RegexURLPattern):
+    def resolve(self, *args, **kwargs):
+        result = RegexURLPattern.resolve(self, *args, **kwargs)
+        if result:
+            result = list(result)
+            result[0] = self._decorate_with(result[0])
+        return result
+def decorated_patterns(prefix, func, *args):
+    result = patterns(prefix, *args)
+    if func:
+        for p in result:
+            if isinstance(p, RegexURLPattern):
+                p.__class__ = DecoratedURLPattern
+                p._decorate_with = func
+    return result
+
+urlpatterns = decorated_patterns ('', login_required,
+  url(r'^$', direct_to_template,
       { 'template' : 'my/index.html' },
       name='savane.my.views.index'),
   url('^conf/$', views.sv_conf),

-----------------------------------------------------------------------

Summary of changes:
 src/savane/my/urls.py |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
Savane-cleanup framework




reply via email to

[Prev in Thread] Current Thread [Next in Thread]