Mercurial > libervia-backend
comparison src/core/sat_main.py @ 809:743b757777d3
core: security limit in menus
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:32:39 +0100 |
parents | be4c5e24dab9 |
children | 1fe00f0c9a91 |
comparison
equal
deleted
inserted
replaced
808:d035c662b357 | 809:743b757777d3 |
---|---|
891 """register a new menu for frontends | 891 """register a new menu for frontends |
892 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open")) | 892 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open")) |
893 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open"))) | 893 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open"))) |
894 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback] | 894 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback] |
895 @param security_limit: %(doc_security_limit)s | 895 @param security_limit: %(doc_security_limit)s |
896 /!\ security_limit MUST be added to data in launchCallback if used | 896 /!\ security_limit MUST be added to data in launchCallback if used #TODO |
897 @param help_string: string used to indicate what the menu do (can be show as a tooltip). | 897 @param help_string: string used to indicate what the menu do (can be show as a tooltip). |
898 /!\ use D_() instead of _() for translations | 898 /!\ use D_() instead of _() for translations |
899 @param type: one of: | 899 @param type: one of: |
900 - GLOBAL: classical menu, can be shown in a menubar on top (e.g. something like File/Open) | 900 - GLOBAL: classical menu, can be shown in a menubar on top (e.g. something like File/Open) |
901 - ROOM: like a global menu, but only shown in multi-user chat | 901 - ROOM: like a global menu, but only shown in multi-user chat |
930 | 930 |
931 self._menus[callback_id] = menu_data | 931 self._menus[callback_id] = menu_data |
932 | 932 |
933 return callback_id | 933 return callback_id |
934 | 934 |
935 def getMenus(self, language='', security_limit = NO_SECURITY_LIMIT): | 935 def getMenus(self, language='', security_limit=NO_SECURITY_LIMIT): |
936 """Return all menus registered | 936 """Return all menus registered |
937 @param language: language used for translation, or empty string for default | 937 @param language: language used for translation, or empty string for default |
938 @param security_limit: %(doc_security_limit)s | 938 @param security_limit: %(doc_security_limit)s |
939 @return: array of tuple with: | 939 @return: array of tuple with: |
940 - menu id (same as callback_id) | 940 - menu id (same as callback_id) |
945 """ | 945 """ |
946 ret = [] | 946 ret = [] |
947 for menu_id, menu_data in self._menus.iteritems(): | 947 for menu_id, menu_data in self._menus.iteritems(): |
948 type_ = menu_data['type'] | 948 type_ = menu_data['type'] |
949 path = menu_data['path'] | 949 path = menu_data['path'] |
950 menu_security_limit = menu_data['security_limit'] | |
951 if security_limit!=NO_SECURITY_LIMIT and (menu_security_limit==NO_SECURITY_LIMIT or menu_security_limit>security_limit): | |
952 continue | |
950 languageSwitch(language) | 953 languageSwitch(language) |
951 path_i18n = [_(elt) for elt in path] | 954 path_i18n = [_(elt) for elt in path] |
952 languageSwitch() | 955 languageSwitch() |
953 ret.append((menu_id, type_, path, path_i18n)) | 956 ret.append((menu_id, type_, path, path_i18n)) |
954 | 957 |