def fill_categories(self):
        records = self._parse_xml()
        categories = set()

        for record in records:
            category_names = record.getElementsByTagName('category')[0].firstChild.data
            for name in category_names.split(', '):
                if name not in categories:
                    categories.add(name)
                    category = Category(name=name)
                    category.save_to_db()
Beispiel #2
0
 def post(self):
     '''Create a new Category instance in the database'''
     data = CategoryListResource.parser.parse_args()
     category = Category(data['name'])
     category.save_to_db()
     return {'message': 'Success'}, 200