Use python3 compatible unicode types

Switch from using unicode to wsme.types.text or six.text_type.

Change-Id: Id5ff56433971d2565558a62c3d0d770bd4bad99e
This commit is contained in:
Gregory Haynes 2015-02-11 16:50:06 -08:00 committed by greghaynes
parent 4082273147
commit 8fbd839995
16 changed files with 58 additions and 42 deletions

View File

@ -19,6 +19,7 @@ from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme.exc import ClientSideError
import wsme.types as wtypes
import wsmeext.pecan as wsme_pecan
import storyboard.api.auth.authorization_checks as checks
@ -107,8 +108,8 @@ class ProjectGroupsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.ProjectGroup], int, int, unicode, unicode,
unicode, unicode)
@wsme_pecan.wsexpose([wmodels.ProjectGroup], int, int, wtypes.text,
wtypes.text, wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, name=None, title=None,
sort_field='id', sort_dir='asc'):
"""Retrieve a list of projects groups."""

View File

@ -18,6 +18,7 @@ from pecan.decorators import expose
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -64,7 +65,7 @@ class ProjectsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose(wmodels.Project, unicode)
@wsme_pecan.wsexpose(wmodels.Project, wtypes.text)
def get_one_by_name(self, project_name):
"""Retrieve information about the given project.
@ -80,8 +81,8 @@ class ProjectsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Project], int, int, unicode, unicode, int,
unicode, unicode)
@wsme_pecan.wsexpose([wmodels.Project], int, int, wtypes.text, wtypes.text,
int, wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, name=None, description=None,
project_group_id=None, sort_field='id', sort_dir='asc'):
"""Retrieve a list of projects.
@ -162,7 +163,8 @@ class ProjectsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Project], unicode, unicode, int, int)
@wsme_pecan.wsexpose([wmodels.Project], wtypes.text, wtypes.text, int,
int)
def search(self, q="", marker=None, limit=None):
"""The search endpoint for projects.

View File

@ -20,6 +20,7 @@ from pecan import request
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -66,9 +67,9 @@ class StoriesController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Story], unicode, unicode, [unicode], int,
int, int, [unicode], int, int, unicode, unicode,
unicode)
@wsme_pecan.wsexpose([wmodels.Story], wtypes.text, wtypes.text,
[wtypes.text], int, int, int, [wtypes.text], int, int,
wtypes.text, wtypes.text, wtypes.text)
def get_all(self, title=None, description=None, status=None,
assignee_id=None, project_group_id=None, project_id=None,
tags=None, marker=None, limit=None, tags_filter_type='all',
@ -197,7 +198,7 @@ class StoriesController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Story], unicode, unicode, int, int)
@wsme_pecan.wsexpose([wmodels.Story], wtypes.text, wtypes.text, int, int)
def search(self, q="", marker=None, limit=None):
"""The search endpoint for stories.

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from pecan import abort
from pecan import request
@ -90,8 +91,8 @@ class SubscriptionEventsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.authenticated)
@wsme_pecan.wsexpose([SubscriptionEvent], int, int, unicode,
int, unicode, unicode)
@wsme_pecan.wsexpose([SubscriptionEvent], int, int, wtypes.text,
int, wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, event_type=None,
subscriber_id=None, sort_field='id', sort_dir='asc'):
"""Retrieve a list of subscriptions.

View File

@ -83,8 +83,8 @@ class SubscriptionsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.authenticated)
@wsme_pecan.wsexpose([Subscription], int, int, [unicode], int, int,
unicode, unicode)
@wsme_pecan.wsexpose([Subscription], int, int, [wtypes.text], int, int,
wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, target_type=None, target_id=None,
user_id=None, sort_field='id', sort_dir='asc'):
"""Retrieve a list of subscriptions.

View File

@ -16,6 +16,7 @@
from oslo.config import cfg
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -69,7 +70,7 @@ class TagsController(rest.RestController):
return [wmodels.Tag.from_db_model(t) for t in story.tags]
@secure(checks.authenticated)
@wsme_pecan.wsexpose(wmodels.Story, int, body=[unicode])
@wsme_pecan.wsexpose(wmodels.Story, int, body=[wtypes.text])
def put(self, story_id, tags):
"""Add a list of tags to a Story.
@ -88,7 +89,7 @@ class TagsController(rest.RestController):
return wmodels.Story.from_db_model(story)
@secure(checks.authenticated)
@wsme_pecan.wsexpose(wmodels.Tag, unicode)
@wsme_pecan.wsexpose(wmodels.Tag, wtypes.text)
def post(self, tag_name):
"""Create a tag not attached to any Story.
@ -100,7 +101,7 @@ class TagsController(rest.RestController):
return wmodels.Tag.from_db_model(tag)
@secure(checks.authenticated)
@wsme_pecan.wsexpose(None, int, body=[unicode], status_code=204)
@wsme_pecan.wsexpose(None, int, body=[wtypes.text], status_code=204)
def delete(self, story_id, tags):
"""Remove a list of tags from a Story.

View File

@ -17,6 +17,7 @@ from oslo.config import cfg
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -30,7 +31,7 @@ class TaskStatusesController(rest.RestController):
"""Manages tasks statuses."""
@secure(checks.guest)
@wsme_pecan.wsexpose([TaskStatus], int, unicode)
@wsme_pecan.wsexpose([TaskStatus], int, wtypes.text)
def get_all(self, limit=None, name=None):
"""Retrieve the possible task statuses.
"""

View File

@ -19,6 +19,7 @@ from pecan import request
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -61,8 +62,9 @@ class TasksController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Task], unicode, int, int, int, int,
[unicode], [unicode], int, int, unicode, unicode)
@wsme_pecan.wsexpose([wmodels.Task], wtypes.text, int, int, int, int,
[wtypes.text], [wtypes.text], int, int, wtypes.text,
wtypes.text)
def get_all(self, title=None, story_id=None, assignee_id=None,
project_id=None, project_group_id=None, status=None,
priority=None, marker=None, limit=None, sort_field='id',
@ -231,7 +233,7 @@ class TasksController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Task], unicode, unicode, int, int)
@wsme_pecan.wsexpose([wmodels.Task], wtypes.text, wtypes.text, int, int)
def search(self, q="", marker=None, limit=None):
"""The search endpoint for tasks.

View File

@ -19,6 +19,7 @@ from pecan.decorators import expose
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -95,7 +96,7 @@ class TeamsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose(wmodels.Team, unicode)
@wsme_pecan.wsexpose(wmodels.Team, wtypes.text)
def get_one_by_name(self, team_name):
"""Retrieve information about the given team.
@ -111,8 +112,8 @@ class TeamsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Team], int, int, unicode, unicode, unicode,
unicode)
@wsme_pecan.wsexpose([wmodels.Team], int, int, wtypes.text, wtypes.text,
wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, name=None, description=None,
sort_field='id', sort_dir='asc'):
"""Retrieve a list of teams.

View File

@ -19,6 +19,7 @@ from pecan import request
from pecan import response
from pecan import rest
from pecan.secure import secure
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -61,8 +62,8 @@ class TimeLineEventsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.TimeLineEvent], int, int, int, unicode,
unicode)
@wsme_pecan.wsexpose([wmodels.TimeLineEvent], int, int, int, wtypes.text,
wtypes.text)
def get_all(self, story_id=None, marker=None, limit=None, sort_field=None,
sort_dir=None):
"""Retrieve all events that have happened under specified story.
@ -122,7 +123,8 @@ class CommentsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Comment], int, int, int, unicode, unicode)
@wsme_pecan.wsexpose([wmodels.Comment], int, int, int, wtypes.text,
wtypes.text)
def get_all(self, story_id=None, marker=None, limit=None, sort_field='id',
sort_dir='asc'):
"""Retrieve all comments posted under specified story.
@ -234,7 +236,8 @@ class CommentsController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.Comment], unicode, unicode, int, int)
@wsme_pecan.wsexpose([wmodels.Comment], wtypes.text, wtypes.text, int,
int)
def search(self, q="", marker=None, limit=None):
"""The search endpoint for comments.

View File

@ -19,7 +19,7 @@ from pecan import abort
from pecan import request
from pecan import rest
from pecan.secure import secure
import wsme.types as types
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -38,7 +38,7 @@ class UserPreferencesController(rest.RestController):
@decorators.db_exceptions
@secure(checks.authenticated)
@wsme_pecan.wsexpose(types.DictType(unicode, unicode), int)
@wsme_pecan.wsexpose(wtypes.DictType(wtypes.text, wtypes.text), int)
def get_all(self, user_id):
"""Return all preferences for the current user.
"""
@ -50,8 +50,8 @@ class UserPreferencesController(rest.RestController):
@decorators.db_exceptions
@secure(checks.authenticated)
@wsme_pecan.wsexpose(types.DictType(unicode, unicode), int,
body=types.DictType(unicode, unicode))
@wsme_pecan.wsexpose(wtypes.DictType(wtypes.text, wtypes.text), int,
body=wtypes.DictType(wtypes.text, wtypes.text))
def post(self, user_id, body):
"""Allow a user to update their preferences. Note that a user must
explicitly set a preference value to Null/None to have it deleted.

View File

@ -23,6 +23,7 @@ from pecan import response
from pecan import rest
from pecan.secure import secure
import six
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -40,8 +41,8 @@ LOG = log.getLogger(__name__)
class UserTokensController(rest.RestController):
@decorators.db_exceptions
@secure(checks.authenticated)
@wsme_pecan.wsexpose([wmodels.AccessToken], int, int, int, unicode,
unicode)
@wsme_pecan.wsexpose([wmodels.AccessToken], int, int, int, wtypes.text,
wtypes.text)
def get_all(self, user_id, marker=None, limit=None, sort_field='id',
sort_dir='asc'):
"""Returns all the access tokens for the provided user.

View File

@ -20,6 +20,7 @@ from pecan import response
from pecan import rest
from pecan.secure import secure
import six
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from storyboard.api.auth import authorization_checks as checks
@ -55,8 +56,8 @@ class UsersController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.User], int, int, unicode, unicode, unicode,
unicode)
@wsme_pecan.wsexpose([wmodels.User], int, int, wtypes.text, wtypes.text,
wtypes.text, wtypes.text)
def get(self, marker=None, limit=None, username=None, full_name=None,
sort_field='id', sort_dir='asc'):
"""Page and filter the users in storyboard.
@ -157,7 +158,7 @@ class UsersController(rest.RestController):
@decorators.db_exceptions
@secure(checks.guest)
@wsme_pecan.wsexpose([wmodels.User], unicode, int, int)
@wsme_pecan.wsexpose([wmodels.User], wtypes.text, int, int)
def search(self, q="", marker=None, limit=None):
"""The search endpoint for users.

View File

@ -129,13 +129,13 @@ class Story(base.APIBase):
creator_id = int
"""User ID of the Story creator"""
status = unicode
status = wtypes.text
"""The derived status of the story, one of 'active', 'merged', 'invalid'"""
task_statuses = wtypes.ArrayType(TaskStatusCount)
"""The summary of each tasks/status."""
tags = wtypes.ArrayType(unicode)
tags = wtypes.ArrayType(wtypes.text)
"""Tag list assigned to this story."""
@classmethod

View File

@ -29,7 +29,7 @@ from storyboard.db import projects_loader
from storyboard.db import superusers_loader
from storyboard.openstack.common.gettextutils import _ # noqa
gettext.install('storyboard', unicode=1)
gettext.install('storyboard')
CONF = cfg.CONF

View File

@ -18,6 +18,7 @@ import yaml
from oslo.config import cfg
from oslo_log import log
import six
from sqlalchemy.exc import SADeprecationWarning
from storyboard.common.custom_types import NameType
@ -90,9 +91,9 @@ def do_load_models(filename):
def _get_project(project, session):
validator = NameType()
name = unicode(project['project'])
name = six.text_type(project['project'])
if 'description' in project:
description = unicode(project['description'])
description = six.text_type(project['description'])
else:
description = ''