def getCategories(cls): session = Session() result = session.query(CommandCategories).all() if not result: category = CommandCategories() session.add(category) session.commit() out = [category.toDict()] else: out = [] for r in result: out.append(r.toDict()) session.close() return out
def createCategory(cls, label): """ Creates a new category with the specified label and returns the dictionary representation of the newly created category, including its id. @@@param label:string The display label for the new category. @@@return dict The dictionary representation of the newly created category. """ session = Session() category = CommandCategories(label=unicode(label)) session.add(category) session.commit() out = category.toDict() session.close() return out