# HG changeset patch # User BenoƮt Allard # Date 1412857575 -7200 # Node ID d6fa288e92a72fc30e150fd3b8e8d6e7428c74ff # Parent 65c874b2c78e085bd003f6a096bf67d704c55e88 Update to latest farolluz (unlink/link) diff -r 65c874b2c78e -r d6fa288e92a7 farol/producttree.py --- a/farol/producttree.py Thu Oct 09 12:28:36 2014 +0200 +++ b/farol/producttree.py Thu Oct 09 14:26:15 2014 +0200 @@ -81,9 +81,7 @@ # 1. unlink branch.unlink() # 2. set the new parent - branch._parentbranch = pbranch - # 3. add to the Tree (again) - ptree.addBranch(branch) + branch.link(pbranch) branch._type = request.form['type'] branch._name = request.form['name'] @@ -104,7 +102,6 @@ try: pbranch = ptree.getBranch([int(p) for p in request.form['parent'].split('/')]) except (ValueError, IndexError): abort(404) branch = CVRFProductBranch(request.form['type'], request.form['name'], pbranch) - ptree.addBranch(branch) return redirect(url_for('.view')) @producttree.route('/branch//del', methods=['POST']) @@ -167,19 +164,21 @@ if pbranch is not oldp: # Gonna be funny, needs re-link product.unlink() - product._parent = pbranch - ptree.addProduct(product) + # And Link again + product.link(pbranch) elif request.form['parent_relationship']: prel = ptree._relationships[int(request.form['parent_relationship'])] if prel is not oldp: + # Unlink product.unlink() - product._parent = prel - ptree.addProduct(product) + # Link again + product.link(prel) else: if ptree is not oldp: + # Unlink product.unlink() - product._parent = ptree - ptree.addProduct(product) + # Link again + product.link(ptree) product._productid = request.form['productid'] product._name = request.form['name']