<metal:block define-macro="options">
  <tal:block define="
    preselected preselected | nothing;
    i_am_manager i_am_manager | silva_permissions/ChangeSilvaViewRegistry | nothing;    
    managers_only_options managers_only_options | python: ('Manager', 'ChiefEditor');
    optgroups python: {
      'public silva roles' : ('Viewer', 'Viewer +', 'Viewer ++'),
      'silva roles' : ('Reader', 'Author', 'Editor', 'ChiefEditor'),
      'zope roles' : ('Manager', )};
      "
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      i18n:domain="silva"
    >
    <optgroup i18n:attributes="label" 
      tal:repeat="
        optgroup python: ('public silva roles', 'silva roles', 'zope roles')"
      tal:attributes="
        label optgroup"
      >
      <tal:block
        tal:repeat="
          option optgroups/?optgroup"        
        >
        <option i18n:translate="" 
          tal:condition="
            python: i_am_manager or option not in managers_only_options"
          tal:content="
            option"
          tal:attributes="
            value option;
            selected python: option == preselected and 'selected' or nothing;
            "
        />
      </tal:block>
    </optgroup>
  </tal:block>  
</metal:block>

<metal:block define-macro="access_restriction_options">
  <tal:block define="
    preselected preselected | nothing;
    optgroups python: {
    'zope roles' : ('Anonymous', 'Authenticated'),
    'public silva roles' : ('Viewer', 'Viewer +', 'Viewer ++')};
    "
    >
    <optgroup i18n:attributes="label" 
      tal:repeat="
        optgroup python: ('zope roles', 'public silva roles')"
      tal:attributes="
        label optgroup"
      >
      <tal:block
        tal:repeat="
          option optgroups/?optgroup"        
        >
        <option i18n:translate="" 
          tal:content="
            option"
          tal:attributes="
            value option;
            selected python: option == preselected and 'selected' or nothing;
            "
        />
      </tal:block>
    </optgroup>
  </tal:block>  
</metal:block>
