Skip to content

Commit b917da2

Browse files
committed
Patches to support Panel 1.4 and Bokeh 3.4
1 parent ecdbda3 commit b917da2

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ This documentation assumes that you have already started a [Django project](http
7070
If the Bokeh ``resources`` setting is set to ``server`` then we must add the location of the Bokeh resources to the ``STATICFILES_DIRS`` setting:
7171

7272
```python
73-
from bokeh.settings import settings as bokeh_settings, bokehjsdir
73+
from bokeh.settings import settings as bokeh_settings
74+
75+
try:
76+
bokeh_js_dir = bokeh_settings.bokehjs_path()
77+
except AttributeError:
78+
# support bokeh versions < 3.4
79+
bokeh_js_dir = bokeh_settings.bokehjsdir()
7480

7581
STATICFILES_DIRS = [
7682
...,
77-
bokehjsdir(),
83+
bokeh_js_dir,
7884
]
7985
```
8086

bokeh_django/consumers.py

+7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ class ConsumerHelper(AsyncConsumer):
7979
def request(self) -> "AttrDict":
8080
request = AttrDict(self.scope)
8181
request["arguments"] = self.arguments
82+
83+
# patch for panel 1.4
84+
request['protocol'] = request.get('scheme')
85+
for k, v in request.headers:
86+
request[k.decode()] = v.decode()
87+
request['uri'] = request.get('path')
88+
8289
return request
8390

8491
@property

examples/django_embed/django_embed/settings.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
from pathlib import Path
1414

15-
from bokeh.settings import bokehjsdir, settings as bokeh_settings
15+
from bokeh.settings import settings as bokeh_settings
16+
17+
try:
18+
bokeh_js_dir = bokeh_settings.bokehjs_path()
19+
except AttributeError:
20+
# support bokeh versions < 3.4
21+
bokeh_js_dir = bokeh_settings.bokehjsdir()
1622

1723
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1824
MODULE_DIR = Path(__file__).resolve().parent
@@ -127,7 +133,7 @@
127133

128134
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
129135

130-
STATICFILES_DIRS = [bokehjsdir()]
136+
STATICFILES_DIRS = [bokeh_js_dir]
131137

132138
STATICFILES_FINDERS = (
133139
"django.contrib.staticfiles.finders.FileSystemFinder",

examples/django_embed/django_embed/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
autoload("sea-surface-temp", views.sea_surface_handler),
4747
autoload("sea_surface_custom_uri", views.sea_surface_handler),
4848
autoload("shapes", views.shape_viewer_handler),
49-
autoload("shapes/(?P<arg1>[\w_\-]+)/(?P<arg2>[\w_\-]+)", views.shape_viewer_handler_with_args),
49+
autoload(r"shapes/(?P<arg1>[\w_\-]+)/(?P<arg2>[\w_\-]+)", views.shape_viewer_handler_with_args),
5050
]

0 commit comments

Comments
 (0)