File: namespace_prefix.py

package info (click to toggle)
python-trame-client 3.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,128 kB
  • sloc: python: 9,609; javascript: 3,897; sh: 9; makefile: 6
file content (36 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from trame.app import get_server

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../tests"))
from test_translator import BasicApp  # noqa: E402

CLIENT_TYPE = "vue2"


def main():
    root_server = get_server(client_type=CLIENT_TYPE)
    one_of_the_app = None
    for app_name in ["main", "a", "b", "c"]:
        child_server = root_server.create_child_server(prefix=f"{app_name}_")
        app = BasicApp(child_server, app_name, CLIENT_TYPE)
        app.ui
        app.add()
        app.ctrl.plus()
        one_of_the_app = app

    # root_server.controller.on_server_ready.add(
    #   lambda **kwargs: print(json.dumps(root_server.state.to_dict(), indent=2))
    # )
    root_server.controller.on_server_ready.add(
        lambda **kwargs: print("Root server ready")
    )
    one_of_the_app.server.controller.on_server_ready.add(
        lambda **kwargs: print("Sub server ready")
    )
    one_of_the_app.server.start()


if __name__ == "__main__":
    main()