Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
71560fc5
Commit
71560fc5
authored
Oct 09, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reactivate the internal cache.
parent
0295e3d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
36 deletions
+36
-36
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+36
-36
No files found.
master/product/Vifib/Tool/SlapTool.py
View file @
71560fc5
...
...
@@ -36,7 +36,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Tool.BaseTool
import
BaseTool
from
Products.ERP5Type
import
Permissions
#
from Products.ERP5Type.Cache import CachingMethod
from
Products.ERP5Type.Cache
import
CachingMethod
from
Products.ERP5Type.Cache
import
DEFAULT_CACHE_SCOPE
from
lxml
import
etree
import
time
...
...
@@ -208,25 +208,25 @@ class SlapTool(BaseTool):
slap_computer
.
_computer_partition_list
=
[]
if
user_type
in
(
'Computer'
,
'Person'
):
#
if not self._isTestRun():
#
cache_plugin = self._getCachePlugin()
#
try:
#
entry = cache_plugin.get(user, DEFAULT_CACHE_SCOPE)
#
except KeyError:
#
entry = None
#
if entry is not None and type(entry.getValue()) == type({}):
#
result = entry.getValue()['data']
#
if time.time() - entry.getValue()['time'] > 60 * 1:
#
# entry was stored 1 minutes ago, ask for recalculation
#
self._activateFillComputerInformationCache(computer_id, user, full)
#
return result
#
else:
#
self._activateFillComputerInformationCache(computer_id, user, full)
#
self.REQUEST.response.setStatus(503)
#
return self.REQUEST.response
#
else:
#
return self._getCacheComputerInformation(computer_id, user, full)
return
self
.
_getCacheComputerInformation
(
computer_id
,
user
,
full
)
if
not
self
.
_isTestRun
():
cache_plugin
=
self
.
_getCachePlugin
()
try
:
entry
=
cache_plugin
.
get
(
user
,
DEFAULT_CACHE_SCOPE
)
except
KeyError
:
entry
=
None
if
entry
is
not
None
and
type
(
entry
.
getValue
())
==
type
({}):
result
=
entry
.
getValue
()[
'data'
]
if
time
.
time
()
-
entry
.
getValue
()[
'time'
]
>
60
*
1
:
# entry was stored 1 minutes ago, ask for recalculation
self
.
_activateFillComputerInformationCache
(
computer_id
,
user
,
full
)
return
result
else
:
self
.
_activateFillComputerInformationCache
(
computer_id
,
user
,
full
)
self
.
REQUEST
.
response
.
setStatus
(
503
)
return
self
.
REQUEST
.
response
else
:
return
self
.
_getCacheComputerInformation
(
computer_id
,
user
,
full
)
#
return self._getCacheComputerInformation(computer_id, user, full)
else
:
slap_computer
.
_software_release_list
=
[]
for
computer_partition
in
self
.
getPortalObject
().
portal_catalog
(
...
...
@@ -248,14 +248,14 @@ class SlapTool(BaseTool):
"""
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'#access %s'
%
computer_id
)
#
if not self._isTestRun():
#
result = CachingMethod(self._getComputerInformation,
#
id='_getComputerInformation',
#
cache_factory='slap_cache_factory')(
#
computer_id, user, False)
#
else:
#
result = self._getComputerInformation(computer_id, user, False)
result
=
self
.
_getComputerInformation
(
computer_id
,
user
,
False
)
if
not
self
.
_isTestRun
():
result
=
CachingMethod
(
self
.
_getComputerInformation
,
id
=
'_getComputerInformation'
,
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
,
False
)
else
:
result
=
self
.
_getComputerInformation
(
computer_id
,
user
,
False
)
#
result = self._getComputerInformation(computer_id, user, False)
# Keep in cache server for 1 year
self
.
REQUEST
.
response
.
setStatus
(
200
)
...
...
@@ -277,14 +277,14 @@ class SlapTool(BaseTool):
"""
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'#access %s'
%
computer_id
)
#
if not self._isTestRun():
#
return CachingMethod(self._getComputerInformation,
#
id='_getFullComputerInformation',
#
cache_factory='slap_cache_factory')(
#
computer_id, user, True)
#
else:
#
return self._getComputerInformation(computer_id, user, True)
result
=
self
.
_getComputerInformation
(
computer_id
,
user
,
True
)
if
not
self
.
_isTestRun
():
return
CachingMethod
(
self
.
_getComputerInformation
,
id
=
'_getFullComputerInformation'
,
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
,
True
)
else
:
return
self
.
_getComputerInformation
(
computer_id
,
user
,
True
)
#
result = self._getComputerInformation(computer_id, user, True)
# Keep in cache server for 1 year
self
.
REQUEST
.
response
.
setStatus
(
200
)
...
...
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