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
fcb5a79e
Commit
fcb5a79e
authored
Nov 26, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.slap hateoas: get 'me' document with no cache.
parent
9c6e8dab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
slapos/slap/slap.py
slapos/slap/slap.py
+12
-7
No files found.
slapos/slap/slap.py
View file @
fcb5a79e
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
...
@@ -730,10 +731,11 @@ class ConnectionHelper:
...
@@ -730,10 +731,11 @@ class ConnectionHelper:
return
req
return
req
def
GET
(
self
,
path
,
params
=
None
):
def
GET
(
self
,
path
,
params
=
None
,
headers
=
None
):
req
=
self
.
do_request
(
requests
.
get
,
req
=
self
.
do_request
(
requests
.
get
,
path
=
path
,
path
=
path
,
params
=
params
)
params
=
params
,
headers
=
headers
)
return
req
.
text
.
encode
(
'utf-8'
)
return
req
.
text
.
encode
(
'utf-8'
)
def
POST
(
self
,
path
,
params
=
None
,
data
=
None
,
def
POST
(
self
,
path
,
params
=
None
,
data
=
None
,
...
@@ -876,10 +878,10 @@ class HateoasNavigator(object):
...
@@ -876,10 +878,10 @@ class HateoasNavigator(object):
self
.
master_ca_file
=
master_ca_file
self
.
master_ca_file
=
master_ca_file
self
.
timeout
=
timeout
self
.
timeout
=
timeout
def
GET
(
self
,
uri
):
def
GET
(
self
,
uri
,
headers
=
None
):
connection_helper
=
ConnectionHelper
(
connection_helper
=
ConnectionHelper
(
uri
,
self
.
key_file
,
self
.
cert_file
,
self
.
master_ca_file
,
self
.
timeout
)
uri
,
self
.
key_file
,
self
.
cert_file
,
self
.
master_ca_file
,
self
.
timeout
)
return
connection_helper
.
GET
(
uri
)
return
connection_helper
.
GET
(
uri
,
headers
=
headers
)
def
hateoasGetLinkFromLinks
(
self
,
links
,
title
):
def
hateoasGetLinkFromLinks
(
self
,
links
,
title
):
if
type
(
links
)
==
dict
:
if
type
(
links
)
==
dict
:
...
@@ -900,8 +902,8 @@ class HateoasNavigator(object):
...
@@ -900,8 +902,8 @@ class HateoasNavigator(object):
return
return
return
str
(
url
)
return
str
(
url
)
def
getSiteDocument
(
self
,
url
):
def
getSiteDocument
(
self
,
url
,
headers
=
None
):
result
=
self
.
GET
(
url
)
result
=
self
.
GET
(
url
,
headers
)
return
json
.
loads
(
result
)
return
json
.
loads
(
result
)
def
getRootDocument
(
self
):
def
getRootDocument
(
self
):
...
@@ -909,7 +911,10 @@ class HateoasNavigator(object):
...
@@ -909,7 +911,10 @@ class HateoasNavigator(object):
cached_root_document
=
getattr
(
self
,
'root_document'
,
None
)
cached_root_document
=
getattr
(
self
,
'root_document'
,
None
)
if
cached_root_document
:
if
cached_root_document
:
return
cached_root_document
return
cached_root_document
self
.
root_document
=
self
.
getSiteDocument
(
self
.
slapos_master_hateoas_uri
)
self
.
root_document
=
self
.
getSiteDocument
(
self
.
slapos_master_hateoas_uri
,
headers
=
{
'Cache-Control'
:
'no-cache'
}
)
return
self
.
root_document
return
self
.
root_document
def
getDocumentAndHateoas
(
self
,
relative_url
,
view
=
'view'
):
def
getDocumentAndHateoas
(
self
,
relative_url
,
view
=
'view'
):
...
...
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