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
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
Boxiang Sun
slapos.core
Commits
82bad6e9
Commit
82bad6e9
authored
May 24, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow flexibility in headers.
parent
a97747ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
master/product/Vifib/Tool/VifibRestApiV1Tool.py
master/product/Vifib/Tool/VifibRestApiV1Tool.py
+6
-5
No files found.
master/product/Vifib/Tool/VifibRestApiV1Tool.py
View file @
82bad6e9
...
@@ -41,6 +41,7 @@ import json
...
@@ -41,6 +41,7 @@ import json
import
transaction
import
transaction
from
App.Common
import
rfc1123_date
from
App.Common
import
rfc1123_date
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
re
class
WrongRequest
(
Exception
):
class
WrongRequest
(
Exception
):
pass
pass
...
@@ -61,7 +62,7 @@ def requireHeader(header_dict):
...
@@ -61,7 +62,7 @@ def requireHeader(header_dict):
def
wrapperRequireHeader
(
self
,
*
args
,
**
kwargs
):
def
wrapperRequireHeader
(
self
,
*
args
,
**
kwargs
):
problem_dict
=
{}
problem_dict
=
{}
for
header
,
value
in
header_dict
.
iteritems
():
for
header
,
value
in
header_dict
.
iteritems
():
if
self
.
REQUEST
.
getHeader
(
header
)
!=
value
:
if
not
re
.
match
(
value
,
self
.
REQUEST
.
getHeader
(
header
))
:
problem_dict
[
header
]
=
'Header with value %r is required.'
%
value
problem_dict
[
header
]
=
'Header with value %r is required.'
%
value
if
not
problem_dict
:
if
not
problem_dict
:
return
fn
(
self
,
*
args
,
**
kwargs
)
return
fn
(
self
,
*
args
,
**
kwargs
)
...
@@ -249,7 +250,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -249,7 +250,7 @@ class InstancePublisher(GenericPublisher):
@
responseSupport
()
@
responseSupport
()
@
requireHeader
({
'Accept'
:
'application/json'
,
@
requireHeader
({
'Accept'
:
'application/json'
,
'Content-Type'
:
'
application/json
'
})
'Content-Type'
:
'
^application/json.*
'
})
@
requireJson
(
dict
(
@
requireJson
(
dict
(
title
=
(
unicode
,
encode_utf8
),
title
=
(
unicode
,
encode_utf8
),
connection
=
dict
connection
=
dict
...
@@ -285,7 +286,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -285,7 +286,7 @@ class InstancePublisher(GenericPublisher):
return
self
.
REQUEST
.
response
return
self
.
REQUEST
.
response
@
requireHeader
({
'Accept'
:
'application/json'
,
@
requireHeader
({
'Accept'
:
'application/json'
,
'Content-Type'
:
'
application/json
'
})
'Content-Type'
:
'
^application/json.*
'
})
@
requireJson
(
dict
(
log
=
unicode
))
@
requireJson
(
dict
(
log
=
unicode
))
@
extractDocument
([
'Software Instance'
,
'Slave Instance'
])
@
extractDocument
([
'Software Instance'
,
'Slave Instance'
])
def
__bang
(
self
):
def
__bang
(
self
):
...
@@ -303,7 +304,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -303,7 +304,7 @@ class InstancePublisher(GenericPublisher):
return
self
.
REQUEST
.
response
return
self
.
REQUEST
.
response
@
requireHeader
({
'Accept'
:
'application/json'
,
@
requireHeader
({
'Accept'
:
'application/json'
,
'Content-Type'
:
'
application/json
'
})
'Content-Type'
:
'
^application/json.*
'
})
@
requireJson
(
dict
(
@
requireJson
(
dict
(
slave
=
bool
,
slave
=
bool
,
software_release
=
(
unicode
,
encode_utf8
),
software_release
=
(
unicode
,
encode_utf8
),
...
@@ -439,7 +440,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -439,7 +440,7 @@ class InstancePublisher(GenericPublisher):
class
ComputerPublisher
(
GenericPublisher
):
class
ComputerPublisher
(
GenericPublisher
):
@
responseSupport
()
@
responseSupport
()
@
requireHeader
({
'Accept'
:
'application/json'
,
@
requireHeader
({
'Accept'
:
'application/json'
,
'Content-Type'
:
'
application/json
'
})
'Content-Type'
:
'
^application/json.*
'
})
@
extractDocument
(
'Computer'
)
@
extractDocument
(
'Computer'
)
@
requireJson
(
dict
(
@
requireJson
(
dict
(
partition
=
list
,
partition
=
list
,
...
...
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