Skip to content

Commit c3a1940

Browse files
committed
align examples to mixin
1 parent 8aca33c commit c3a1940

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

examples/simple/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ You need `python3` to build and run the server extensions.
1010
# Clone, create a conda env and install from source.
1111
git clone https://github.com/jupyter/jupyter_server && \
1212
cd examples/simple && \
13-
conda create -y -n jupyter_server_example python=3.7 && \
14-
conda activate jupyter_server_example && \
13+
conda create -y -n jupyter-server-example python=3.7 && \
14+
conda activate jupyter-server-example && \
1515
pip install -e .
1616
```
1717

@@ -154,7 +154,7 @@ Stop any running server and then start the simple-ext11.
154154

155155
```bash
156156
jupyter simple-ext11 --hello --simple11-dir any_folder
157-
# or...
157+
# TODO FIX the following command, simple11 does not work launching with jpserver_extensions parameter.
158158
jupyter server --ServerApp.jpserver_extensions="{'simple_ext11': True}" --hello --simple11-dir any_folder
159159
```
160160

examples/simple/simple_ext1/handlers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from jupyter_server.extension.handler import ExtensionHandler, ExtensionHandlerJinjaMixin
1+
from jupyter_server.base.handlers import JupyterHandler
2+
from jupyter_server.extension.handler import ExtensionHandlerMixin, ExtensionHandlerJinjaMixin
23

3-
class DefaultHandler(ExtensionHandler):
4+
class DefaultHandler(ExtensionHandlerMixin, JupyterHandler):
45
def get(self):
56
# The name of the extension to which this handler is linked.
67
self.log.info("Extension Name in {} Default Handler: {}".format(self.extension_name, self.extension_name))
@@ -9,11 +10,11 @@ def get(self):
910
self.write('<h1>Hello Simple 1 - I am the default...</h1>')
1011
self.write('Config in {} Default Handler: {}'.format(self.extension_name, self.config))
1112

12-
class RedirectHandler(ExtensionHandler):
13+
class RedirectHandler(ExtensionHandlerMixin, JupyterHandler):
1314
def get(self):
1415
self.redirect("/static/{}/favicon.ico".format(self.extension_name))
1516

16-
class ParameterHandler(ExtensionHandler):
17+
class ParameterHandler(ExtensionHandlerMixin, JupyterHandler):
1718
def get(self, matched_part=None, *args, **kwargs):
1819
var1 = self.get_argument('var1', default=None)
1920
components = [x for x in self.request.path.split("/") if x]
@@ -22,7 +23,7 @@ def get(self, matched_part=None, *args, **kwargs):
2223
self.write('<p>var1: {}</p>'.format(var1))
2324
self.write('<p>components: {}</p>'.format(components))
2425

25-
class BaseTemplateHandler(ExtensionHandlerJinjaMixin, ExtensionHandler): pass
26+
class BaseTemplateHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler): pass
2627

2728
class TypescriptHandler(BaseTemplateHandler):
2829
def get(self):

examples/simple/simple_ext11/application.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def initialize_settings(self):
6161
self.log.info('ignore_js: {}'.format(self.ignore_js))
6262
super().initialize_settings()
6363

64+
def initialize_handlers(self):
65+
super().initialize_handlers()
66+
6467
#-----------------------------------------------------------------------------
6568
# Main entry point
6669
#-----------------------------------------------------------------------------

examples/simple/simple_ext2/handlers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from jupyter_server.extension.handler import ExtensionHandler, ExtensionHandlerJinjaMixin
1+
from jupyter_server.base.handlers import JupyterHandler
2+
from jupyter_server.extension.handler import ExtensionHandlerMixin, ExtensionHandlerJinjaMixin
23

3-
class ParameterHandler(ExtensionHandler):
4+
class ParameterHandler(ExtensionHandlerMixin, JupyterHandler):
45
def get(self, matched_part=None, *args, **kwargs):
56
var1 = self.get_argument('var1', default=None)
67
components = [x for x in self.request.path.split("/") if x]
@@ -9,7 +10,7 @@ def get(self, matched_part=None, *args, **kwargs):
910
self.write('<p>var1: {}</p>'.format(var1))
1011
self.write('<p>components: {}</p>'.format(components))
1112

12-
class BaseTemplateHandler(ExtensionHandlerJinjaMixin, ExtensionHandler): pass
13+
class BaseTemplateHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler): pass
1314

1415
class IndexHandler(BaseTemplateHandler):
1516
def get(self):

0 commit comments

Comments
 (0)