-
Notifications
You must be signed in to change notification settings - Fork 5
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
Django Integration: Documentation and URL handling #4
Comments
@mattpap @philippjfr I asked for the issue to be made because I'm not sure it points to a need for docs/examples, or if there is some useful feature work that could be prompted |
I'm actively using these feature(s) so I figure I will update this comment as I go with things I notice / functionality improvements. Logging
|
When you request the app interface, you can carry the data and modify your code
and in app app_handler func
But I had other problems In the HTML file of another server, AJAX carries the parameter request interface to get the returned script and execute it..There is no problem with the first access, but there is no response after the second access only modifies the parameters |
Hey @yanwencheng , you'll have to be a little more descriptive - does "wriId" exist in **request.POST.dict() (or GET), otherwise I don't see how you are fetching a valid value, which would cause it to silently fail on the KeyError as I mentioned. Otherwise it looks fine and if you are saying the graph appears on the first request then I think you should definitely investigate what the value of wriID is when the graph doesn't render. |
Combined POST and GET request parameters,Use args = doc.session_context.request.arguments when generating bokeh documents |
@bryevdv Am I correct in that bokeh/bokeh#9536 would allow me to access other arguments on the request object and enable me to do (I'll try to keep it as purely-bokeh-related as possible, treat From what I can tell, and this includes separate from django, an autoloadjsConsumer (or document - though I'm not all that sure what this does) that extends In any case, this prompts a possible feature - user synchronization between django and bokeh. It would be nice, if bokeh is living in a django environment, to optionally take advantage of the powerful django session, auth (might solve some problems mentioned in bokeh/bokeh#9536?), and user modules, it's already confusing enough that |
I took a stab at implementing something like this before finding this issue - see bokeh/bokeh#9946 & bokeh/bokeh#9947 |
Take a look at PR #6 and let me know if you have any feedback. Here are the key points from the expanded examples in the PR:
urlpatterns = [
path("shapes/<str:arg1>/<str:arg2>", views.shapes_with_args),
]
bokeh_apps = [
autoload("shapes/(?P<arg1>[\w_\-]+)/(?P<arg2>[\w_\-]+)", views.shape_viewer_handler_with_args),
] Note that
from bokeh_django import with_url_args
@with_url_args
def shape_viewer_handler_with_args(doc, arg1, arg2):
viewer = shape_viewer()
pn.Column(
viewer,
pn.pane.Markdown(f'## This app has URL Args: {arg1} and {arg2}')
).server_doc(doc)
def shapes_with_args(request: HttpRequest, arg1: str, arg2: str) -> HttpResponse:
script = server_document(request.get_full_path())
return render(request, "embed.html", dict(script=script)) Note that |
Created from discussion around this discourse topic.
The main feature I am interested in is properly using
autoload
frombokeh.server.django
to access a bokeh app without mangling the url in the request function. To demonstrate this, consider the django project namedproject
and just using views/urls within said project directory (this could easily be extended to be contained within an app). Currently the following has to be done in order to support the generic 'title':Ideally, you could indicate to autoload that it will take a parameter and it would make that parameter available to that handler. Note that it is already technically available to the handler under doc.session_context.arguments, however I still had to explicitly put "/home/x"
A few issues from this example:
and substitute it into
django/routing.py
inadd_new_routing(...)
:self._websocket_urlpatterns.append(url(urlpattern("/ws"), Wrapper, kwargs=kwargs))
3. Documentation is lacking all around here, for instance what is the difference/the use cases between
DocConsumer (document())
andAutoloadJsConsumer (autoload)
If a full project directory is required I will happily provide, but I think that this is mainly a documentation issue - I am happy to contribute!
This is on bokeh version 1.4.0, I looked at the recent commit bokeh/bokeh#9536 but that seemed to have just added token support so what I have put here should be up to date, at least concerning what I am discussing here!
The text was updated successfully, but these errors were encountered: