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
Titouan Soulard
slapos.core
Commits
39b74652
Commit
39b74652
authored
May 09, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use decorator in order to extract person document.
parent
071b62c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
30 deletions
+22
-30
master/product/Vifib/Tool/VifibRestApiV1Tool.py
master/product/Vifib/Tool/VifibRestApiV1Tool.py
+22
-30
No files found.
master/product/Vifib/Tool/VifibRestApiV1Tool.py
View file @
39b74652
...
...
@@ -98,7 +98,8 @@ def responseSupport(anonymous=False):
response
.
setHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
response
.
setHeader
(
'Access-Control-Allow-Methods'
,
'DELETE, PUT, POST, '
'GET, OPTIONS'
)
if
not
anonymous
and
getSecurityManager
().
getUser
().
getId
()
is
None
:
if
not
anonymous
:
if
getSecurityManager
().
getUser
().
getId
()
is
None
:
# force login
response
.
setStatus
(
401
)
response
.
setHeader
(
'WWW-Authenticate'
,
'Bearer realm="%s"'
%
...
...
@@ -106,6 +107,17 @@ def responseSupport(anonymous=False):
response
.
setHeader
(
'Location'
,
self
.
getPortalObject
()
\
.
portal_preferences
.
getPreferredRestApiV1TokenServerUrl
())
return
response
else
:
self
.
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
if
self
.
person
is
None
:
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
'Currenty logged in user %r has no Person document.'
%
self
.
getPortalObject
().
getAuthenticatedMember
())
self
.
REQUEST
.
response
.
setStatus
(
500
)
self
.
REQUEST
.
response
.
setBody
(
json
.
dumps
({
'error'
:
'There is system issue, please try again later.'
}))
return
self
.
REQUEST
.
response
return
fn
(
self
,
*
args
,
**
kwargs
)
wrapperResponseSupport
.
__doc__
=
fn
.
__doc__
return
wrapperResponseSupport
...
...
@@ -141,6 +153,7 @@ def extractInstance(fn):
return
self
.
REQUEST
.
response
wrapperExtractInstance
.
__doc__
=
fn
.
__doc__
return
wrapperExtractInstance
class
GenericPublisher
(
Implicit
):
@
responseSupport
(
True
)
def
OPTIONS
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -163,16 +176,6 @@ class InstancePublisher(GenericPublisher):
@
requireJson
(
dict
(
log
=
unicode
))
@
extractInstance
def
__bang
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
if
person
is
None
:
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
'Currenty logged in user %r has no Person document.'
%
self
.
getPortalObject
().
getAuthenticatedMember
())
self
.
REQUEST
.
response
.
setStatus
(
500
)
self
.
REQUEST
.
response
.
setBody
(
json
.
dumps
({
'error'
:
'There is system issue, please try again later.'
}))
return
self
.
REQUEST
.
response
try
:
self
.
software_instance
.
reportComputerPartitionBang
(
comment
=
self
.
jbody
[
'log'
])
except
Exception
:
...
...
@@ -198,17 +201,6 @@ class InstancePublisher(GenericPublisher):
))
def
__request
(
self
):
response
=
self
.
REQUEST
.
response
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
if
person
is
None
:
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
'Currenty logged in user %r has no Person document.'
%
self
.
getPortalObject
().
getAuthenticatedMember
())
response
.
setStatus
(
500
)
response
.
setBody
(
json
.
dumps
({
'error'
:
'There is system issue, please try again later.'
}))
return
response
request_dict
=
{}
for
k_j
,
k_i
in
(
(
'software_release'
,
'software_release'
),
...
...
@@ -226,7 +218,7 @@ class InstancePublisher(GenericPublisher):
request_dict
[
k_i
]
=
self
.
jbody
[
k_j
]
try
:
person
.
requestSoftwareInstance
(
**
request_dict
)
self
.
person
.
requestSoftwareInstance
(
**
request_dict
)
except
Exception
:
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
...
...
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