2.18.5 appadmin database administration fails when trying to edit record.

36 views
Skip to first unread message

David Manns

unread,
Jun 6, 2019, 11:10:14 AM6/6/19
to web2py-users
Here is my table definition:

db.define_table('AccTrans',
    Field('Timestamp', 'datetime', default=request.now, writable=False),
    Field('Bank', 'reference Bank_Accounts', writable=False),    #e.g. PayPal, Cambridge Trust, ...
    Field('Account', 'reference CoA',
            requires=IS_IN_DB(db, 'CoA.id', '%(Name)s', orderby=db.CoA.Name)),
    Field('Event', 'reference Events',
                requires=IS_EMPTY_OR(IS_IN_DB(db, 'Events.id', '%(Event)s', orderby=~db.Events.Date)),
                comment='leave blank if not applicable'),
    Field('Amount', 'decimal(8,2)',
                comment='enter full amount of check (negative) or deposit (positive); split using Edit if multiple accounts',
                requires=IS_DECIMAL_IN_RANGE(-10000, 10000)),    # >=0 for asset/revenue, <0 for liability/expense
    Field('Fee', 'decimal(6,2)', requires=IS_EMPTY_OR(IS_DECIMAL_IN_RANGE(-1000,100))),    # e.g. PayPal transaction fee, <0 (unless refunded)
    Field('CheckNumber', 'integer', default=None, requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1,99999)),
                comment='enter check number if recording a check written'),
    Field('Accrual', 'boolean', default=True, readable=True, writable=False),
    Field('FullAmt', 'decimal(8,2)', writable=False, readable=False),    # for an accrual, the original unsplit amount
    Field('Reference', 'string', writable=False),
    Field('Notes', 'text'),
    singular='Transaction', plural='Check_Register')

The referenced table CoA looks like:

db.define_table('CoA',
    Field('Name', 'string'),
    Field('Notes', 'string'),
    singular='Bank', plural='Banks', format='%(Name)s')
db.CoA.Name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'CoA.Name')]


Database administration displays the table rows just fine.

Clicking on a record's id field should display the record for editing. Instead I get an error, looks like when its setting up the widget for the first reference field. In my application, grid and smartgrid have no problem with my model.

<type 'exceptions.KeyError'> 'Account.Name'

Version

web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
Python Python 2.7.14: C:\Python27\python.exe (prefix: C:\Python27)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
Traceback (most recent call last):
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers/appadmin.py", line 695, in <module>
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f()
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers/appadmin.py", line 337, in update
f='download', args=request.args[:1]))
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\sqlhtml.py", line 1550, in __init__
inp = self.widgets.options.widget(field, default)
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\sqlhtml.py", line 353, in widget
options = requires[0].options()
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py", line 2742, in _options
options = self.other.options(*args, **kwargs)
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py", line 609, in options
self.build_set()
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py", line 604, in build_set
self.labels = [self.label % r for r in records]
File "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\objects.py", line 103, in __getitem__
raise KeyError(key)
KeyError: 'Account.Name'

Error snapshot help

<type 'exceptions.KeyError'>('Account.Name')

inspect attributes

Frames

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\restricted.py in restricted at line 219 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers\appadmin.py in <module> at line 695 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\globals.py in <lambda> at line 421 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers\appadmin.py in update at line 337 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\sqlhtml.py in __init__ at line 1550 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\sqlhtml.py in widget at line 353 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py in _options at line 2742 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py in options at line 609 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\validators.py in build_set at line 604 code arguments variables

  • File C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\gluon\packages\dal\pydal\objects.py in __getitem__ at line 103 code arguments variables

    Function argument list

    (self=<Row {'Accrued': -2427.37, 'id': 1L}>, k='Account.Name')

    Code listing
    98.
    99.
    100.
    101.
    102.
    103.
    104.
    105.
    106.
    107.
            lg = BasicStorage.get(self, '__get_lazy_reference__', None)
    if callable(lg):
    v = self[key] = lg(key)
    return v

    raise KeyError(key)

    __str__ = __repr__ = lambda self: '<Row %s>' % \
    self.as_dict(custom_types=[LazySet])
    Variables
    key 'Account.Name'
    builtinKeyError <type 'exceptions.KeyError'>

In file: C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers/appadmin.py

1.
<code object <module> at 000000000BC220B0, file "C:\Users\David\Google Drive\My Documents\OxCamNE.3.1\applications\init\controllers/appadmin.py", line 7>

David Manns

unread,
Jun 7, 2019, 5:51:33 PM6/7/19
to web2py-users
This is a duplicate of https://groups.google.com/forum/#!topic/web2py/2oVcXiUCAiE this one originally seemed to disappear so I resubmitted it.
Reply all
Reply to author
Forward
0 new messages