Hi!


I dunno if I'm doing it wrong or if this is a bug with schema validators.  I
have a form broken into parts, where one part is repeating itself and the
other is a "header".  The repeating part is using widgets (so is the header),
but who's posting the data to TG is a JavaScript function (to get the parts
together and do some other AJAX stuff).


I'm getting the following message in tg_errors: 

The input field 'self' was not expected.

This is my validator

================================================================================
class validador_compras(validators.Schema):
    compra_id = validators.Int(if_empty = None)
    data = validators.DateValidator(allow_empty = False)
    fornecedor = validators.Int(not_empty = True)
    genero_id = validators.Int(not_empty = True)
    produto = validators.UnicodeString(not_empty = True)
    quantidade = validators.Number(not_empty = True)
    preco_unitario = validators.Number(not_empty = True)
================================================================================

and this is my controller:

================================================================================
    @turbogears.expose(format = 'json', allow_json = True)
    @turbogears.error_handler(turbogears.util.bind_args(add = True)(compras))
    @turbogears.validate(validators = validador_compras)
    @identity.require(identity.conditions.in_any_group('compras_novo', 'admin'))
    @mensagem_json
    def save(self, **kword):

        agora = datetime.datetime.now()
        usuario = identity.current.user

        try:
            compra_id = kword['compra_id']
        except KeyError:
            compra_id = self.get_next_compra()

        compra = model.Compra(
            compra = compra_id,
            data = kword['data'],
            generoID = kword['genero_id'],
            produto = kword['produto'],
            fornecedorID = kword['fornecedor'],
            quantidade = kword['quantidade'],
            precoUnitario = kword['preco_unitario'],
            incluidoPor = usuario,
            incluidoEm = agora,
            alteradoPor = usuario,
            alteradoEm = agora)

        return dict(compra = compra.id)
================================================================================

Using an instance of validador_compras as the validator gives me the same
error... 

If I print the keys in kword I get (in this case, where there's no "compra_id"
yet):

['quantidade', 'genero_id', 'produto', 'fornecedor', 'preco_unitario', 'data']

as I am expecting it to be...


Any hints on what might be happening?


TurboGears 0.9a4
nose 0.8.4
RuleDispatch 0.5a0
setuptools 0.6a11
FormEncode 0.4
cElementTree 1.0.5-20051216
PasteScript 0.5
elementtree 1.2.6
simplejson 1.1
SQLObject 0.7.1dev-r1682
CherryPy 2.2.0
TurboKid 0.9.4dev-r1090
TurboJson 0.9.2dev-r1093
PyProtocols 1.0a0
Cheetah 1.0
PasteDeploy 0.3
Paste 0.5
FormEncode 0.4
kid 0.9
elementtree 1.2.6


TIA,
-- 
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to