~ubuntu-branches/ubuntu/oneiric/ubuntuone-control-panel/oneiric

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/cache.py

* New upstream release:
  [ Alejandro J. Cura <alecu@canonical.com>]
    - Do not throw a webclient error when closing
      (LP: #845105).
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - Removed all code related to Bookmarks (LP: #850142).
    - Replaces references to "Evolution" by "Thunderbird" (LP: #849494).
  [ Rodney Dawes <rodney.dawes@canonical.com> ]
    - Don't install a .desktop file for control panel
      (part of LP: #838778).
    - Point the indicator/Unity API at the installer .desktop file
      (part of LP: #838778).
    - Set the WMCLASS so Unity will fall back properly
      (part of LP: #838778).
    - Fix a few grammar mistakes (LP: #835093).
    - Don't show the "Get NGB free!" label on "Join now" button at all
      (LP: #819955).
* debian/control:
  - ubuntuone-control-panel-gtk depends now on ubuntuone-installer >= 2.0.0.
  - require ubuntuone-client >= 2.0.0.
  - require ubuntu-sso-client >= 1.4.0.
  - no longer install a .desktop file (will be installed by ubuntuone-installer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License version 3, as published
 
9
# by the Free Software Foundation.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
# PURPOSE.  See the GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License along
 
17
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
"""The base object that holds a backend instance."""
 
20
 
 
21
from ubuntuone.controlpanel import backend
 
22
 
 
23
 
 
24
class Cache(object):
 
25
    """The base object that caches stuff."""
 
26
 
 
27
    logger = None
 
28
    _shared_objects = {}
 
29
 
 
30
    def __init__(self, *args, **kwargs):
 
31
        """Initialize the object using 'backend' as backend."""
 
32
        super(Cache, self).__init__()
 
33
        if self.logger is not None:
 
34
            self.logger.debug('%s: started.', self.__class__.__name__)
 
35
 
 
36
    def get_backend(self):
 
37
        """A cached ControlBackend instance."""
 
38
        if not self._shared_objects:
 
39
            self._shared_objects['backend'] = backend.ControlBackend()
 
40
        return self._shared_objects['backend']
 
41
 
 
42
    def set_backend(self, new_value):
 
43
        """Set a new ControlBackend instance."""
 
44
        self._shared_objects['backend'] = new_value
 
45
 
 
46
    backend = property(fget=get_backend, fset=set_backend)
 
47
 
 
48
    def clear(self):
 
49
        """Clear all cached objects."""
 
50
        self._shared_objects = {}