improved but now get this error:

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File "gluon/restricted.py", line 224, in restricted
  File "C:/alex/web2py/web2py/web2py/applications/ES1/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/ES1/controllers/default.py>, line 
1280, in <module>
  File "gluon/globals.py", line 392, in <lambda>
  File "C:/alex/web2py/web2py/web2py/applications/ES1/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/ES1/controllers/default.py>, line 
909, in view_suggestions
    links = suggestionLinks,  buttons_placement = 'right')
  File "gluon/sqlhtml.py", line 2214, in grid
  File "gluon/html.py", line 2303, in process
  File "gluon/html.py", line 2240, in validate
  File "gluon/sqlhtml.py", line 1669, in accepts
  File "gluon/dal.py", line 10774, in update
  File "C:/alex/web2py/web2py/web2py/applications/ES1/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/ES1/models/db.py>, line 1440, in 
update_SuggestionDisplayName
    db(db.SuperObject.id == 
ThisSuperObject.objectID).update(objectDisplayName=displayName)
  File "gluon/dal.py", line 7529, in __getitem__
AttributeError: 'Row' object has no attribute 'objectID'


CONTROLLER
# Update displayName in db.SuperObject whenever Suggestion.suggestionTitle 
is updated in db.Suggestion  
def update_SuggestionDisplayName(set, ufields):
   table = 'Suggestion' if ('suggestionTitle' in ufields) else None
   if table:
       name_format = '%(suggestionTitle)s'
       records = set.select()
       for record in records:
           displayName = name_format % record
           ThisSuperObject = db(db.SuperObject.id == 
record.objectID).select(db.SuperObject.id).first()
           ThisSuperObject.update_record(objectDisplayName=displayName)
           db(db.SuperObject.id == 
ThisSuperObject.objectID).update(objectDisplayName=displayName)

db.Suggestion._after_update.append(update_SuggestionDisplayName)

Table SuperObject
db.define_table('SuperObject',  #
    Field('objectDisplayName','string', label='Object Name'),
    Field('objectTypeID','reference ObjectType', label = 'Object Type'), 
format='%(objectDisplayName)s') ## 

Table Suggestion
db.define_table('Suggestion', 
Field('objectID', 'reference SuperObject'),  
Field('suggestionTitle','string', length=140, label='suggestion Title', 
comment='140 characters max'),
Field('suggestionShortSummary','string', length=280, label='Summary info', 
comment='short summary - 280 characters max'),
format='%(suggestionTitle)s')

Thanks,

Alex Glaros

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to