Merge "Remove page_size_default"

This commit is contained in:
Jenkins 2015-04-09 08:29:23 +00:00 committed by Gerrit Code Review
commit 822ece7260
15 changed files with 58 additions and 66 deletions

View File

@ -37,9 +37,6 @@ lock_path = $state_path/lock
# Port the bind the API server to
# bind_port = 8080
# List paging configuration options.
# page_size_default = 20
# Enable notifications. This feature drives deferred processing, reporting,
# and subscriptions.
# enable_notifications = True

View File

@ -22,8 +22,4 @@ app = {
}
cfg.CONF.register_opts([
cfg.IntOpt('page_size_default',
default=20,
help='The maximum number of results to allow a user to request '
'from the API')
])

View File

@ -80,9 +80,8 @@ class BranchesController(rest.RestController):
:param sort_dir: Sort direction for results (asc, desc).
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_branch = branches_api.branch_get(marker)
@ -101,7 +100,8 @@ class BranchesController(rest.RestController):
project_group_id=project_group_id)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(branches_count)
if marker_branch:
response.headers['X-Marker'] = str(marker_branch.id)

View File

@ -79,9 +79,8 @@ class MilestonesController(rest.RestController):
:param sort_dir: Sort direction for results (asc, desc).
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_milestone = milestones_api.milestone_get(marker)
@ -99,7 +98,8 @@ class MilestonesController(rest.RestController):
branch_id=branch_id)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(milestones_count)
if marker_milestone:
response.headers['X-Marker'] = str(marker_milestone.id)

View File

@ -129,9 +129,8 @@ class ProjectGroupsController(rest.RestController):
:param sort_dir: Sort direction for results (asc, desc).
"""
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_group = project_groups.project_group_get(marker)
@ -147,7 +146,8 @@ class ProjectGroupsController(rest.RestController):
title=title)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(group_count)
if marker_group:
response.headers['X-Marker'] = str(marker_group.id)

View File

@ -98,9 +98,8 @@ class ProjectsController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_project = projects_api.project_get(marker)
@ -119,7 +118,8 @@ class ProjectsController(rest.RestController):
project_group_id=project_group_id)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(project_count)
if marker_project:
response.headers['X-Marker'] = str(marker_project.id)

View File

@ -92,9 +92,8 @@ class StoriesController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_story = stories_api.story_get(marker)
@ -122,7 +121,8 @@ class StoriesController(rest.RestController):
tags_filter_type=tags_filter_type)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(story_count)
if marker_story:
response.headers['X-Marker'] = str(marker_story.id)

View File

@ -106,9 +106,8 @@ class SubscriptionEventsController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_sub = subscription_events_api.subscription_events_get(marker)
@ -133,7 +132,8 @@ class SubscriptionEventsController(rest.RestController):
event_type=event_type)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(subscription_count)
if marker_sub:
response.headers['X-Marker'] = str(marker_sub.id)

View File

@ -99,9 +99,8 @@ class SubscriptionsController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Sanity check on user_id
current_user = user_api.user_get(request.current_user_id)
@ -126,7 +125,8 @@ class SubscriptionsController(rest.RestController):
user_id=user_id)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(subscription_count)
if marker_sub:
response.headers['X-Marker'] = str(marker_sub.id)

View File

@ -37,9 +37,8 @@ class TaskStatusesController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
statuses = tasks_api.task_get_statuses()
task_statuses = []
@ -51,7 +50,8 @@ class TaskStatusesController(rest.RestController):
task_statuses.append(ts)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(len(task_statuses))
return task_statuses[0:limit]

View File

@ -293,9 +293,8 @@ class TasksPrimaryController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_task = tasks_api.task_get(marker)
@ -326,7 +325,8 @@ class TasksPrimaryController(rest.RestController):
priority=priority)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(task_count)
if marker_task:
response.headers['X-Marker'] = str(marker_task.id)
@ -468,9 +468,8 @@ class TasksNestedController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_task = tasks_api.task_get(marker)

View File

@ -134,9 +134,8 @@ class TeamsController(rest.RestController):
:param sort_dir: Sort direction for results (asc, desc).
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_team = teams_api.team_get(marker)
@ -152,7 +151,8 @@ class TeamsController(rest.RestController):
description=description)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(team_count)
if marker_team:
response.headers['X-Marker'] = str(marker_team.id)

View File

@ -79,9 +79,8 @@ class TimeLineEventsController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Sanity check on event types.
if event_type:
@ -105,7 +104,8 @@ class TimeLineEventsController(rest.RestController):
sort_dir=sort_dir)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(event_count)
if marker_event:
response.headers['X-Marker'] = str(marker_event.id)
@ -153,9 +153,8 @@ class CommentsController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_event = None
@ -181,7 +180,8 @@ class CommentsController(rest.RestController):
for event in events]
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(events_count)
if marker_event:
response.headers['X-Marker'] = str(marker)

View File

@ -72,9 +72,8 @@ class UserTokensController(rest.RestController):
self._assert_can_access(user_id)
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_token = token_api.user_token_get(marker)
@ -88,7 +87,8 @@ class UserTokensController(rest.RestController):
token_count = token_api.user_token_get_count(user_id=user_id)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(token_count)
if marker_token:

View File

@ -72,9 +72,8 @@ class UsersController(rest.RestController):
"""
# Boundary check on limit.
if limit is None:
limit = CONF.page_size_default
limit = max(0, limit)
if limit is not None:
limit = max(0, limit)
# Resolve the marker record.
marker_user = users_api.user_get(marker)
@ -87,7 +86,8 @@ class UsersController(rest.RestController):
user_count = users_api.user_get_count(full_name=full_name)
# Apply the query response headers.
response.headers['X-Limit'] = str(limit)
if limit:
response.headers['X-Limit'] = str(limit)
response.headers['X-Total'] = str(user_count)
if marker_user:
response.headers['X-Marker'] = str(marker_user.id)