This change makes it possible for regulations-site to pull content from a regulations-core API running in the same Django instance by directly making Python calls instead of using HTTP requests.
By defining the Django setting EREGS_REGCORE_URLS and setting it to the path to your regulations-core URLconf (likely regcore.urls), the API will, instead of using HTTP to make requests, just call the Django views directly.
When running in the same Django installation as regulations-core this saves time and reduces load on the web server.
If this setting is not defined then behavior falls back to the current method of using HTTP requests based on the EREGS_API_BASE environment variable.
The best way to test this in action is to observe that if you run the Django debug server with this setting, you won't see any requests to the regcore API when making regsite requests.
I've added several unit tests that attempt to cover this change. Behavior should be similar to the current HTTP-based approach. If the Django view returns a 404 or raises an Http404 then the API returns None. If the view raises an exception, then the API will pass that along. Otherwise, the view just passes back the JSON content of the regcore view response as if it had been retrieved via HTTP.
This change makes it possible for regulations-site to pull content from a regulations-core API running in the same Django instance by directly making Python calls instead of using HTTP requests.
By defining the Django setting
EREGS_REGCORE_URLS
and setting it to the path to your regulations-core URLconf (likelyregcore.urls
), the API will, instead of using HTTP to make requests, just call the Django views directly.When running in the same Django installation as regulations-core this saves time and reduces load on the web server.
If this setting is not defined then behavior falls back to the current method of using HTTP requests based on the
EREGS_API_BASE
environment variable.The best way to test this in action is to observe that if you run the Django debug server with this setting, you won't see any requests to the regcore API when making regsite requests.
I've added several unit tests that attempt to cover this change. Behavior should be similar to the current HTTP-based approach. If the Django view returns a 404 or raises an
Http404
then the API returnsNone
. If the view raises an exception, then the API will pass that along. Otherwise, the view just passes back the JSON content of the regcore view response as if it had been retrieved via HTTP.