blob: 6f43e3b415dfe0823cc8c0cd035044e832aef930 [file] [log] [blame]
from header import *
{% for m in proto.messages %}
{% if file_exists(xproto_base_name(m.name)|lower+'_header.py') -%}from {{xproto_base_name(m.name)|lower }}_header import *{% endif %}
{% if file_exists(xproto_base_name(m.name)|lower+'_top.py') -%}{{ include_file(xproto_base_name(m.name)|lower+'_top.py') }} {% endif %}
{%- for l in m.links %}
{% if l.peer != m.name %}
from core.models.{{ l.peer | lower }} import {{ l.peer }}
{% endif %}
{%- endfor %}
{% for b in m.bases %}
{% if b!='PlCoreBase' and 'Mixin' not in b%}
from core.models.{{b | lower}} import {{ b }}
{% endif %}
{% endfor %}
class {{ m.name }}{{ xproto_base_def(m.bases) }}:
# Primitive Fields (Not Relations)
{% for f in m.fields %}
{%- if not f.link -%}
{{ f.name }} = {{ xproto_django_type(f.type, f.options) }}( {{ xproto_django_options_str(f) }} )
{% endif %}
{%- endfor %}
# Relations
{% for l in m.links %}
{{ l.src_port }} = {{ xproto_django_link_type(l) }}( {%- if l.peer==m.name -%}'self'{%- else -%}{{ l.peer }} {%- endif -%}, {{ xproto_django_options_str(l, l.dst_port ) }} )
{%- endfor %}
{% if file_exists(m.name|lower + '_model.py') -%}{{ include_file(m.name|lower + '_model.py') | indent(width=2)}}{%- endif %}
pass
{% if file_exists(xproto_base_name(m.name)|lower+'_bottom.py') -%}{{ include_file(xproto_base_name(m.name)|lower+'_bottom.py') }}{% endif %}
+++ {{m.name|lower}}.py
{% endfor %}