def update(self): if not ISubForm.providedBy(self.form_instance): interface.alsoProvides(self.form_instance, IWrappedForm) # If a form action redirected, don't render the wrapped form if self.request.response.getStatus() in (302, 303): self.contents = "" return z2.switch_on(self, request_layer=self.request_layer) self.form_instance.update()
def executeActions(self, form): request = self.request content = self.getContent() if hasattr(form, 'actions'): for action in form.actions.executedActions: adapter = queryMultiAdapter( (self, request, content, action), IActionHandler) if adapter: adapter() if ISubForm.providedBy(form): self.executeActions(form.parentForm) elif IPageletSubform.providedBy(form) and form.managers: self.executeActions(form.managers[0])
def update(self): if not ISubForm.providedBy(self.form_instance): interface.alsoProvides(self.form_instance, IWrappedForm) # If a form action redirected, don't render the wrapped form if self.request.response.getStatus() in (302, 303): self.contents = "" return z2.switch_on(self, request_layer=self.request_layer) self.form_instance.update() # A z3c.form.form.AddForm does a redirect in its render method. # So we have to render the form to see if we have a redirection. # In the case of redirection, we don't render the layout at all. self.contents = self.form_instance.render()
def _getForm(self): # TODO: check if we create the form multiple times during one request # and if yes, find out what needs to be updated on repeated calls # e.g. context, value, mode, etc.... # The widget provides a context for the form context = None if self.value: # TODO: use field here uri = URIRef(self.value) handler = getUtility(IORDF).getHandler() context = handler.get(URIRef(uri)) else: identifier = getUtility(IORDF).generateURI() context = Graph(identifier=identifier) self.value = unicode(identifier) form = getattr(self, 'form', None) # get parent main form (we might be within a group and only main form has buttons) while form is not None: if IGroup.providedBy(form): form = form.__parent__ elif IRDFObjectPropertyWidget.providedBy(form): form = form.form elif ISubForm.providedBy(form): form = form.__parent__ else: break subformfactory = getMultiAdapter( (context, self.request, form, self, self.field), ISubformFactory) subform = subformfactory() # TODO: pass on all widget properties to the form subform.ignoreContext = self.ignoreContext subform.mode = self.mode return subform
def get_context(self): if ISubForm.providedBy(self.context.form): context = self.context.form.parentForm.context else: context = self.context.context return context
def get_context(self): if ISubForm.providedBy(self.context.form): context = self.context.form.parentForm.context else: context = self.context.context return context