__category A private method to create/refer category for/of this module. :param name: Name of the category :param label: Display name of the category, it will be send to client/front end to list down in the preferences/options
(self, name, label)
| 368 | return res |
| 369 | |
| 370 | def __category(self, name, label): |
| 371 | """ |
| 372 | __category |
| 373 | |
| 374 | A private method to create/refer category for/of this module. |
| 375 | |
| 376 | :param name: Name of the category |
| 377 | :param label: Display name of the category, it will be send to |
| 378 | client/front end to list down in the preferences/options |
| 379 | dialog. |
| 380 | :returns: A dictionary object reprenting this category. |
| 381 | """ |
| 382 | if name in self.categories: |
| 383 | res = self.categories[name] |
| 384 | # Update the category label (if not yet defined) |
| 385 | res['label'] = res['label'] or label |
| 386 | |
| 387 | return res |
| 388 | |
| 389 | cat = PrefCategoryTbl.query.filter_by( |
| 390 | mid=self.mid |
| 391 | ).filter_by(name=name).first() |
| 392 | |
| 393 | if cat is None: |
| 394 | cat = PrefCategoryTbl(name=name, mid=self.mid) |
| 395 | db.session.add(cat) |
| 396 | db.session.commit() |
| 397 | cat = PrefCategoryTbl.query.filter_by( |
| 398 | mid=self.mid |
| 399 | ).filter_by(name=name).first() |
| 400 | |
| 401 | self.categories[name] = res = { |
| 402 | 'id': cat.id, |
| 403 | 'name': name, |
| 404 | 'label': label, |
| 405 | 'preferences': dict() |
| 406 | } |
| 407 | |
| 408 | return res |
| 409 | |
| 410 | def register( |
| 411 | self, category, name, label, _type, default, **kwargs |