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
Nicolas Wavrant
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
Hide 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,14 +98,26 @@ def responseSupport(anonymous=False):
...
@@ -98,14 +98,26 @@ def responseSupport(anonymous=False):
response
.
setHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
response
.
setHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
response
.
setHeader
(
'Access-Control-Allow-Methods'
,
'DELETE, PUT, POST, '
response
.
setHeader
(
'Access-Control-Allow-Methods'
,
'DELETE, PUT, POST, '
'GET, OPTIONS'
)
'GET, OPTIONS'
)
if
not
anonymous
and
getSecurityManager
().
getUser
().
getId
()
is
None
:
if
not
anonymous
:
# force login
if
getSecurityManager
().
getUser
().
getId
()
is
None
:
response
.
setStatus
(
401
)
# force login
response
.
setHeader
(
'WWW-Authenticate'
,
'Bearer realm="%s"'
%
response
.
setStatus
(
401
)
self
.
absolute_url
())
response
.
setHeader
(
'WWW-Authenticate'
,
'Bearer realm="%s"'
%
response
.
setHeader
(
'Location'
,
self
.
getPortalObject
()
\
self
.
absolute_url
())
.
portal_preferences
.
getPreferredRestApiV1TokenServerUrl
())
response
.
setHeader
(
'Location'
,
self
.
getPortalObject
()
\
return
response
.
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
)
return
fn
(
self
,
*
args
,
**
kwargs
)
wrapperResponseSupport
.
__doc__
=
fn
.
__doc__
wrapperResponseSupport
.
__doc__
=
fn
.
__doc__
return
wrapperResponseSupport
return
wrapperResponseSupport
...
@@ -141,6 +153,7 @@ def extractInstance(fn):
...
@@ -141,6 +153,7 @@ def extractInstance(fn):
return
self
.
REQUEST
.
response
return
self
.
REQUEST
.
response
wrapperExtractInstance
.
__doc__
=
fn
.
__doc__
wrapperExtractInstance
.
__doc__
=
fn
.
__doc__
return
wrapperExtractInstance
return
wrapperExtractInstance
class
GenericPublisher
(
Implicit
):
class
GenericPublisher
(
Implicit
):
@
responseSupport
(
True
)
@
responseSupport
(
True
)
def
OPTIONS
(
self
,
*
args
,
**
kwargs
):
def
OPTIONS
(
self
,
*
args
,
**
kwargs
):
...
@@ -163,16 +176,6 @@ class InstancePublisher(GenericPublisher):
...
@@ -163,16 +176,6 @@ class InstancePublisher(GenericPublisher):
@
requireJson
(
dict
(
log
=
unicode
))
@
requireJson
(
dict
(
log
=
unicode
))
@
extractInstance
@
extractInstance
def
__bang
(
self
):
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
:
try
:
self
.
software_instance
.
reportComputerPartitionBang
(
comment
=
self
.
jbody
[
'log'
])
self
.
software_instance
.
reportComputerPartitionBang
(
comment
=
self
.
jbody
[
'log'
])
except
Exception
:
except
Exception
:
...
@@ -198,17 +201,6 @@ class InstancePublisher(GenericPublisher):
...
@@ -198,17 +201,6 @@ class InstancePublisher(GenericPublisher):
))
))
def
__request
(
self
):
def
__request
(
self
):
response
=
self
.
REQUEST
.
response
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
=
{}
request_dict
=
{}
for
k_j
,
k_i
in
(
for
k_j
,
k_i
in
(
(
'software_release'
,
'software_release'
),
(
'software_release'
,
'software_release'
),
...
@@ -226,7 +218,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -226,7 +218,7 @@ class InstancePublisher(GenericPublisher):
request_dict
[
k_i
]
=
self
.
jbody
[
k_j
]
request_dict
[
k_i
]
=
self
.
jbody
[
k_j
]
try
:
try
:
person
.
requestSoftwareInstance
(
**
request_dict
)
self
.
person
.
requestSoftwareInstance
(
**
request_dict
)
except
Exception
:
except
Exception
:
transaction
.
abort
()
transaction
.
abort
()
LOG
(
'VifibRestApiV1Tool'
,
ERROR
,
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