[Freeipa-devel] [PATCH] 0487 ipalib.plugable: Always set the parser in bootstrap()

2014-03-05 Thread Petr Viktorin

Hello,
This patch fixes a failing test setup where logging was configured 
before the API was bootstrapped.

The __setattr__ is moved before a conditional return.

--
PetrĀ³
From d90395f3c7dc54efda49355976155bd56dc2259d Mon Sep 17 00:00:00 2001
From: Petr Viktorin pvikt...@redhat.com
Date: Wed, 5 Mar 2014 13:59:10 +0100
Subject: [PATCH] ipalib.plugable: Always set the parser in bootstrap()

In cases where logging was already configured by the time
API.bootstrap() was called, saving the argument parser was
mistakenly skipped along with the logging configuration.

Always set the argument parser on the API object.
---
 ipalib/plugable.py | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 3be8bb118570e5f80853376eb8e6973b8b087e46..216f9c08a8b5d22bdb1e7853013967e8fe3f88b0 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -493,6 +493,12 @@ def bootstrap(self, parser=None, **overrides):
 object.__setattr__(self, 'log_mgr', log_mgr)
 log = log_mgr.root_logger
 object.__setattr__(self, 'log', log)
+
+# Add the argument parser
+if not parser:
+parser = self.build_global_parser()
+object.__setattr__(self, 'parser', parser)
+
 # If logging has already been configured somewhere else (like in the
 # installer), don't add handlers or change levels:
 if log_mgr.configure_state != 'default' or self.env.validate_api:
@@ -518,10 +524,6 @@ def bootstrap(self, parser=None, **overrides):
   level=level,
   format=LOGGING_FORMAT_STDERR)])
 
-if not parser:
-parser = self.build_global_parser()
-object.__setattr__(self, 'parser', parser)
-
 # Add file handler:
 if self.env.mode in ('dummy', 'unit_test'):
 return  # But not if in unit-test mode
-- 
1.8.5.3

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0487 ipalib.plugable: Always set the parser in bootstrap()

2014-03-05 Thread Jan Cholasta

On 5.3.2014 14:51, Petr Viktorin wrote:

Hello,
This patch fixes a failing test setup where logging was configured
before the API was bootstrapped.
The __setattr__ is moved before a conditional return.


ACK, the test failures are gone.

--
Jan Cholasta

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel