1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2013 Team tiramisu (see AUTHORS for all contributors)
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Lesser General Public License as published by the
6 # Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # ____________________________________________________________
18 from ...error import ConfigError
19 from ..util import SerializeObject
22 class Setting(SerializeObject):
23 """Dictionary storage has no particular setting.
32 def list_sessions(): # pragma: optional cover
36 def delete_session(session_id): # pragma: optional cover
37 raise ConfigError(_('dictionary storage cannot delete session'))
40 class Storage(object):
41 __slots__ = ('session_id', 'persistent')
42 storage = 'dictionary'
43 #if object could be serializable
46 def __init__(self, session_id, persistent, test=False):
47 if not test and session_id in _list_sessions: # pragma: optional cover
48 raise ValueError(_('session already used'))
49 if persistent: # pragma: optional cover
50 raise ValueError(_('a dictionary cannot be persistent'))
51 self.session_id = session_id
52 self.persistent = persistent
53 _list_sessions.append(self.session_id)
57 _list_sessions.remove(self.session_id)
58 except AttributeError: # pragma: optional cover