Skip to content
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

inject_filter_options is added to template context even when not needed #317

Closed
jace opened this issue Apr 1, 2016 · 4 comments
Closed

Comments

@jace
Copy link
Member

jace commented Apr 1, 2016

In hasjob.views.helper.inject_filter_options, as an app context processor, it's called for every single query whether it's needed or not. Rather than insert actual values, it should insert functions which the template can call when needed.

@iambibhas
Copy link
Contributor

The issue with inserting functions is that cache can't be set. It can't pickle function objects.

@jace
Copy link
Member Author

jace commented Apr 21, 2016

Fair point, so let's have the outer function return an inner function, which hits cache. Rather than return a dict of job_location_filters, job_type_filters and job_category_filters, we return a dict with a single key, job_filters, which is a function that when called returns another dict with the above three keys.

The templates will have to be updated accordingly.

@iambibhas
Copy link
Contributor

But the values of job_filters will still be a function, right? Which will raise the same issue?

@jace
Copy link
Member Author

jace commented Apr 21, 2016

No, it will be actual values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants