Open Jesse-vd-Linden opened 9 months ago
hello, I see the same thing by simply running the example in django_embed
python manage.py runserver
and then browsing
http://127.0.0.1:8000/shape_viewer
or
http://127.0.0.1:8000/shapes
error:
February 14, 2024 - 07:26:50
Django version 4.2.7, using settings 'django_embed.settings'
Starting ASGI/Channels version 3.0.5 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
HTTP GET /shapes 200 [0.02, 127.0.0.1:62960]
ERROR:bokeh.application.application:Error running application handler <bokeh.application.handlers.function.FunctionHandler object at 0x1153eb350>: 'protocol'
File 'consumers.py', line 352, in __getattr__:
return self[key] Traceback (most recent call last):
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/bokeh/application/handlers/function.py", line 140, in modify_document
self._func(doc)
File "/Users/helsens/Software/github/bokeh-django/examples/django_embed/django_embed/views.py", line 27, in shape_viewer_handler
panel.server_doc(doc)
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/panel/viewable.py", line 1044, in server_doc
self._add_location(doc, location, model)
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/panel/viewable.py", line 332, in _add_location
loc = state.location
^^^^^^^^^^^^^^
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/panel/io/state.py", line 1015, in location
loc = Location.from_request(self.curdoc.session_context.request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/panel/io/location.py", line 75, in from_request
if request.protocol:
^^^^^^^^^^^^^^^^
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/bokeh/server/contexts.py", line 378, in __getattr__
val = getattr(self._request, name, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/helsens/miniconda3/envs/django_seg/lib/python3.11/site-packages/bokeh_django/consumers.py", line 352, in __getattr__
return self[key]
~~~~^^^^^
KeyError: 'protocol'
Could you please have a look?
Could you open a new issue in Panel since it probably has to be patched there.
Could you open a new issue in Panel since it probably has to be patched there.
@philippjfr
I was able to patch this in bokeh-django
with:
class ConsumerHelper(AsyncConsumer):
_prefix = "/"
@property
def request(self) -> "AttrDict":
request = AttrDict(self.scope)
request["arguments"] = self.arguments
# patch for panel 1.4
request['protocol'] = request.get('scheme')
for k, v in request.headers:
request[k.decode()] = v.decode()
request['uri'] = request.get('path')
return request
Do you think this is sufficient, or should changes be made in panel
?
Hi There,
I am using the bokeh-django package to display a panel.chat.ChatInterface on my website.
The chat using the following panel_handler
And is added to the bokeh_app with an autoload
After using the setup instructions for the README I was finally able to display the ChatInterface. For this, I did have to alter the following in the setting.py
If I use the the resources setting as server, it does not seem to find the static files from Panel.
However when using the inline as setting it does load the chat panel, but I am getting the error that protocol is not a key in the _RequestProxy object. Is this due to changing the bokeh_settings?
Current dependencies are: bokeh==3.2.0 bokeh-django==0.1.0 channels==3.0.5 daphne==3.0.2 Django==4.2.9 Jinja2==3.1.3 panel==1.3.0 tornado==6.4