Mercurial > libervia-web
comparison libervia/web/pages/_browser/proxy.py @ 1570:038d4bfdd967
server (tasks/JS modules): add new way to generate modules + support of CSS files
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 22 Nov 2023 16:31:32 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1569:54ba0f74a488 | 1570:038d4bfdd967 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 # Libervia XMPP | |
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 class JSProxy: | |
20 def __init__(self): | |
21 self._module = None | |
22 | |
23 @property | |
24 def js_module(self): | |
25 return self._module | |
26 | |
27 @js_module.setter | |
28 def js_module(self, module): | |
29 if self._module is not None: | |
30 raise Exception("Module is already set!") | |
31 self._module = module | |
32 | |
33 def __getattr__(self, name): | |
34 if self._module is None: | |
35 raise RuntimeError("The module has not been loaded yet") | |
36 return getattr(self._module, name) | |
37 | |
38 def __call__(self, *args): | |
39 if self._module is None: | |
40 raise RuntimeError("The module has not been loaded yet") | |
41 return self._module(*args) |