json: fixed calls to json after orjson implementation
This commit is contained in:
parent
34af9cfa2f
commit
acbe2b54a6
22 changed files with 55 additions and 45 deletions
|
|
@ -40,7 +40,7 @@ from rhodecode.lib.exceptions import (
|
|||
UserCreationError, UserOwnsReposException, UserOwnsRepoGroupsException,
|
||||
UserOwnsUserGroupsException, UserOwnsPullRequestsException,
|
||||
UserOwnsArtifactsException, DefaultUserException)
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasPermissionAllDecorator, CSRFRequired)
|
||||
from rhodecode.lib import helpers as h
|
||||
|
|
@ -1169,7 +1169,7 @@ class UsersView(UserAppView):
|
|||
|
||||
groups = [UserGroupModel.get_user_groups_as_dict(group.users_group)
|
||||
for group in c.user.group_member]
|
||||
c.groups = json.dumps(groups)
|
||||
c.groups = ext_json.str_json(groups)
|
||||
c.active = 'groups'
|
||||
|
||||
return self._get_template_context(c)
|
||||
|
|
@ -1258,9 +1258,8 @@ class UsersView(UserAppView):
|
|||
for entry in user_log:
|
||||
audit_log_data[entry.user_log_id] = entry.get_dict()
|
||||
|
||||
response = Response(json.dumps(audit_log_data, indent=4))
|
||||
response.content_disposition = str(
|
||||
'attachment; filename=%s' % 'user_{}_audit_logs.json'.format(c.user.user_id))
|
||||
response = Response(ext_json.formatted_str_json(audit_log_data))
|
||||
response.content_disposition = f'attachment; filename=user_{c.user.user_id}_audit_logs.json'
|
||||
response.content_type = 'application/json'
|
||||
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from pyramid.settings import asbool
|
|||
|
||||
from rhodecode.apps._base import ADMIN_PREFIX
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib.str_utils import safe_str
|
||||
|
||||
|
||||
def url_gen(request):
|
||||
|
|
@ -38,7 +39,7 @@ def url_gen(request):
|
|||
'longpoll': longpoll_url or proxy_url,
|
||||
'ws': ws_url or proxy_url.replace('http', 'ws')
|
||||
}
|
||||
return json.dumps(urls)
|
||||
return safe_str(json.dumps(urls))
|
||||
|
||||
|
||||
PLUGIN_DEFINITION = {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ from pyramid.renderers import render
|
|||
from pyramid.response import Response
|
||||
|
||||
from rhodecode.apps._base import BaseAppView
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib import helpers as h, ext_json
|
||||
from rhodecode.lib.auth import LoginRequired, NotAnonymous, CSRFRequired
|
||||
from rhodecode.lib.utils2 import time_to_datetime
|
||||
from rhodecode.lib.ext_json import json
|
||||
|
|
@ -124,7 +124,7 @@ class GistView(BaseAppView):
|
|||
'expires': _render('gist_expires', gist.gist_expires),
|
||||
'description': _render('gist_description', gist.gist_description)
|
||||
})
|
||||
c.data = json.dumps(data)
|
||||
c.data = ext_json.str_json(data)
|
||||
|
||||
return self._get_template_context(c)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from rhodecode.apps._base import BaseAppView, DataGridAppView
|
|||
from rhodecode import forms
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib import audit_logger
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, NotAnonymous, CSRFRequired,
|
||||
HasRepoPermissionAny, HasRepoGroupPermissionAny, AuthUser)
|
||||
|
|
@ -457,7 +457,7 @@ class MyAccountView(BaseAppView, DataGridAppView):
|
|||
repos_data.append(row)
|
||||
|
||||
# json used to render the grid
|
||||
return json.dumps(repos_data)
|
||||
return ext_json.str_json(repos_data)
|
||||
|
||||
@LoginRequired()
|
||||
@NotAnonymous()
|
||||
|
|
@ -779,5 +779,5 @@ class MyAccountView(BaseAppView, DataGridAppView):
|
|||
c.active = 'user_group_membership'
|
||||
groups = [UserGroupModel.get_user_groups_as_dict(group.users_group)
|
||||
for group in self._rhodecode_db_user.group_member]
|
||||
c.user_groups = json.dumps(groups)
|
||||
c.user_groups = ext_json.str_json(groups)
|
||||
return self._get_template_context(c)
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@ import logging
|
|||
|
||||
from pyramid.httpexceptions import HTTPNotFound
|
||||
|
||||
|
||||
from rhodecode.apps._base import BaseReferencesView
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
|
||||
|
||||
|
|
@ -47,5 +46,5 @@ class RepoBookmarksView(BaseReferencesView):
|
|||
ref_items=ref_items, partials_template='bookmarks/bookmarks_data.mako')
|
||||
|
||||
c.has_references = bool(data)
|
||||
c.data = json.dumps(data)
|
||||
c.data = ext_json.str_json(data)
|
||||
return self._get_template_context(c)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import logging
|
|||
|
||||
|
||||
from rhodecode.apps._base import BaseReferencesView
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
|
||||
|
||||
|
||||
|
|
@ -42,5 +42,5 @@ class RepoBranchesView(BaseReferencesView):
|
|||
ref_items=ref_items, partials_template='branches/branches_data.mako')
|
||||
|
||||
c.has_references = bool(data)
|
||||
c.data = json.dumps(data)
|
||||
c.data = ext_json.str_json(data)
|
||||
return self._get_template_context(c)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ from pyramid.response import Response
|
|||
|
||||
from rhodecode.apps._base import RepoAppView
|
||||
import rhodecode.lib.helpers as h
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator)
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ class RepoChangelogView(RepoAppView):
|
|||
|
||||
data = [[commit_id, vtx, edges, branch]
|
||||
for commit_id, vtx, edges, branch in _colored(dag)]
|
||||
return json.dumps(data), json.dumps(current)
|
||||
return ext_json.str_json(data), ext_json.str_json(current)
|
||||
|
||||
def _check_if_valid_branch(self, branch_name, repo_name, f_path):
|
||||
if branch_name not in self.rhodecode_vcs_repo.branches_all:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from rhodecode.apps.file_store.exceptions import FileNotAllowedException, FileOv
|
|||
from rhodecode.lib import diffs, codeblocks, channelstream
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous, CSRFRequired)
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from collections import OrderedDict
|
||||
from rhodecode.lib.diffs import (
|
||||
cache_diff, load_cached_diff, diff_cache_exist, get_diff_context,
|
||||
|
|
@ -218,7 +218,7 @@ class RepoCommitsView(RepoAppView):
|
|||
member_reviewer['allowed_to_update'] = False
|
||||
c.commit_set_reviewers_data_json['reviewers'].append(member_reviewer)
|
||||
|
||||
c.commit_set_reviewers_data_json = json.dumps(c.commit_set_reviewers_data_json)
|
||||
c.commit_set_reviewers_data_json = ext_json.str_json(c.commit_set_reviewers_data_json)
|
||||
|
||||
# NOTE(marcink): this uses the same voting logic as in pull-requests
|
||||
c.commit_review_status = ChangesetStatusModel().calculate_status(review_statuses)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from rhodecode.lib import helpers as h, diffs, codeblocks, channelstream
|
|||
from rhodecode.lib.base import vcs_operation_context
|
||||
from rhodecode.lib.diffs import load_cached_diff, cache_diff, diff_cache_exist
|
||||
from rhodecode.lib.exceptions import CommentVersionMismatch
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAny, HasRepoPermissionAnyDecorator,
|
||||
NotAnonymous, CSRFRequired)
|
||||
|
|
@ -468,7 +468,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
c.observers_count = pull_request.observers_count
|
||||
|
||||
# reviewers and statuses
|
||||
c.pull_request_default_reviewers_data_json = json.dumps(pull_request.reviewer_data)
|
||||
c.pull_request_default_reviewers_data_json = ext_json.str_json(pull_request.reviewer_data)
|
||||
c.pull_request_set_reviewers_data_json = collections.OrderedDict({'reviewers': []})
|
||||
c.pull_request_set_observers_data_json = collections.OrderedDict({'observers': []})
|
||||
|
||||
|
|
@ -485,7 +485,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
member_reviewer['allowed_to_update'] = c.allowed_to_update
|
||||
c.pull_request_set_reviewers_data_json['reviewers'].append(member_reviewer)
|
||||
|
||||
c.pull_request_set_reviewers_data_json = json.dumps(c.pull_request_set_reviewers_data_json)
|
||||
c.pull_request_set_reviewers_data_json = ext_json.str_json(c.pull_request_set_reviewers_data_json)
|
||||
|
||||
for observer_obj, member in pull_request_at_ver.observers():
|
||||
member_observer = h.reviewer_as_json(
|
||||
|
|
@ -496,7 +496,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
member_observer['allowed_to_update'] = c.allowed_to_update
|
||||
c.pull_request_set_observers_data_json['observers'].append(member_observer)
|
||||
|
||||
c.pull_request_set_observers_data_json = json.dumps(c.pull_request_set_observers_data_json)
|
||||
c.pull_request_set_observers_data_json = ext_json.str_json(c.pull_request_set_observers_data_json)
|
||||
|
||||
general_comments, inline_comments = \
|
||||
self.register_comments_vars(c, pull_request_latest, versions)
|
||||
|
|
@ -889,9 +889,9 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
|
||||
c.default_repo_data = {
|
||||
'source_repo_name': source_repo.repo_name,
|
||||
'source_refs_json': json.dumps(source_repo_data),
|
||||
'source_refs_json': ext_json.str_json(source_repo_data),
|
||||
'target_repo_name': default_target_repo.repo_name,
|
||||
'target_refs_json': json.dumps(target_repo_data),
|
||||
'target_refs_json': ext_json.str_json(target_repo_data),
|
||||
}
|
||||
c.default_source_ref = selected_source_ref
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
import logging
|
||||
|
||||
from rhodecode.apps._base import BaseReferencesView
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -40,5 +40,5 @@ class RepoTagsView(BaseReferencesView):
|
|||
ref_items=ref_items, partials_template='tags/tags_data.mako')
|
||||
|
||||
c.has_references = bool(data)
|
||||
c.data = json.dumps(data)
|
||||
c.data = ext_json.str_json(data)
|
||||
return self._get_template_context(c)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib import ext_json
|
||||
|
||||
|
||||
def pyramid_ext_json(info):
|
||||
|
|
@ -34,7 +34,8 @@ def pyramid_ext_json(info):
|
|||
if ct == response.default_content_type:
|
||||
response.content_type = 'application/json'
|
||||
indent = getattr(request, 'ext_json_indent', None)
|
||||
|
||||
return json.dumps(value, indent=indent)
|
||||
if indent:
|
||||
return ext_json.formatted_json(value)
|
||||
return ext_json.json.dumps(value)
|
||||
|
||||
return _render
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ from webhelpers2.number import format_byte_size
|
|||
|
||||
from rhodecode.lib.action_parser import action_parser
|
||||
from rhodecode.lib.pagination import Page, RepoPage, SqlPage
|
||||
from rhodecode.lib import ext_json
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.lib.str_utils import safe_bytes
|
||||
from rhodecode.lib.utils import repo_name_slug, get_custom_lexer
|
||||
from rhodecode.lib.utils2 import (
|
||||
str2bool, safe_unicode, safe_str,
|
||||
|
|
@ -135,6 +137,14 @@ def html_escape(text, html_escape_table=default_html_escape_table):
|
|||
return text.translate(html_escape_table)
|
||||
|
||||
|
||||
def str_json(*args, **kwargs):
|
||||
return ext_json.str_json(*args, **kwargs)
|
||||
|
||||
|
||||
def formatted_str_json(*args, **kwargs):
|
||||
return ext_json.formatted_str_json(*args, **kwargs)
|
||||
|
||||
|
||||
def chop_at_smart(s, sub, inclusive=False, suffix_if_chopped=None):
|
||||
"""
|
||||
Truncate string ``s`` at the first occurrence of ``sub``.
|
||||
|
|
@ -346,7 +356,7 @@ def files_url_data(request):
|
|||
if 'commit_id' not in matchdict:
|
||||
matchdict['commit_id'] = 'tip'
|
||||
|
||||
return json.dumps(matchdict)
|
||||
return ext_json.str_json(matchdict)
|
||||
|
||||
|
||||
def repo_files_by_ref_url(db_repo_name, db_repo_type, f_path, ref_name, commit_id, query=None, ):
|
||||
|
|
@ -768,7 +778,7 @@ class Flash(object):
|
|||
'subdata': message.sub_data
|
||||
}
|
||||
})
|
||||
return json.dumps(payloads)
|
||||
return safe_str(json.dumps(payloads))
|
||||
|
||||
def __call__(self, message, category=None, ignore_duplicate=True,
|
||||
session=None, request=None):
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ def write_usage_data(event):
|
|||
)
|
||||
|
||||
with open(dest_file, 'wb') as f:
|
||||
f.write(ext_json.json.dumps(metadata, indent=2, sort_keys=True))
|
||||
f.write(ext_json.formatted_json(metadata))
|
||||
|
||||
try:
|
||||
log.debug('Writing usage file at: %s', usage_metadata_destination)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
<td class="td-journalaction">
|
||||
% if c.audit_log_entry.version == c.audit_log_entry.VERSION_2:
|
||||
<div>
|
||||
<pre>${h.json.dumps(c.audit_log_entry.action_data, indent=4, sort_keys=True)}</pre>
|
||||
<pre>${h.formatted_str_json(c.audit_log_entry.action_data)}</pre>
|
||||
</div>
|
||||
% else:
|
||||
<pre title="${_('data not available for v1 entries type')}">-</pre>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
% if l.version == l.VERSION_2:
|
||||
<a href="#" onclick="$('#entry-'+${l.user_log_id}).toggle();return false">${_('toggle')}</a>
|
||||
<div id="entry-${l.user_log_id}" style="display: none">
|
||||
<pre>${h.json.dumps(l.action_data, indent=4, sort_keys=True)}</pre>
|
||||
<pre>${h.formatted_str_json(l.action_data)}</pre>
|
||||
</div>
|
||||
% else:
|
||||
<pre title="${_('data not available for v1 entries type')}">-</pre>
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ examples = [
|
|||
% if loop.index == 0:
|
||||
<a href="#showMore" onclick="$('.it-examples').toggle(); return false">${_('show examples')}</a>
|
||||
% else:
|
||||
<a href="#copyToInput" onclick="copyToInput(this, '${h.json.dumps(name)}', '${h.json.dumps(pat)}', '${h.json.dumps(url)}', '${h.json.dumps(pref)}'); return false">copy to input</a>
|
||||
<a href="#copyToInput" onclick="copyToInput(this, '${h.str_json(name)}', '${h.str_json(pat)}', '${h.str_json(url)}', '${h.str_json(pref)}'); return false">copy to input</a>
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ c.template_context['attachment_store'] = {
|
|||
<script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script>
|
||||
<script type="text/javascript">
|
||||
// register templateContext to pass template variables to JS
|
||||
var templateContext = ${h.json.dumps(c.template_context)|n};
|
||||
var templateContext = ${h.str_json(c.template_context)|n};
|
||||
|
||||
var APPLICATION_URL = "${h.route_path('home').rstrip('/')}";
|
||||
var APPLICATION_PLUGINS = [];
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
% endif
|
||||
|
||||
<%
|
||||
data = h.json.dumps({
|
||||
data = h.str_json({
|
||||
'comment_id': comment_obj.comment_id,
|
||||
'version_info': version_info,
|
||||
'file_name': comment_obj.f_path,
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@
|
|||
line="${comment.line_no}"
|
||||
data-comment-id="${comment.comment_id}"
|
||||
data-comment-type="${comment.comment_type}"
|
||||
data-comment-draft=${h.json.dumps(comment.draft)}
|
||||
data-comment-draft=${h.str_json(comment.draft)}
|
||||
data-comment-renderer="${comment.renderer}"
|
||||
data-comment-text="${comment.text | html_filters.base64,n}"
|
||||
data-comment-f-path="${comment.f_path}"
|
||||
data-comment-line-no="${comment.line_no}"
|
||||
data-comment-inline=${h.json.dumps(inline)}
|
||||
data-comment-inline=${h.str_json(inline)}
|
||||
style="${'display: none;' if outdated_at_ver else ''}">
|
||||
|
||||
<div class="meta">
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
% if comment.resolved_comment:
|
||||
<div class="tooltip" title="${_('This comment resolves TODO #{}').format(comment.resolved_comment.comment_id)}">
|
||||
fix
|
||||
<a href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})">
|
||||
<a href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.str_json(comment.resolved_comment.outdated)})">
|
||||
<span style="text-decoration: line-through">#${comment.resolved_comment.comment_id}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -547,7 +547,7 @@
|
|||
<i class="icon-info-circled tooltip-hovercard"
|
||||
data-hovercard-alt="ALT"
|
||||
data-hovercard-url="javascript:commentHelp('${c.visual.default_renderer.upper()}')"
|
||||
data-comment-json-b64='${h.b64(h.json.dumps({}))}'></i>
|
||||
data-comment-json-b64='${h.b64(h.str_json({}))}'></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1114,7 +1114,7 @@ def get_comments_for(diff_type, comments, filename, line_version, line_number):
|
|||
% for filediff in diffset.files:
|
||||
{id:"a_${h.FID(filediff.raw_id, filediff.patch['filename'])}",
|
||||
text:"${filediff.patch['filename']}",
|
||||
ops:${h.json.dumps(filediff.patch['stats'])|n}}${('' if loop.last else ',')}
|
||||
ops:${h.str_json(filediff.patch['stats'])|n}}${('' if loop.last else ',')}
|
||||
% endfor
|
||||
]
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<span style="white-space: pre-line">- ${pr_check_details['message']}</span>
|
||||
% if pr_check_key == 'todo':
|
||||
% for co in pr_check_details['details']:
|
||||
<a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'), 0, ${h.json.dumps(co.outdated)})"> #${co.comment_id}</a>${'' if loop.last else ','}
|
||||
<a class="permalink" href="#comment-${co.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${co.comment_id}'), 0, ${h.str_json(co.outdated)})"> #${co.comment_id}</a>${'' if loop.last else ','}
|
||||
% endfor
|
||||
% endif
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
import pytest
|
||||
import urllib.parse
|
||||
import mock
|
||||
import simplejson as json
|
||||
|
||||
from rhodecode.lib.vcs.backends.base import Config
|
||||
from rhodecode.tests.lib.middleware import mock_scm_app
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue