This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit 66e96d277460e92cddbe905672d65dc4daa50ef7 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Fri Mar 21 01:31:43 2014 +0100 fix profile COPYing and hostname changes --- x2go/backends/profiles/base.py | 34 +++++++++++++++++++++++----------- x2go/backends/profiles/file.py | 2 +- x2go/inifiles.py | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/x2go/backends/profiles/base.py b/x2go/backends/profiles/base.py index 7630a8a..c19571f 100644 --- a/x2go/backends/profiles/base.py +++ b/x2go/backends/profiles/base.py @@ -179,19 +179,24 @@ class X2GoSessionProfiles(): else: return self._profile_metatypes[_profile_id] - def is_mutable(self, profile_id_or_name): + def is_mutable(self, profile_id_or_name=None, profile_id=None): """\ Check if a given profile name (or ID) is mutable or not. @param profile_id_or_name: profile name or profile ID @type profile_id_or_name: C{str} + @param profile_id: if the profile ID is known, pass it in directly and skip + the L{check_profile_id_or_name()} call + @type profile_id: C{str} @return: C{True} if the session profile of the specified name/ID is mutable @rtype: C{bool} + @raise X2GoProfileException: if no such session profile exists + """ try: - profile_id = self.check_profile_id_or_name(profile_id_or_name) + profile_id = profile_id or self.check_profile_id_or_name(profile_id_or_name) return self._is_mutable(profile_id) except X2GoProfileException: return None @@ -258,8 +263,9 @@ class X2GoSessionProfiles(): self._delete_profile(profile_id) try: del self._cached_profile_ids[profile_id] - except ValueError: pass + except KeyError: pass self.add_profile(profile_id=None, force_add=True, **_config) + self._profiles_need_profile_id_renewal = [] self._cached_profile_ids = {} @@ -485,6 +491,8 @@ class X2GoSessionProfiles(): if kwargs['name'] in self.profile_names and not force_add: raise X2GoProfileException('a profile of name ,,%s\'\' already exists' % kwargs['name']) + self._cached_profile_ids[profile_id] = kwargs['name'] + for key, value in kwargs.items(): self.update_value(None, key, value, profile_id=profile_id) @@ -492,7 +500,7 @@ class X2GoSessionProfiles(): if key in kwargs: continue self.update_value(None, key, value, profile_id=profile_id) - self._cached_profile_ids = [] + self._cached_profile_ids = {} return unicode(profile_id) @@ -510,8 +518,7 @@ class X2GoSessionProfiles(): self.write_user_config = True self.write() - self._cached_profile_ids = [] - self._cached_profile_names = [] + self._cached_profile_ids = {} def _delete_profile(self, profile_id): """\ @@ -531,6 +538,9 @@ class X2GoSessionProfiles(): @type option: C{str} @param value: the value to update the session profile option with @type value: any type, depends on the session profile option + @param profile_id: if the profile ID is known, pass it in directly and skip + the L{check_profile_id_or_name()} call + @type profile_id: C{str} """ try: @@ -538,7 +548,7 @@ class X2GoSessionProfiles(): except X2GoProfileException: profile_id = profile_id_or_name - if not self.is_mutable(profile_id): + if not self.is_mutable(profile_id=profile_id): raise X2GoProfileException("session profile cannot be modified, it is marked as immutable") if option == 'name': @@ -547,9 +557,11 @@ class X2GoSessionProfiles(): if not profile_name: raise X2GoProfileException('profile name for profile id %s must not be empty' % profile_id) else: - self._cached_profile_names = [] - if profile_name != current_profile_name and profile_name in self.profile_names: - raise X2GoProfileException('a profile of name ,,%s\'\' already exists' % profile_name) + if profile_name != current_profile_name: + try: del self._cached_profile_ids[profile_id] + except KeyError: pass + if profile_name in self.profile_names: + raise X2GoProfileException('a profile of name ,,%s\'\' already exists' % profile_name) if option == 'export' and type(value) == types.DictType: _strvalue = '"' @@ -561,7 +573,7 @@ class X2GoSessionProfiles(): if option == 'host': _host = self.get_profile_config(profile_id=profile_id, parameter='host') - if _host != value: + if _host != value and _host is not None: self._profiles_need_profile_id_renewal.append(profile_id) if type(value) is types.TupleType: value = list(value) diff --git a/x2go/backends/profiles/file.py b/x2go/backends/profiles/file.py index c9c0f7c..39e7da1 100644 --- a/x2go/backends/profiles/file.py +++ b/x2go/backends/profiles/file.py @@ -109,7 +109,7 @@ class X2GoSessionProfiles(base.X2GoSessionProfiles, inifiles.X2GoIniFile): def _update_value(self, profile_id, option, value): if option == 'host': value = ','.join(value) - inifiles.X2GoIniFile.update_value(self, profile_id, option, value) + self._X2GoIniFile__update_value(profile_id, option, value) def _get_profile_parameter(self, profile_id, option, key_type): return self.get(profile_id, option, key_type) diff --git a/x2go/inifiles.py b/x2go/inifiles.py index 1bc10d4..84a3e51 100644 --- a/x2go/inifiles.py +++ b/x2go/inifiles.py @@ -194,6 +194,7 @@ class X2GoIniFile(object): self.iniConfig.add_section(section) self._storeValue(section, key, value) self._write_user_config = True + __update_value = update_value def write(self): """\ -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git