# Note: Environment is setup in running wrapper script, as zope.conf is read
# too late for some components.
%define INSTANCE {{ instance }}
instancehome $INSTANCE
zserver-threads {{ parameter_dict['thread-amount'] }}

lock-filename {{ parameter_dict['lock-file'] }}
pid-filename {{ parameter_dict['pid-file'] }}

default-zpublisher-encoding utf-8
rest-input-encoding utf-8
rest-output-encoding utf-8

# XXX: isn't this entry implicit ?
products {{ instance_products }}

<http-server>
  address {{ parameter_dict['ip'] }}:{{ parameter_dict['port'] }}
</http-server>

{# TODO: enable
{% if webdav_port -%}
<webdav-source-server>
  address {{ parameter_dict['ip'] }}:{{ parameter_dict['webdav_port'] }}
  force-connection-close off
</webdav-source-server>

{% endif -%}
-#}
<zoperunner>
    program $INSTANCE/bin/runzope
</zoperunner>

<product-config DeadlockDebugger>
  dump_url /manage_debug_threads
  secret {{ deadlock_debugger_password }}
</product-config>

{% if tidstorage_ip -%}
<product-config TIDStorage>
  backend-ip {{ tidstorage_ip }}
  backend-port {{ tidstorage_port }}
</product-config>

{% endif -%}
{% if 'timerserver-interval' in parameter_dict -%}
%import timerserver
<timer-server>
  interval {{ parameter_dict['timerserver-interval'] }}
</timer-server>

{% endif -%}
{% if promise_path -%}
<product-config /{{ parameter_dict['site-id'] }}>
  promise_path {{ promise_path }}
</product-config>

{% endif -%}
<eventlog>
  level info
  <logfile>
    dateformat
    path {{ parameter_dict['event-log'] }}
  </logfile>
</eventlog>

<logger access>
  level WARN
  <logfile>
    dateformat
    path {{ parameter_dict['z2-log'] }}
  </logfile>
</logger>

<zodb_db temporary>
  <temporarystorage>
    name temporary storage for sessioning
  </temporarystorage>
  mount-point /temp_folder
  container-class Products.TemporaryFolder.TemporaryContainer
</zodb_db>

{% for db_name, mount_point, cache_size, storage_type, storage_dict in parameter_dict['zodb-list'] -%}
<zodb_db {{ db_name }}>
{%-   if cache_size %}
  cache-size {{ cache_size }}
{%-   endif %}
  mount-point {{ mount_point }}
  <{{ storage_type }}>
{%-   for key, value in storage_dict.iteritems() %}
    {{ key }} {{ value }}
{%-   endfor %}
  </{{ storage_type }}>
</zodb_db>

{% endfor -%}