I have hierarchical data stored in the datastore using a model which looks like this:
class ToolCategories(db.Model):
name = db.StringProperty()
parent
You have a very reasonable approach! My main caveat would be one having little to do with GAE and a lot with Python: don't build a string from pieces with +
or +=
. Rather, you make a list of string pieces (with append
or extend
or list comprehensions &c) and when you're all done you join it up for the final string result with ''.join(thelist)
or the like. Even though recent Python versions strive hard to optimize the intrinsically O(N squared)
performance of the +
or +=
loops, in the end you're always better off building up lists of strings along the way and ''.join
ing them up at the very end!