I needs to see more of the app to understand the workflow. This will
get rid of the problem:
Field('name_lower', compute=lambda
r:r.get('name','unknwon').lower(),readable=False,writable=False)
But somehow compute is being called without a prefilled record in your
app.
On Feb 3, 7:45 pm, Carl
ah... you are right; I don't get this information from a web2py form.
I added in readable and writable but still get the exception:
KeyError: 'name'
On Feb 4, 1:16 am, mdipierro wrote:
> required is not really required for anything.
>
> For debugging try:
>
> Field('name_lower', compute=lambda
>
required is not really required for anything.
For debugging try:
Field('name_lower', compute=lambda
r:r['name'].lower(),readable=False,writable=False)
Perhaps you do not display the field name in the form?
On Feb 3, 5:57 pm, Carl wrote:
> I've traced right now to the exception and I get KeyE
I've traced right now to the exception and I get KeyError: 'name'
This is referring to the definition in db.py of the compute function
compute=lambda r:r['name'].lower()),
I've removed both notnull=True & required=True from:
Field('name', 'string', length=128, notnull=True, required=True),
but I
Now the see this I understand the problem better. In this line:
Field('mDate', 'datetime', required=True)
required=True is not the same as requires=IS_NOT_EMPTY() and it is not
the same as notnull=True.
required=True means you cannot do insert without providing a value for
this field and that is
db.define_table('team',
Field('name', 'string', length=128, notnull=True,
required=True),
Field('name_lower', compute=lambda r:r['name'].lower()),
Field('owner_user_id', db.auth_user, required=True,
requires=IS_IN_DB(db,db.auth_user.id,'%(id)s')),
Can you show us the model and attributes of db.team.
I suspect db.team.mDate is missing a writable=False, readable=False
which you need since it is a computed field.
On Feb 3, 10:59 am, Carl wrote:
> MainThread - pid4460_seq4
> update [gql.py:696]
> update_record [sql.py:3232]
>
MainThread - pid4460_seq4
update [gql.py:696]
update_record [sql.py:3232]
[sql.py:3109]
update [subscription.py:65]
update_team [default.py:call:68]
serve_jsonrpc [tools.py:2560]
__call__ [tools.py:2646]
call [default.py:call:594]
what is the traceback?
On Feb 3, 6:59 am, Carl wrote:
> Given:
> - a define_table() with a field as "compute=lambda r:r['name'].lower
> ()"
> - that I call update_record() on a row returned from a select.
>
> when I test on dev_appserver I need to include name as a parameter to
> update_record()
9 matches
Mail list logo