#!/usr/bin/env python
# -*- coding: utf_8 -*-

from application.signal_manager import signalManager
{%- for api in config %}
from .{{ api['name'] }} import {{ api["name"] }}Manager
{%- endfor %}

def initConnect():
{%- for api in config %}
    {%- if "restful" in api.get("view") and api.get("view").get("restful") == False %}
    {%- for r in api.get("view").get("routes", []) %}
    signalManager.action{{ r.get("name") | capitalize }}.connect({{ api.get("name") }}Manager.{{ r.get("name") }})
    {%- endfor %}
    {%- else %}
    {%- for key, value in api.get("view").items() %}
    signalManager.action{{ key | capitalize }}{{ api.get("name") | capitalize }}.connect({{ api.get("name") }}Manager.{{ key }})
    {%- endfor %}
    {%- endif %}
{%- endfor %}
