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
931eede7
Commit
931eede7
authored
May 11, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support 304 response when possible.
parent
8dec110c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
master/product/Vifib/Tool/VifibRestApiV1Tool.py
master/product/Vifib/Tool/VifibRestApiV1Tool.py
+31
-0
No files found.
master/product/Vifib/Tool/VifibRestApiV1Tool.py
View file @
931eede7
...
@@ -39,6 +39,7 @@ from lxml import etree
...
@@ -39,6 +39,7 @@ from lxml import etree
import
json
import
json
import
transaction
import
transaction
from
App.Common
import
rfc1123_date
from
App.Common
import
rfc1123_date
from
DateTime
import
DateTime
class
WrongRequest
(
Exception
):
class
WrongRequest
(
Exception
):
pass
pass
...
@@ -69,6 +70,35 @@ def requireHeader(header_dict):
...
@@ -69,6 +70,35 @@ def requireHeader(header_dict):
return
wrapperRequireHeader
return
wrapperRequireHeader
return
outer
return
outer
def
supportModifiedSince
(
document_url_id
):
def
outer
(
fn
):
def
wrapperSupportModifiedSince
(
self
,
*
args
,
**
kwargs
):
modified_since
=
self
.
REQUEST
.
getHeader
(
'If-Modified-Since'
)
if
modified_since
is
not
None
:
# RFC 2616 If-Modified-Since support
try
:
modified_since
=
DateTime
(
self
.
REQUEST
.
getHeader
(
'If-Modified-Since'
))
except
Exception
:
# client sent wrong header, shall be ignored
pass
else
:
if
modified_since
<=
DateTime
():
# client send date before current time, shall continue and
# compare with second precision, as client by default shall set
# If-Modified-Since to last known Last-Modified value
if
int
(
self
.
restrictedTraverse
(
getattr
(
self
,
document_url_id
)
).
getModificationDate
().
timeTime
())
<=
int
(
modified_since
.
timeTime
()):
# document was not modified since
self
.
REQUEST
.
response
.
setStatus
(
304
)
return
self
.
REQUEST
.
response
return
fn
(
self
,
*
args
,
**
kwargs
)
wrapperSupportModifiedSince
.
__doc__
=
fn
.
__doc__
return
wrapperSupportModifiedSince
return
outer
def
requireJson
(
json_dict
,
optional_key_list
=
None
):
def
requireJson
(
json_dict
,
optional_key_list
=
None
):
if
optional_key_list
is
None
:
if
optional_key_list
is
None
:
optional_key_list
=
[]
optional_key_list
=
[]
...
@@ -284,6 +314,7 @@ class InstancePublisher(GenericPublisher):
...
@@ -284,6 +314,7 @@ class InstancePublisher(GenericPublisher):
@
requireHeader
({
'Accept'
:
'application/json'
})
@
requireHeader
({
'Accept'
:
'application/json'
})
@
extractInstance
@
extractInstance
@
supportModifiedSince
(
'software_instance_url'
)
def
__instance_info
(
self
):
def
__instance_info
(
self
):
certificate
=
False
certificate
=
False
software_instance
=
self
.
restrictedTraverse
(
self
.
software_instance_url
)
software_instance
=
self
.
restrictedTraverse
(
self
.
software_instance_url
)
...
...
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