After finding some code in a class called RecordUpdater in gluon/dal.py i 
think I figured out how to get past my arguments as a set or a 
dict....well....I was getting a keyerr for 'name' so I put it in a 
try-catch but now I'm getting a keyerror for 'id'
In the code below I've only been working on the _after_update.

Wonder why 'name' and 'id' throw the error but 'tablename' does not?

#This is after my table definition inside my model file
db.extracted_linear._after_insert.append(
    lambda f, id:wiki_update_or_insert(
        tablename='extracted_linear',
        id=id,
        name=f['name'] or f['measuremnt']))
db.extracted_linear._after_update.append(
    lambda s, id:wiki_update_or_insert(
        tablename='extracted_linear',
        id=id,
        colset=s(db.extracted_linear.id==id)))

#Here is function in the controller
def wiki_update_or_insert(**fields):
    newfields = fields or dict(colset)
    try:
        title=newfields['name'] or newfields['tablename'] + ' ' + 
newfields['id']['id']
    except:
        title=newfields['tablename'] + ' ' + newfields['id']['id']
    db.wiki_page.update_or_insert(
        title=title,
        slug=table_slug(title),
        body=MARKMIN('#ADD CODE TO DISPLAY GRAPHS HERE'),
        tablename=newfields['tablename'],
        record_id=newfields['id']['id'])




Traceback (most recent call last):
  File "C:\web2py_src_2.2.1\web2py\gluon\restricted.py", line 212, in restricted
    exec ccode in environment
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PROD/controllers/default.py>, line 
173, in <module>
  File "C:\web2py_src_2.2.1\web2py\gluon\globals.py", line 188, in <lambda>
    self._caller = lambda f: f()
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 2911, in f
    return action(*a, **b)
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PROD/controllers/default.py>, line 
67, in linear_manage
    form = SQLFORM.smartgrid(db.extracted_linear)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 2376, in smartgrid
    user_signature=user_signature, **kwargs)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1882, in grid
    next=referrer)
  File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 2170, in process
    self.validate(**kwargs)
  File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 2109, in validate
    if self.accepts(**kwargs):
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1473, in accepts
    self.id_field_name]).update(**fields)
  File "C:\web2py_src_2.2.1\web2py\gluon\dal.py", line 8814, in update
    ret and [f(self,update_fields) for f in table._after_update]
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/models/db_wizard.py" 
<http://127.0.0.1:8000/admin/default/edit/PROD/models/db_wizard.py>, line 118, 
in <lambda>
    colset=s(db.extracted_linear.id==id)))
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/PROD/controllers/default.py>, line 
44, in wiki_update_or_insert
    title=newfields['tablename'] + ' ' + newfields['id']['id']
KeyError: 'id'



-- 



Reply via email to