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
c0cd7867
Commit
c0cd7867
authored
Sep 08, 2011
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- REST Interface:
Now allowing to limit the columns returned using "columns" argument
parent
9376cd16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
intranet-rest-procs.tcl
tcl/intranet-rest-procs.tcl
+8
-1
intranet-rest-util-procs.tcl
tcl/intranet-rest-util-procs.tcl
+23
-0
No files found.
tcl/intranet-rest-procs.tcl
View file @
c0cd7867
...
...
@@ -794,6 +794,7 @@ ad_proc -private im_rest_get_object_type {
ns_log Notice
"im_rest_get_object_type: format=
$format
, user_id=
$current
_user_id, rest_otype=
$rest
_otype, rest_oid=
$rest
_oid, query_hash=
$query
_hash_pairs"
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
]]
set rest_columns
[
im_rest_get_rest_columns
$query
_hash_pairs
]
# -------------------------------------------------------
# Get some more information about the current object type
...
...
@@ -968,7 +969,7 @@ ad_proc -private im_rest_get_object_type {
set url
"
$base
_url/
$rest
_otype/
$rest
_oid"
switch
$format
{
xml
{
xml
{
append result
"<object_id id=
\"
$rest
_oid
\"
href=
\"
$url
\"
>
[
ns_quotehtml
$object
_name
]
</object_id>
\n
"
}
json
{
...
...
@@ -976,6 +977,12 @@ ad_proc -private im_rest_get_object_type {
if
{
0 ==
$obj
_ctr
}
{
set komma
""
}
set dereferenced_result
""
foreach v
$valid
_vars
{
if
{{}
!=
$rest
_columns
}
{
# Skip the column unless it is explicitely mentioned in the rest_columns list
if
{
!
[
info
exists rest_columns
(
$v
)]}
{
continue
}
}
eval
"set a
$
$v
"
regsub -all
{
\n
}
$a
{
\n
}
a
regsub -all
{
\r
}
$a
{}
a
...
...
tcl/intranet-rest-util-procs.tcl
View file @
c0cd7867
...
...
@@ -38,6 +38,29 @@ ad_proc -public im_rest_doc_return {args} {
}
ad_proc -public im_rest_get_rest_columns
{
query_hash_pairs
}
{
Reads the
"columns"
URL variable and returns the
list of selected REST columns or an empty list
if the variable was not specified.
}
{
set rest_columns
[
list
]
set rest_column_arg
""
array set query_hash
$query
_hash_pairs
if
{[
info
exists query_hash
(
columns
)]}
{
set rest_column_arg
$query
_hash
(
columns
)
}
if
{
""
!=
$rest
_column_arg
}
{
# Accept both space
(
" "
)
and komma
(
","
)
separated columns
set rest_columns
[
split
$rest
_column_arg
" "
]
if
{[
llength
$rest
_columns
]
<= 1
}
{
set rest_columns
[
split
$rest
_column_arg
","
]
}
}
return
$rest
_columns
}
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