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.

Reply via email to