Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mikolaï Krol
erp5
Commits
76d44557
Commit
76d44557
authored
Aug 22, 2016
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_bearer_token: support pass a different cache factory name
parent
160891ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
bt5/erp5_bearer_token/ExtensionTemplateItem/portal_components/extension.erp5.BearerToken.py
...plateItem/portal_components/extension.erp5.BearerToken.py
+7
-6
No files found.
bt5/erp5_bearer_token/ExtensionTemplateItem/portal_components/extension.erp5.BearerToken.py
View file @
76d44557
import
hmac
from
Products.ERP5Type.Cache
import
DEFAULT_CACHE_SCOPE
CACHE_FACTORY_NAME
=
'bearer_token_cache_factory'
def
getHMAC
(
self
,
key
,
body
):
digest
=
hmac
.
new
(
key
,
body
)
return
digest
.
hexdigest
()
def
_getCacheFactory
(
self
):
def
_getCacheFactory
(
self
,
cache_factory_name
):
portal
=
self
.
getPortalObject
()
cache_tool
=
portal
.
portal_caches
cache_factory_name
=
'bearer_token_cache_factory'
cache_factory
=
cache_tool
.
getRamCacheRoot
().
get
(
cache_factory_name
)
#XXX This conditional statement should be remove as soon as
#Broadcasting will be enable among all zeo clients.
...
...
@@ -19,15 +20,15 @@ def _getCacheFactory(self):
cache_tool
.
updateCache
()
return
cache_tool
.
getRamCacheRoot
().
get
(
cache_factory_name
)
def
setBearerToken
(
self
,
key
,
body
):
cache_factory
=
_getCacheFactory
(
self
)
def
setBearerToken
(
self
,
key
,
body
,
cache_factory_name
=
CACHE_FACTORY_NAME
):
cache_factory
=
_getCacheFactory
(
self
,
cache_factory_name
)
cache_duration
=
cache_factory
.
cache_duration
for
cache_plugin
in
cache_factory
.
getCachePluginList
():
cache_plugin
.
set
(
key
,
DEFAULT_CACHE_SCOPE
,
body
,
cache_duration
=
cache_duration
)
def
getBearerToken
(
self
,
key
):
cache_factory
=
_getCacheFactory
(
self
)
def
getBearerToken
(
self
,
key
,
cache_factory_name
=
CACHE_FACTORY_NAME
):
cache_factory
=
_getCacheFactory
(
self
,
cache_factory_name
)
for
cache_plugin
in
cache_factory
.
getCachePluginList
():
cache_entry
=
cache_plugin
.
get
(
key
,
DEFAULT_CACHE_SCOPE
)
if
cache_entry
is
not
None
:
...
...
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