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
Hardik Juneja
slapos.core
Commits
9e9884d9
Commit
9e9884d9
authored
May 09, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow one pattern.
Access and use response object directly.
parent
8f933329
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
master/product/Vifib/Tool/VifibRestApiV1Tool.py
master/product/Vifib/Tool/VifibRestApiV1Tool.py
+14
-16
No files found.
master/product/Vifib/Tool/VifibRestApiV1Tool.py
View file @
9e9884d9
...
@@ -91,22 +91,21 @@ def requireJson(json_dict):
...
@@ -91,22 +91,21 @@ def requireJson(json_dict):
def
responseSupport
(
anonymous
=
False
):
def
responseSupport
(
anonymous
=
False
):
def
outer
(
fn
):
def
outer
(
fn
):
def
wrapperResponseSupport
(
self
,
*
args
,
**
kwargs
):
def
wrapperResponseSupport
(
self
,
*
args
,
**
kwargs
):
response
=
self
.
REQUEST
.
response
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'application/json'
)
response
.
setHeader
(
'Content-Type'
,
'application/json'
)
self
.
REQUEST
.
response
.
setHeader
(
'Access-Control-Allow-Headers'
,
response
.
setHeader
(
'Access-Control-Allow-Headers'
,
self
.
REQUEST
.
getHeader
(
'Access-Control-Allow-Headers'
))
self
.
REQUEST
.
getHeader
(
'Access-Control-Allow-Headers'
))
response
.
setHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
self
.
REQUEST
.
response
.
setHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
response
.
setHeader
(
'Access-Control-Allow-Methods'
,
'DELETE, PUT, POST, '
self
.
REQUEST
.
response
.
setHeader
(
'Access-Control-Allow-Methods'
,
'DELETE, PUT, POST, '
'GET, OPTIONS'
)
'GET, OPTIONS'
)
if
not
anonymous
:
if
not
anonymous
:
if
getSecurityManager
().
getUser
().
getId
()
is
None
:
if
getSecurityManager
().
getUser
().
getId
()
is
None
:
# force login
# force login
response
.
setStatus
(
401
)
self
.
REQUEST
.
response
.
setStatus
(
401
)
response
.
setHeader
(
'WWW-Authenticate'
,
'Bearer realm="%s"'
%
self
.
REQUEST
.
response
.
setHeader
(
'WWW-Authenticate'
,
'Bearer realm="%s"'
%
self
.
absolute_url
())
self
.
absolute_url
())
response
.
setHeader
(
'Location'
,
self
.
getPortalObject
()
\
self
.
REQUEST
.
response
.
setHeader
(
'Location'
,
self
.
getPortalObject
()
\
.
portal_preferences
.
getPreferredRestApiV1TokenServerUrl
())
.
portal_preferences
.
getPreferredRestApiV1TokenServerUrl
())
return
response
return
self
.
REQUEST
.
response
else
:
else
:
self
.
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
self
.
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
if
self
.
person
is
None
:
if
self
.
person
is
None
:
...
@@ -200,7 +199,6 @@ class InstancePublisher(GenericPublisher):
...
@@ -200,7 +199,6 @@ class InstancePublisher(GenericPublisher):
status
=
unicode
status
=
unicode
))
))
def
__request
(
self
):
def
__request
(
self
):
response
=
self
.
REQUEST
.
response
request_dict
=
{}
request_dict
=
{}
for
k_j
,
k_i
in
(
for
k_j
,
k_i
in
(
(
'software_release'
,
'software_release'
),
(
'software_release'
,
'software_release'
),
...
@@ -223,14 +221,14 @@ class InstancePublisher(GenericPublisher):
...
@@ -223,14 +221,14 @@ class InstancePublisher(GenericPublisher):
transaction
.
abort
()
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
'Problem with person.requestSoftwareInstance:'
,
error
=
True
)
'Problem with person.requestSoftwareInstance:'
,
error
=
True
)
response
.
setStatus
(
500
)
self
.
REQUEST
.
response
.
setStatus
(
500
)
response
.
setBody
(
json
.
dumps
({
'error'
:
self
.
REQUEST
.
response
.
setBody
(
json
.
dumps
({
'error'
:
'There is system issue, please try again later.'
}))
'There is system issue, please try again later.'
}))
return
response
return
self
.
REQUEST
.
response
response
.
setStatus
(
202
)
self
.
REQUEST
.
response
.
setStatus
(
202
)
response
.
setBody
(
json
.
dumps
({
'status'
:
'processing'
}))
self
.
REQUEST
.
response
.
setBody
(
json
.
dumps
({
'status'
:
'processing'
}))
return
response
return
self
.
REQUEST
.
response
@
requireHeader
({
'Accept'
:
'application/json'
})
@
requireHeader
({
'Accept'
:
'application/json'
})
@
extractInstance
@
extractInstance
...
...
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