Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-rest
Commits
9376cd16
Commit
9376cd16
authored
Sep 08, 2011
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- REST Interface:
Applied now the gzip_p parameter to all list returning REST functions
parent
96677bad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
28 deletions
+38
-28
intranet-rest-procs.tcl
tcl/intranet-rest-procs.tcl
+15
-28
intranet-rest-util-procs.tcl
tcl/intranet-rest-util-procs.tcl
+23
-0
No files found.
tcl/intranet-rest-procs.tcl
View file @
9376cd16
...
...
@@ -795,11 +795,6 @@ ad_proc -private im_rest_get_object_type {
array set query_hash
$query
_hash_pairs
set rest_otype_id
[
util_memoize
[
list
db_string otype_id
"select object_type_id from im_rest_object_types where object_type = '
$rest
_otype'"
-default 0
]]
# Should we return the results in gzip format?
set gzip_p 0
if
{[
info
exists query_hash
(
gzip_p
)]}
{
set gzip_p
$query
_hash
(
gzip_p
)
}
# -------------------------------------------------------
# Get some more information about the current object type
db_1row rest_otype_info
"
...
...
@@ -1001,29 +996,21 @@ ad_proc -private im_rest_get_object_type {
switch
$format
{
html
{
set page_title
"object_type:
$rest
_otype"
doc_return 200
"text/html"
"
im_rest_
doc_return 200
"text/html"
"
[
im_header
$page
_title
[
im_rest_header_extra_stuff
]][
im_navbar
]
<table>
<tr class=rowtitle><td class=rowtitle>object_id</td><td class=rowtitle>Link</td></tr>
$result
</table>
[
im_footer
]
"
}
xml
{
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
im_rest_
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
return
}
json
{
# Calculate the total number of objects
set total
[
db_string total
"select count(*) from (
$unlimited
_sql) t"
-default 0
]
set result
"{
\"
success
\"
: true,
\n\"
total
\"
:
$total
,
\n\"
message
\"
:
\"
im_rest_get_object_type: Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
# Return the results. Check if compressed
if
{
$gzip
_p
}
{
db_release_unused_handles
ad_http_cache_control
ns_returnz 200
"text/html"
$result
}
else
{
doc_return 200
"text/html"
$result
}
im_rest_doc_return 200
"text/html"
$result
return
}
default
{
...
...
@@ -1108,7 +1095,7 @@ ad_proc -private im_rest_get_im_invoice_items {
switch
$format
{
html
{
set page_title
"object_type:
$rest
_otype"
doc_return 200
"text/html"
"
im_rest_
doc_return 200
"text/html"
"
[
im_header
$page
_title
[
im_rest_header_extra_stuff
]][
im_navbar
]
<table>
<tr class=rowtitle><td class=rowtitle>object_id</td><td class=rowtitle>Link</td></tr>
$result
</table>
[
im_footer
]
...
...
@@ -1116,11 +1103,11 @@ ad_proc -private im_rest_get_im_invoice_items {
return
}
xml
{
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
im_rest_
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
return
}
json
{
doc_return 200
"text/html"
"{object_type:
\"
$rest
_otype
\"
,
\n
$result
\n
}"
im_rest_
doc_return 200
"text/html"
"{object_type:
\"
$rest
_otype
\"
,
\n
$result
\n
}"
return
}
}
...
...
@@ -1208,7 +1195,7 @@ ad_proc -private im_rest_get_im_hours {
switch
$format
{
html
{
set page_title
"object_type:
$rest
_otype"
doc_return 200
"text/html"
"
im_rest_
doc_return 200
"text/html"
"
[
im_header
$page
_title
[
im_rest_header_extra_stuff
]][
im_navbar
]
<table>
<tr class=rowtitle><td class=rowtitle>object_id</td><td class=rowtitle>Link</td></tr>
$result
</table>
[
im_footer
]
...
...
@@ -1216,11 +1203,11 @@ ad_proc -private im_rest_get_im_hours {
return
}
xml
{
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
im_rest_
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
return
}
json
{
doc_return 200
"text/html"
"
\[
$result
\]\n
"
im_rest_
doc_return 200
"text/html"
"
\[
$result
\]\n
"
return
}
}
...
...
@@ -1339,7 +1326,7 @@ ad_proc -private im_rest_get_im_categories {
switch
$format
{
html
{
set page_title
"object_type:
$rest
_otype"
doc_return 200
"text/html"
"
im_rest_
doc_return 200
"text/html"
"
[
im_header
$page
_title
[
im_rest_header_extra_stuff
]][
im_navbar
]
<table>
<tr class=rowtitle><td class=rowtitle>object_id</td><td class=rowtitle>Link</td></tr>
$result
</table>
[
im_footer
]
...
...
@@ -1347,13 +1334,13 @@ ad_proc -private im_rest_get_im_categories {
return
}
xml
{
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
im_rest_
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
return
}
json
{
# Deal with different JSON variants for different AJAX frameworks
set result
"{
\"
success
\"
: true,
\n\"
message
\"
:
\"
im_rest_get_im_categories: Data loaded
\"
,
\n\"
data
\"
:
\[\n
$result
\n\]\n
}"
doc_return 200
"text/html"
$result
im_rest_
doc_return 200
"text/html"
$result
return
}
}
...
...
@@ -1436,17 +1423,17 @@ ad_proc -private im_rest_get_im_dynfield_attributes {
switch
$format
{
html
{
set page_title
"object_type:
$rest
_otype"
doc_return 200
"text/html"
"
im_rest_
doc_return 200
"text/html"
"
[
im_header
$page
_title
[
im_rest_header_extra_stuff
]][
im_navbar
]
<table>
<tr class=rowtitle><td class=rowtitle>object_id</td><td class=rowtitle>Link</td></tr>
$result
</table>
[
im_footer
]
"
}
xml
{
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
im_rest_
doc_return 200
"text/xml"
"<?xml version='1.0'?>
\n
<object_list>
\n
$result
</object_list>
\n
"
}
json
{
doc_return 200
"text/html"
"
\[\n
$result
\n\]\n
"
im_rest_
doc_return 200
"text/html"
"
\[\n
$result
\n\]\n
"
}
}
...
...
tcl/intranet-rest-util-procs.tcl
View file @
9376cd16
...
...
@@ -15,6 +15,29 @@ ad_library {
# Auxillary functions
# --------------------------------------------------------
ad_proc -public im_rest_doc_return
{
args
}
{
This is a replacement for doc_return that values if the
gzip_p URL parameters has been set.
}
{
# Perform some magic work
db_release_unused_handles
ad_http_cache_control
# find out if we should compress or not
set query_set
[
ns_conn form
]
set gzip_p
[
ns_set get
$query
_set gzip_p
]
ns_log Notice
"im_rest_doc_return: gzip_p=
$gzip
_p"
# Return the data
if
{
"1"
==
$gzip
_p
}
{
return
[
eval
"ns_returnz
$args
"
]
}
else
{
return
[
eval
"ns_return
$args
"
]
}
}
ad_proc -private im_rest_header_extra_stuff
{
{
-debug 1
}
}
{
...
...
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