Skip to content

Commit cf11cfc

Browse files
committed
Ported the codebase and tests over to js-host.
1 parent c83ff2f commit cf11cfc

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

react/bundle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
import tempfile
44
from webpack.compiler import webpack
5-
from service_host.conf import settings as service_host_settings
5+
from js_host.conf import settings as js_host_settings
66
from .templates import BUNDLE_CONFIG, BUNDLE_TRANSLATE_CONFIG, DEVTOOL_CONFIG
77
from .conf import settings
88

@@ -34,7 +34,7 @@ def get_webpack_config(path, translate=None, path_to_react=None, devtool=None):
3434
if devtool is None:
3535
devtool = settings.DEVTOOL
3636

37-
node_modules = os.path.join(service_host_settings.SOURCE_ROOT, 'node_modules')
37+
node_modules = os.path.join(js_host_settings.SOURCE_ROOT, 'node_modules')
3838

3939
if path_to_react is None:
4040
path_to_react = settings.PATH_TO_REACT or os.path.join(node_modules, 'react')

react/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class Conf(conf.Conf):
1414
# bundling components
1515
WATCH_SOURCE_FILES = False
1616

17-
SERVICE_NAME = 'react'
17+
FUNCTION_NAME = 'react'
1818

1919
settings = Conf()

react/render.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from optional_django.serializers import JSONEncoder
66
from optional_django.safestring import mark_safe
77
from optional_django import six
8-
from service_host.service import Service
9-
from service_host.exceptions import ServiceError
8+
from js_host.function import Function
9+
from js_host.exceptions import JSFunctionError
1010
from .exceptions import ComponentSourceFileNotFound, ComponentWasNotBundled
1111
from .conf import settings
1212
from .bundle import bundle_component
1313
from .templates import MOUNT_JS
1414
from .exceptions import ReactRenderingError
1515

16-
service = Service(settings.SERVICE_NAME)
16+
function = Function(settings.FUNCTION_NAME)
1717

1818

1919
class RenderedComponent(object):
@@ -118,16 +118,14 @@ def render_component(
118118
serialized_props = None
119119

120120
try:
121-
res = service.call(
121+
markup = function.call(
122122
path=path_to_source,
123123
serializedProps=serialized_props,
124124
toStaticMarkup=to_static_markup
125125
)
126-
except ServiceError as e:
126+
except JSFunctionError as e:
127127
raise six.reraise(ReactRenderingError, ReactRenderingError(*e.args), sys.exc_info()[2])
128128

129-
markup = res.text
130-
131129
return RenderedComponent(
132130
markup, path_to_source, props, serialized_props, watch_source, bundled_component, to_static_markup
133131
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var reactRender = require('react-render');
22
var webpackService = require('webpack-service');
33

44
module.exports = {
5-
services: {
5+
functions: {
66
react: reactRender,
77
webpack: webpackService
88
}

tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"dependencies": {
44
"babel-core": "^5.1.11",
55
"babel-loader": "^5.0.0",
6+
"js-host": "^0.4.0",
67
"react": "^0.13.2",
78
"react-render": "^0.2.4",
8-
"service-host": "git+https://git@github.com/markfinger/service-host#c26dd63074536dfdb3fbf0bfc7904b2cbe223613",
99
"webpack": "^1.8.8",
1010
"webpack-service": "^0.1.1"
1111
}

tests/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
2-
from service_host.conf import settings as service_host_settings
2+
from js_host.conf import settings as js_host_settings
33
from webpack.conf import settings as webpack_settings
44

55
TEST_ROOT = os.path.dirname(__file__)
66
COMPONENT_ROOT = os.path.join(TEST_ROOT, 'components')
77

8-
service_host_settings.configure(
8+
js_host_settings.configure(
99
SOURCE_ROOT=TEST_ROOT,
1010
# Let the manager spin up an instance
1111
USE_MANAGER=True,

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import shutil
33
import unittest
4-
from service_host.host import host
4+
from js_host.host import host
55
from webpack.conf import settings as webpack_settings
66

77

0 commit comments

Comments
 (0)