def prepare(self): if self.form_template: self.form = parse_from_YAML( self.form_template, self, self.message_factory) return # BBB self.form = parse_from_YAML( self.form_template_path, self, self.message_factory)
def prepare(self): if self.form_template: self.form = parse_from_YAML(self.form_template, self, self.message_factory) return # BBB self.form = parse_from_YAML(self.form_template_path, self, self.message_factory)
def form(self): # make configuration data available on form context self.props = ILDAPProps(self.plugin) self.users = ILDAPUsersConfig(self.plugin) self.groups = ILDAPGroupsConfig(self.plugin) # prepare users data on form context self.users_attrmap = odict() for key in self.static_attrs_users: self.users_attrmap[key] = self.users.attrmap.get(key) self.users_propsheet_attrmap = odict() for key, value in self.users.attrmap.items(): if key in self.static_attrs_users: continue self.users_propsheet_attrmap[key] = value # prepare groups data on form context self.groups_attrmap = odict() for key in self.static_attrs_groups: self.groups_attrmap[key] = self.groups.attrmap.get(key) self.groups_propsheet_attrmap = odict() for key, value in self.groups.attrmap.items(): if key in self.static_attrs_groups: continue self.groups_propsheet_attrmap[key] = value # handle form form = parse_from_YAML('pas.plugins.ldap:properties.yaml', self, _) controller = Controller(form, self.request) if not controller.next: return controller.rendered self.request.RESPONSE.redirect(controller.next) return u''
def form(self): form = parse_from_YAML('collective.folderorder:form.yaml', self, _) controller = Controller(form, self.request) if not controller.next: return controller.rendered self.context.REQUEST.response.redirect(controller.next) return u''
def form(self): path = os.path.join(os.path.dirname(__file__), 'controlpanel.yaml') form = parse_from_YAML(path, self, _) controller = Controller(form, self.request) if not controller.next: return controller.rendered raise Redirect(controller.next)
def test_parse_from_yaml(self): template_path = os.path.join(self.tempdir, 'tmpl.yaml') with open(template_path, 'w') as file: file.write(self.yaml_tmpl) context = DummyContext() _ = lambda x, default=None: default and default or x form = parse_from_YAML(template_path, context, _) self.assertEqual(form.treerepr().split('\n'), [ "<class 'yafowil.base.Widget'>: demoform", " <class 'yafowil.base.Widget'>: firstfield", " <class 'yafowil.base.Widget'>: secondfield", "" ]) self.assertEqual(sorted(form.attrs.items()), [('action', 'demoaction')]) self.check_output( """ <form action="demoaction" enctype="multipart/form-data" id="form-demoform" method="post" novalidate="novalidate"> <div class="field" id="field-demoform-firstfield"> <label for="input-demoform-firstfield">First Field</label> <input class="required text" id="input-demoform-firstfield" name="demoform.firstfield" required="required" type="text" value="First value"/> </div> <div class="field" id="field-demoform-secondfield"> <label for="input-demoform-secondfield" title="Second Field">secondfield</label> <input id="exists-demoform-secondfield" name="demoform.secondfield-exists" type="hidden" value="exists"/> <select class="select" id="input-demoform-secondfield" multiple="multiple" name="demoform.secondfield"> <option id="input-demoform-secondfield-a" selected="selected" value="a">a</option> <option id="input-demoform-secondfield-b" selected="selected" value="b">b</option> <option id="input-demoform-secondfield-c" value="c">c</option> </select> </div> </form> """, fxml(form()))
def test_parse_from_yaml(self): template_path = os.path.join(self.tempdir, 'tmpl.yaml') with open(template_path, 'w') as file: file.write(self.yaml_tmpl) context = DummyContext() _ = lambda x, default=None: default and default or x form = parse_from_YAML(template_path, context, _) self.assertEqual(form.treerepr().split('\n'), [ "<class 'yafowil.base.Widget'>: demoform", " <class 'yafowil.base.Widget'>: firstfield", " <class 'yafowil.base.Widget'>: secondfield", "" ]) self.assertEqual(sorted(form.attrs.items()), [('action', 'demoaction')]) self.check_output(""" <form action="demoaction" enctype="multipart/form-data" id="form-demoform" method="post" novalidate="novalidate"> <div class="field" id="field-demoform-firstfield"> <label for="input-demoform-firstfield">First Field</label> <input class="required text" id="input-demoform-firstfield" name="demoform.firstfield" required="required" type="text" value="First value"/> </div> <div class="field" id="field-demoform-secondfield"> <label for="input-demoform-secondfield" title="Second Field">secondfield</label> <input id="exists-demoform-secondfield" name="demoform.secondfield-exists" type="hidden" value="exists"/> <select class="select" id="input-demoform-secondfield" multiple="multiple" name="demoform.secondfield"> <option id="input-demoform-secondfield-a" selected="selected" value="a">a</option> <option id="input-demoform-secondfield-b" selected="selected" value="b">b</option> <option id="input-demoform-secondfield-c" value="c">c</option> </select> </div> </form> """, fxml(form()))
def form(self): # make configuration data available on form context try: self.props = ILDAPProps(self.plugin) self.users = ILDAPUsersConfig(self.plugin) self.groups = ILDAPGroupsConfig(self.plugin) except Exception: msg = "Problems getting the configuration adapters, re-initialize!" logger.exception(msg) self.plugin.init_settings() self.anonymous = not self.props.user # prepare users data on form context self.users_attrmap = odict() for key in self.static_attrs_users: self.users_attrmap[key] = self.users.attrmap.get(key) self.users_propsheet_attrmap = odict() for key, value in self.users.attrmap.items(): if key in self.static_attrs_users: continue self.users_propsheet_attrmap[key] = value # prepare groups data on form context self.groups_attrmap = odict() for key in self.static_attrs_groups: self.groups_attrmap[key] = self.groups.attrmap.get(key) self.groups_propsheet_attrmap = odict() for key, value in self.groups.attrmap.items(): if key in self.static_attrs_groups: continue self.groups_propsheet_attrmap[key] = value # handle form form = parse_from_YAML("pas.plugins.ldap:properties.yaml", self, _) controller = Controller(form, self.request) if not controller.next: return controller.rendered self.request.RESPONSE.redirect(controller.next) return u""
def extend(self, form): if self.skip: return fields = parse_from_YAML(self.fields_template, self, self.message_factory) form[self.fields_name] = fields
def prepare(self): self.form = parse_from_YAML( self.form_template, self, self.message_factory)
def _fetch_form(self): return parse_from_YAML('g24.elements.filter:filter.yaml', self, _)