def generateArguments(self, context, args): default_content_pattern = None content_pattern = None for argument in args: try: content_pattern = context.tag.patternGenerator('argument!!%s' % argument.name) except NodeNotFound: if default_content_pattern is None: try: default_content_pattern = context.tag.patternGenerator( 'argument') except NodeNotFound: default_content_pattern = freeformDefaultContentPattern content_pattern = default_content_pattern renderer = iformless.ITypedRenderer(argument.typedValue, defaultBindingRenderer, persist=False) pat = content_pattern( key=argument.name, data=argument, render=renderer, remember={iformless.ITyped: argument.typedValue}) context.fillSlots('argument!!%s' % argument.name, pat) yield pat
def rend(self, context, data): context.remember(data, iformless.IBinding) context.remember(data.typedValue, iformless.ITyped) typedRenderer = iformless.ITypedRenderer(data.typedValue, defaultBindingRenderer) if typedRenderer.complexType: return invisible(data=data, render=typedRenderer) if self.needsSkin or not context.tag.children: self.calculateDefaultSkin(context) if self.isGrouped or data.typedValue.getAttribute('immutable'): subm = '' else: subm = input(type="submit", name="change", value="Change") self.fillForm(context, data) context.fillSlots('form-label', '') context.fillSlots('form-description', '') try: content_pattern = context.tag.patternGenerator('binding') except NodeNotFound: content_pattern = freeformDefaultContentPattern context.fillSlots( 'form-arguments', content_pattern(data=data, render=typedRenderer, key=data.name)) context.fillSlots('form-button', subm) return context.tag
def test_1_renderTyped(self): binding = formless.Property('hello', formless.String( label="Hello", description="Hello, world.")) ## Look up a renderer specific to the type of our binding, typedValue; renderer = iformless.ITypedRenderer( binding.typedValue, None) ## But render the binding itself with this renderer ## The binding has the ".name" attribute we need def later(val): self.assertSubstring('hello', val) self.assertSubstring('Hello', val) self.assertSubstring('Hello, world.', val) self.failIfSubstring('</form>', val) self.failIfSubstring('<input type="submit"', val) return self.render(tags.invisible(data=binding, render=renderer)).addCallback(later)