def term_translation_update(context, data_dict):
 model = context['model']
 _check_access('term_translation_update', context, data_dict)
 schema = {'term': [validators.not_empty, unicode], 'term_translation': [validators.not_empty, unicode], 'lang_code': [validators.not_empty, unicode]}
 (data, errors) = _validate(data_dict, schema, context)
 if errors:
  model.Session.rollback()
  raise ValidationError(errors)
 trans_table = model.term_translation_table
 update = trans_table.update()
 update = update.where((trans_table.c.term == data['term']))
 update = update.where((trans_table.c.lang_code == data['lang_code']))
 update = update.values(term_translation=data['term_translation'])
 conn = model.Session.connection()
 result = conn.execute(update)
 if (not result.rowcount):
  conn.execute(trans_table.insert().values(**data))
 if (not context.get('defer_commit')):
  model.Session.commit()
 return data

def term_translation_update ( context , data_dict ) : model = context [ 'model' ] _check_access ( 'term_translation_update' , context , data_dict ) schema = { 'term' : [ validators . not_empty , unicode ] , 'term_translation' : [ validators . not_empty , unicode ] , 'lang_code' : [ validators . not_empty , unicode ] } ( data , errors ) = _validate ( data_dict , schema , context ) if errors : model . Session . rollback ( ) raise ValidationError ( errors ) trans_table = model . term_translation_table update = trans_table . update ( ) update = update . where ( ( trans_table . c . term == data [ 'term' ] ) ) update = update . where ( ( trans_table . c . lang_code == data [ 'lang_code' ] ) ) update = update . values ( term_translation = data [ 'term_translation' ] ) conn = model . Session . connection ( ) result = conn . execute ( update ) if ( not result . rowcount ) : conn . execute ( trans_table . insert ( ) . values ( ** data ) ) if ( not context . get ( 'defer_commit' ) ) : model . Session . commit ( ) return data
create or update a term translation .