def process(self, context, boundTo, data, autoConfigure = True): """Knows how to process a dictionary of lists where the dictionary may contain a key with the same name as the property binding's name. """ binding = self.original context.remember(binding, iformless.IBinding) result = {} try: result[binding.name] = iformless.IInputProcessor(binding.typedValue).process(context, boundTo, data.get(binding.name, [''])) except formless.InputError as e: result[binding.name] = data.get(binding.name, ['']) raise formless.ValidateError({binding.name: e.reason}, e.reason, result) if autoConfigure: try: return self.original.configure(boundTo, result) except formless.InputError as e: result[binding.name] = data.get(binding.name, ['']) raise formless.ValidateError({binding.name: e.reason}, e.reason, result) return result
class ProcessMethodBinding(components.Adapter): implements(iformless.IInputProcessor) def process(self, context, boundTo, data, autoConfigure=True): """Knows how to process a dictionary of lists where the dictionary may contain a key with the same name as some of the arguments to the MethodBinding instance. """ typedValue = self.original.typedValue results = {} failures = {} if data.has_key('----'): ## ---- is the "direct object", the one argument you can specify using the command line without saying what the argument name is data[typedValue.arguments[0].name] = data['----'] del data['----'] for binding in typedValue.arguments: name = binding.name try: context = WovenContext(context, faketag) context.remember(binding, iformless.IBinding) results[name] = iformless.IInputProcessor( binding.typedValue).process(context, boundTo, data.get(name, [''])) except formless.InputError, e: results[name] = data.get(name, [''])[0] failures[name] = e.reason if failures: #print "There were validation errors. The errors were: ", failures raise formless.ValidateError(failures, "Error:", results) if autoConfigure: def _except(e): failures[''] = e.reason # self.original.name raise formless.ValidateError(failures, e.reason, results) return exceptblock(self.original.configure, _except, formless.InputError, boundTo, results) return results
def _except(e): failures[''] = e.reason # self.original.name raise formless.ValidateError(failures, e.reason, results)