summaryrefslogtreecommitdiffstats
path: root/.emacs.d/snippets/python-mode/permission_guard
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-08-13 22:20:08 +0200
committerGravatar Tom Willemse2013-08-13 22:20:08 +0200
commitaaa9e1a953d8db0e974db9b09b2fe0b19751e3d9 (patch)
treee6c880a904ad0bdd2a697b4e4bea669ee0aa1499 /.emacs.d/snippets/python-mode/permission_guard
downloademacs-aaa9e1a953d8db0e974db9b09b2fe0b19751e3d9.tar.gz
emacs-aaa9e1a953d8db0e974db9b09b2fe0b19751e3d9.zip
Initial commit of my Emacs configuration in vcsh
Diffstat (limited to '.emacs.d/snippets/python-mode/permission_guard')
-rw-r--r--.emacs.d/snippets/python-mode/permission_guard9
1 files changed, 9 insertions, 0 deletions
diff --git a/.emacs.d/snippets/python-mode/permission_guard b/.emacs.d/snippets/python-mode/permission_guard
new file mode 100644
index 0000000..ab53895
--- /dev/null
+++ b/.emacs.d/snippets/python-mode/permission_guard
@@ -0,0 +1,9 @@
+# -*- mode: snippet -*-
+# name: Permission guard
+# key: defm
+# --
+@method_decorator(permission_required('$1',
+ raise_exception=True))
+def dispatch(self, *args, **kwargs):
+ '''Make sure the user has the $1 permission.'''
+ return super(${3:`(progn (re-search-backward "^[ \t]*class \\(.+\\)(") (match-string 1)))`}, self).dispatch(*args, **kwargs) \ No newline at end of file