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
0
Merge Requests
0
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
Rafael Monnerat
slapos.core
Commits
4a56c93b
Commit
4a56c93b
authored
Dec 31, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: getAccessStatus should not return unicode strings
parent
2ac9e527
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSCacheMixin.py
...lateItem/portal_components/mixin.erp5.SlapOSCacheMixin.py
+29
-2
No files found.
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSCacheMixin.py
View file @
4a56c93b
...
@@ -34,11 +34,38 @@ from App.Common import rfc1123_date
...
@@ -34,11 +34,38 @@ from App.Common import rfc1123_date
from
Products.ERP5Type.Cache
import
DEFAULT_CACHE_SCOPE
from
Products.ERP5Type.Cache
import
DEFAULT_CACHE_SCOPE
import
json
import
json
import
six
ACCESS
=
"#access"
ACCESS
=
"#access"
ERROR
=
"#error"
ERROR
=
"#error"
BUILDING
=
"#building"
BUILDING
=
"#building"
# On python2, make sure we use UTF-8 strings for the json schemas, so that we don't
# have ugly u' prefixes in the reprs. This also transforms the collections.OrderedDict
# to simple dicts, because the former also have an ugly representation.
# http://stackoverflow.com/a/13105359
if
six
.
PY2
:
def
byteify
(
string
):
if
isinstance
(
string
,
dict
):
return
{
byteify
(
key
):
byteify
(
value
)
for
key
,
value
in
string
.
iteritems
()
}
elif
isinstance
(
string
,
list
):
return
[
byteify
(
element
)
for
element
in
string
]
elif
isinstance
(
string
,
tuple
):
return
tuple
(
byteify
(
element
)
for
element
in
string
)
elif
isinstance
(
string
,
six
.
text_type
):
return
string
.
encode
(
'utf-8'
)
else
:
return
string
else
:
def
byteify
(
x
):
return
x
class
SlapOSCacheMixin
:
class
SlapOSCacheMixin
:
# Declarative security
# Declarative security
...
@@ -87,7 +114,7 @@ class SlapOSCacheMixin:
...
@@ -87,7 +114,7 @@ class SlapOSCacheMixin:
#data_dict["user"] = data_dict["user"].decode("UTF-8")
#data_dict["user"] = data_dict["user"].decode("UTF-8")
return
data_dict
return
data_dict
data_dict
=
json
.
loads
(
data_json
)
data_dict
=
byteify
(
json
.
loads
(
data_json
)
)
last_contact
=
DateTime
(
data_dict
.
get
(
'created_at'
))
last_contact
=
DateTime
(
data_dict
.
get
(
'created_at'
))
data_dict
[
"no_data_since_15_minutes"
]
=
0
data_dict
[
"no_data_since_15_minutes"
]
=
0
data_dict
[
"no_data_since_5_minutes"
]
=
0
data_dict
[
"no_data_since_5_minutes"
]
=
0
...
@@ -117,7 +144,7 @@ class SlapOSCacheMixin:
...
@@ -117,7 +144,7 @@ class SlapOSCacheMixin:
since
=
created_at
since
=
created_at
status_changed
=
True
status_changed
=
True
if
previous
is
not
None
:
if
previous
is
not
None
:
previous_json
=
json
.
loads
(
previous
)
previous_json
=
byteify
(
json
.
loads
(
previous
)
)
if
text
.
split
(
" "
)[
0
]
==
previous_json
.
get
(
"text"
,
""
).
split
(
" "
)[
0
]:
if
text
.
split
(
" "
)[
0
]
==
previous_json
.
get
(
"text"
,
""
).
split
(
" "
)[
0
]:
since
=
previous_json
.
get
(
"since"
,
since
=
previous_json
.
get
(
"since"
,
previous_json
.
get
(
"created_at"
,
rfc1123_date
(
DateTime
())))
previous_json
.
get
(
"created_at"
,
rfc1123_date
(
DateTime
())))
...
...
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