comparison src/core/sat_main.py @ 914:1a3ba959f0ab

core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:08:11 +0100
parents fab49a1d5ea2
children 1a759096ccbd
comparison
equal deleted inserted replaced
913:d08cbdd566e2 914:1a3ba959f0ab
37 import os.path 37 import os.path
38 38
39 from sat.core.default_config import CONST 39 from sat.core.default_config import CONST
40 from sat.core import xmpp 40 from sat.core import xmpp
41 from sat.core import exceptions 41 from sat.core import exceptions
42 from sat.memory.memory import Memory, NO_SECURITY_LIMIT 42 from sat.core.constants import Const as C
43 from sat.memory.memory import Memory
43 from sat.tools.xml_tools import tupleList2dataForm 44 from sat.tools.xml_tools import tupleList2dataForm
44 from sat.tools.misc import TriggerManager 45 from sat.tools.misc import TriggerManager
45 from glob import glob 46 from glob import glob
46 from uuid import uuid4 47 from uuid import uuid4
47 48
895 896
896 return defer.maybeDeferred(callback, *args, **kwargs) 897 return defer.maybeDeferred(callback, *args, **kwargs)
897 898
898 #Menus management 899 #Menus management
899 900
900 def importMenu(self, path, callback, security_limit=NO_SECURITY_LIMIT, help_string="", type_="NORMAL"): 901 def importMenu(self, path, callback, security_limit=C.NO_SECURITY_LIMIT, help_string="", type_="NORMAL"):
901 """register a new menu for frontends 902 """register a new menu for frontends
902 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open")) 903 @param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open"))
903 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open"))) 904 /!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open")))
904 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback] 905 @param callback: method to be called when menuitem is selected, callable or a callback id (string) as returned by [registerCallback]
905 @param security_limit: %(doc_security_limit)s 906 @param security_limit: %(doc_security_limit)s
940 941
941 self._menus[callback_id] = menu_data 942 self._menus[callback_id] = menu_data
942 943
943 return callback_id 944 return callback_id
944 945
945 def getMenus(self, language='', security_limit=NO_SECURITY_LIMIT): 946 def getMenus(self, language='', security_limit=C.NO_SECURITY_LIMIT):
946 """Return all menus registered 947 """Return all menus registered
947 @param language: language used for translation, or empty string for default 948 @param language: language used for translation, or empty string for default
948 @param security_limit: %(doc_security_limit)s 949 @param security_limit: %(doc_security_limit)s
949 @return: array of tuple with: 950 @return: array of tuple with:
950 - menu id (same as callback_id) 951 - menu id (same as callback_id)
956 ret = [] 957 ret = []
957 for menu_id, menu_data in self._menus.iteritems(): 958 for menu_id, menu_data in self._menus.iteritems():
958 type_ = menu_data['type'] 959 type_ = menu_data['type']
959 path = menu_data['path'] 960 path = menu_data['path']
960 menu_security_limit = menu_data['security_limit'] 961 menu_security_limit = menu_data['security_limit']
961 if security_limit!=NO_SECURITY_LIMIT and (menu_security_limit==NO_SECURITY_LIMIT or menu_security_limit>security_limit): 962 if security_limit!=C.NO_SECURITY_LIMIT and (menu_security_limit==C.NO_SECURITY_LIMIT or menu_security_limit>security_limit):
962 continue 963 continue
963 languageSwitch(language) 964 languageSwitch(language)
964 path_i18n = [_(elt) for elt in path] 965 path_i18n = [_(elt) for elt in path]
965 languageSwitch() 966 languageSwitch()
966 ret.append((menu_id, type_, path, path_i18n)) 967 ret.append((menu_id, type_, path, path_i18n))