forked from markfinger/python-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
23 lines (19 loc) · 803 Bytes
/
Copy path__init__.py
File metadata and controls
23 lines (19 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
import os
from django.utils import six
from django_node.base_service import BaseService
from django_node.exceptions import NodeServiceError
from ..exceptions import ComponentRenderingError
class RenderService(BaseService):
path_to_source = os.path.join(os.path.dirname(__file__), 'render.js')
package_dependencies = os.path.dirname(__file__)
def render(self, path_to_source, serialized_props, to_static_markup):
try:
response = self.send(
path=path_to_source,
serializedProps=serialized_props,
toStaticMarkup=to_static_markup
)
except NodeServiceError as e:
six.reraise(ComponentRenderingError, ComponentRenderingError(*e.args), sys.exc_info()[2])
return response.text