If execution continues in post it means it didn't detect any validation error, so that is the reason why request.validation is actually empty.
Are you sure the price.validator and amount.validator actually work? The expected syntax to specify validators in sprox is to actually use __field_validators__ and if your issue is that nor the error_handler is called nor request.validation contains errors is because validation is not happening at all. On Wed, Oct 15, 2014 at 12:03 AM, Johannes Sauer < [email protected]> wrote: > The model: > > class DepotItem(Base): > __tablename__ = 'depot_item' > > id = Column(Integer, autoincrement=True, primary_key=True) > depot_id = Column(Integer, ForeignKey('depot.id'), nullable=False) > price = Column(Float) > amount = Column(Integer) > stock_id = Column(Integer, ForeignKey('stock.id'), nullable=False) > > The form: > > class NewDepotItemForm(AddRecordForm): > __model__ = DepotItem > __omit_fields__ = ['depot'] > __require_fields__ = ['price', 'amount'] > __dropdown_field_names__ = {'stock':'symbol'} > stock = StockField > price = TextField > price.validator = validators.Number(min=0.01) > amount = TextField > amount.validator = validators.Int(min=1) > > new_depotitem_form = NewDepotItemForm(DBSession) > > The POST method: > @validate(new_depotitem_form, error_handler=new) > @expose() > def post(self, kw): > print("\n\n\n"+str(tg.request.validation['errors'])) > > del kw['sprox_id'] > depot_item = DepotItem() > depot_item.price = kw.get('price') > depot_item.amount = kw.get('amount') > depot_item.depot = self.entry > depot_item.stock = DBSession.query(Stock).filter_by(symbol=kw.get( > 'stock')).one() > DBSession.add(depot_item) > flash('Aktie gekauft') > redirect('/depot/'+str(self.entry.id)) > > When I enter something else than a number the application crashes with a > StatementError, because those Strings could not be converted to Float or > Integer. But according to my @validat decorater the new procedure should be > called again. But poorly there where no validation errors detected (as the > print in the POST method only shows an empty dict). > > Has anybody an idea, why this is not working? > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

