diff --git a/slapos/recipe/random.py b/slapos/recipe/random.py index 5c2abfbd966df64848f47b238a488588ba0acd8a..bcfba3ed763d104db2e011f7c5772dfbc637e413 100644 --- a/slapos/recipe/random.py +++ b/slapos/recipe/random.py @@ -123,7 +123,6 @@ class Password(object): """ def __init__(self, buildout, name, options): - options_get = options.get self.create_once = options.get('create-once', 'True').lower() \ in GenericBaseRecipe.TRUE_VALUES try: @@ -140,13 +139,21 @@ class Password(object): if e.errno != errno.ENOENT: raise if not passwd: - passwd = self.generatePassword(int(options_get('bytes', '8'))) + passwd = self.generatePassword(int(options.get('bytes', '8'))) self.update = self.install self.passwd = passwd.strip('\n') # Password must not go into .installed file, for 2 reasons: # security of course but also to prevent buildout to always reinstall. - options.get = lambda option, *args, **kw: passwd \ - if option == 'passwd' else options_get(option, *args, **kw) + def get(option, *args, **kw): + return passwd if option == 'passwd' else options_get(option, *args, **kw) + + try: + options_get = options._get + except AttributeError: + options_get = options.get + options.get = get + else: + options._get = get generatePassword = staticmethod(generatePassword)