-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [#1078] package_show performance improvements #1079
Changes from all commits
53a4e5c
b885935
973bb8c
89dd89e
4e2f721
709bb89
d01e5a4
f2a4822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import logging | ||
import json | ||
import datetime | ||
import socket | ||
|
||
from pylons import config | ||
import sqlalchemy | ||
|
@@ -752,22 +753,34 @@ def package_show(context, data_dict): | |
|
||
_check_access('package_show', context, data_dict) | ||
|
||
package_dict = model_dictize.package_dictize(pkg, context) | ||
|
||
for item in plugins.PluginImplementations(plugins.IPackageController): | ||
item.read(pkg) | ||
|
||
package_plugin = lib_plugins.lookup_package_plugin(package_dict['type']) | ||
if 'schema' in context: | ||
schema = context['schema'] | ||
else: | ||
schema = package_plugin.show_package_schema() | ||
package_dict = None | ||
no_cache_context = ['revision_id', 'revision_date', 'schema'] | ||
if not any(k in context for k in no_cache_context): | ||
try: | ||
package_dict = search.show(name_or_id)['data_dict'] | ||
except (search.SearchError, socket.error): | ||
pass | ||
if not context.get('json_string', False): | ||
package_dict = json.loads(package_dict) | ||
else: | ||
context['json_string_returned'] = True | ||
if not package_dict: | ||
package_dict = model_dictize.package_dictize(pkg, context) | ||
|
||
if schema and context.get('validate', True): | ||
package_dict, errors = _validate(package_dict, schema, context=context) | ||
package_plugin = lib_plugins.lookup_package_plugin(package_dict['type']) | ||
if 'schema' in context: | ||
schema = context['schema'] | ||
else: | ||
schema = package_plugin.show_package_schema() | ||
|
||
for item in plugins.PluginImplementations(plugins.IPackageController): | ||
item.after_show(context, package_dict) | ||
if schema and context.get('validate', True): | ||
package_dict, errors = _validate(package_dict, schema, context=context) | ||
|
||
for item in plugins.PluginImplementations(plugins.IPackageController): | ||
item.after_show(context, package_dict) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks a problem. If I add/remove a plugin from my .ini then it should change the results I see. I'm not sure how we deal with this currently with the solr index. unfortunately this part may need the json -> dict -> json cycle if IPackageControllers exist I'm not sure how we can get around this with the current interface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if our schemas were possible to serialize (using converter names instead of functions, say) then the validated data could store the hash of the schema that was used for generating it |
||
|
||
return package_dict | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the email I'd prefer
"return_type": "json"
the implicit default being"dict"