anyone see what the error is with this after_update function?

# 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(displayName=displayName)
           db(db.SuperObject.id == 
ThisSuperObject.objectID).update(objectDisplayName=displayName)


db.Suggestion._after_update.append(update_SuggestionDisplayName)


Error
 File "C:/Program Files (x86)/web2py/web2py/applications/ES1/models/db.py", 
line 1441, in update_SuggestionDisplayName
    ThisSuperObject.update_record(displayName=displayName)
  File "gluon/dal.py", line 10866, in __call__
  File "gluon/dal.py", line 10772, in update
SyntaxError: No fields to update

Function argument list
(self=<Set (SuperObject.id = 18)>, **update_fields={})

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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to