@set_database
def update_parents(parent_mapping=None, **kwargs):
 if parent_mapping:
  db = kwargs.get('db')
  if db:
   with db.atomic() as transaction:
    for (key, value) in parent_mapping.iteritems():
     if value:
      try:
       parent = Item.get((Item.id == value), (Item.kind == 'Topic'))
       item = Item.get((Item.path == key))
      except DoesNotExist:
       print (key, value, 'Parent or Item not found')
      if (item and parent):
       item.parent = parent
       item.save()

@ set_database def update_parents ( parent_mapping = None , ** kwargs ) : if parent_mapping : db = kwargs . get ( 'db' ) if db : with db . atomic ( ) as transaction : for ( key , value ) in parent_mapping . iteritems ( ) : if value : try : parent = Item . get ( ( Item . id == value ) , ( Item . kind == 'Topic' ) ) item = Item . get ( ( Item . path == key ) ) except DoesNotExist : print ( key , value , 'Parent or Item not found' ) if ( item and parent ) : item . parent = parent item . save ( )
convenience function to add parent nodes to other nodes in the database .