Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
b4e939f3
Commit
b4e939f3
authored
Apr 16, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method for cache clearing
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
37f861ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
weblate/trans/permissions.py
weblate/trans/permissions.py
+18
-1
No files found.
weblate/trans/permissions.py
View file @
b4e939f3
...
@@ -23,11 +23,28 @@ Permissions abstract layer for Weblate.
...
@@ -23,11 +23,28 @@ Permissions abstract layer for Weblate.
from
weblate
import
appsettings
from
weblate
import
appsettings
from
django.core.cache
import
cache
from
django.core.cache
import
cache
ALL_CACHES
=
set
()
KEY_TEMPLATE
=
'permission-{0}-{1}-{2}'
def
clear_cache
(
user
,
translation
):
"""
Helper to clear permissions cache.
"""
for
key
in
ALL_CACHES
:
cache
.
delete
(
KEY_TEMPLATE
.
format
(
key
,
user
.
id
,
translation
.
id
)
)
def
cache_permission
(
func
):
def
cache_permission
(
func
):
"""
"""
Caching for permissions check.
Caching for permissions check.
"""
"""
ALL_CACHES
.
add
(
func
.
__name__
)
def
wrapper
(
user
,
translation
):
def
wrapper
(
user
,
translation
):
if
user
is
None
:
if
user
is
None
:
userid
=
0
userid
=
0
...
@@ -37,7 +54,7 @@ def cache_permission(func):
...
@@ -37,7 +54,7 @@ def cache_permission(func):
translationid
=
0
translationid
=
0
else
:
else
:
translationid
=
translation
.
id
translationid
=
translation
.
id
key
=
'permission-{0}-{1}-{2}'
.
format
(
key
=
KEY_TEMPLATE
.
format
(
func
.
__name__
,
userid
,
translationid
func
.
__name__
,
userid
,
translationid
)
)
result
=
cache
.
get
(
key
)
result
=
cache
.
get
(
key
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment