core (memory): moved Params in its own module + introduced a new core/constants module, and moved some constants there
This commit is contained in:
parent
399ac31e05
commit
e689f6bb34
2 changed files with 715 additions and 668 deletions
25
src/core/constants.py
Normal file
25
src/core/constants.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SàT: a XMPP client
|
||||
# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Const(object):
|
||||
NO_SECURITY_LIMIT = -1
|
||||
INDIVIDUAL = "individual"
|
||||
GENERAL = "general"
|
||||
SAVEFILE_DATABASE = "/sat.db"
|
||||
|
|
@ -39,7 +39,8 @@ import os.path
|
|||
from sat.core.default_config import CONST
|
||||
from sat.core import xmpp
|
||||
from sat.core import exceptions
|
||||
from sat.memory.memory import Memory, NO_SECURITY_LIMIT
|
||||
from sat.core.constants import Const as C
|
||||
from sat.memory.memory import Memory
|
||||
from sat.tools.xml_tools import tupleList2dataForm
|
||||
from sat.tools.misc import TriggerManager
|
||||
from glob import glob
|
||||
|
|
@ -897,7 +898,7 @@ class SAT(service.Service):
|
|||
|
||||
#Menus management
|
||||
|
||||
def importMenu(self, path, callback, security_limit=NO_SECURITY_LIMIT, help_string="", type_="NORMAL"):
|
||||
def importMenu(self, path, callback, security_limit=C.NO_SECURITY_LIMIT, help_string="", type_="NORMAL"):
|
||||
"""register a new menu for frontends
|
||||
@param path: path to go to the menu (category/subcategory/.../item), must be an iterable (e.g.: ("File", "Open"))
|
||||
/!\ use D_() instead of _() for translations (e.g. (D_("File"), D_("Open")))
|
||||
|
|
@ -942,7 +943,7 @@ class SAT(service.Service):
|
|||
|
||||
return callback_id
|
||||
|
||||
def getMenus(self, language='', security_limit=NO_SECURITY_LIMIT):
|
||||
def getMenus(self, language='', security_limit=C.NO_SECURITY_LIMIT):
|
||||
"""Return all menus registered
|
||||
@param language: language used for translation, or empty string for default
|
||||
@param security_limit: %(doc_security_limit)s
|
||||
|
|
@ -958,7 +959,7 @@ class SAT(service.Service):
|
|||
type_ = menu_data['type']
|
||||
path = menu_data['path']
|
||||
menu_security_limit = menu_data['security_limit']
|
||||
if security_limit!=NO_SECURITY_LIMIT and (menu_security_limit==NO_SECURITY_LIMIT or menu_security_limit>security_limit):
|
||||
if security_limit!=C.NO_SECURITY_LIMIT and (menu_security_limit==C.NO_SECURITY_LIMIT or menu_security_limit>security_limit):
|
||||
continue
|
||||
languageSwitch(language)
|
||||
path_i18n = [_(elt) for elt in path]
|
||||
|
|
|
|||
Loading…
Reference in a new issue