Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2015-01-08 Thread Martin Basti

On 16/12/14 13:04, Martin Basti wrote:

On 16/12/14 13:00, Martin Kosek wrote:

On 12/16/2014 12:30 PM, Martin Basti wrote:

On 11/12/14 12:13, Martin Basti wrote:

On 11/12/14 11:19, Jan Cholasta wrote:

Hi,

Dne 9.12.2014 v 16:07 Martin Basti napsal(a):

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.

Which test?
If you apply my patch 170 and add a random forwardzone, then DNS 
root zone

tests failed.

Patch attached.

What about:

 result['messages'] = result.get('messages', ()) + 
(message.to_dict(),)


(My point is, don't support both lists and tuples, pick just one.)

Honza


This is question for framework guru (you?), I tried to preserve format
unchanged.
Shouldn't be all values in lists in server part?

Martin^2


As was requested, I convert tuple to list instead handling both types.

Updated patch attached.

I assume you do not want to track the  .idea/ files in FreeIPA git :-)


Oh, thanks. My IDE was too smart again and add those files there itself.

updated patch attached


Please review this patch.

--
Martin Basti

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


Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-16 Thread Martin Basti

On 11/12/14 12:13, Martin Basti wrote:

On 11/12/14 11:19, Jan Cholasta wrote:

Hi,

Dne 9.12.2014 v 16:07 Martin Basti napsal(a):

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.


Which test?
If you apply my patch 170 and add a random forwardzone, then DNS root 
zone tests failed.




Patch attached.


What about:

result['messages'] = result.get('messages', ()) + 
(message.to_dict(),)


(My point is, don't support both lists and tuples, pick just one.)

Honza

This is question for framework guru (you?), I tried to preserve format 
unchanged.

Shouldn't be all values in lists in server part?

Martin^2


As was requested, I convert tuple to list instead handling both types.

Updated patch attached.



--
Martin Basti

From 55948536aa37a4625fb84f8e0c0a5ece65b649d3 Mon Sep 17 00:00:00 2001
From: Martin Basti mba...@redhat.com
Date: Tue, 16 Dec 2014 12:28:07 +0100
Subject: [PATCH] Fix add message on client side

https://fedorahosted.org/freeipa/ticket/4793
---
 .idea/inspectionProfiles/Project_Default.xml   | 15 +++
 .idea/inspectionProfiles/profiles_settings.xml |  7 +++
 ipalib/frontend.py |  6 ++
 3 files changed, 28 insertions(+)
 create mode 100644 .idea/inspectionProfiles/Project_Default.xml
 create mode 100644 .idea/inspectionProfiles/profiles_settings.xml

diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index ..2288d89872ce51c1f8b2e2d4ffeb91213c56600c
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,15 @@
+component name=InspectionProjectProfileManager
+  profile version=1.0 is_locked=false
+option name=myName value=Project Default /
+option name=myLocal value=false /
+inspection_tool class=PyPackageRequirementsInspection enabled=true level=WARNING enabled_by_default=true
+  option name=ignoredPackages
+value
+  list size=1
+item index=0 class=java.lang.String itemvalue=dns /
+  /list
+/value
+  /option
+/inspection_tool
+  /profile
+/component
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index ..3b312839bf2e939fea3ebdef15630a4b33e57caf
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+component name=InspectionProjectProfileManager
+  settings
+option name=PROJECT_PROFILE value=Project Default /
+option name=USE_PROJECT_PROFILE value=true /
+version value=1.0 /
+  /settings
+/component
\ No newline at end of file
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index a9a3dfeaac2ab7047c036ea7bbed7655dd93be56..565e1af29df5d39b80048f2af33281a31c374b9e 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -438,6 +438,12 @@ class Command(HasParam):
 (args, options) = self.params_2_args_options(**params)
 ret = self.run(*args, **options)
 if not version_provided and isinstance(ret, dict):
+# on client side the messages can be stored in tuple
+# convert them into list first
+ret_messages = ret.get('messages')
+if isinstance(ret_messages, tuple):
+ret['messages'] = list(ret_messages)
+
 messages.add_message(
 API_VERSION, ret,
 messages.VersionMissing(server_version=API_VERSION))
-- 
1.8.3.1

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

Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-16 Thread Martin Kosek
On 12/16/2014 12:30 PM, Martin Basti wrote:
 On 11/12/14 12:13, Martin Basti wrote:
 On 11/12/14 11:19, Jan Cholasta wrote:
 Hi,

 Dne 9.12.2014 v 16:07 Martin Basti napsal(a):
 Ticket: https://fedorahosted.org/freeipa/ticket/4793

 I'm able to reproduce it only in one nose test.

 Which test?
 If you apply my patch 170 and add a random forwardzone, then DNS root zone
 tests failed.


 Patch attached.

 What about:

 result['messages'] = result.get('messages', ()) + (message.to_dict(),)

 (My point is, don't support both lists and tuples, pick just one.)

 Honza

 This is question for framework guru (you?), I tried to preserve format
 unchanged.
 Shouldn't be all values in lists in server part?

 Martin^2

 As was requested, I convert tuple to list instead handling both types.
 
 Updated patch attached.

I assume you do not want to track the  .idea/ files in FreeIPA git :-)

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


Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-16 Thread Martin Basti

On 16/12/14 13:00, Martin Kosek wrote:

On 12/16/2014 12:30 PM, Martin Basti wrote:

On 11/12/14 12:13, Martin Basti wrote:

On 11/12/14 11:19, Jan Cholasta wrote:

Hi,

Dne 9.12.2014 v 16:07 Martin Basti napsal(a):

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.

Which test?

If you apply my patch 170 and add a random forwardzone, then DNS root zone
tests failed.

Patch attached.

What about:

 result['messages'] = result.get('messages', ()) + (message.to_dict(),)

(My point is, don't support both lists and tuples, pick just one.)

Honza


This is question for framework guru (you?), I tried to preserve format
unchanged.
Shouldn't be all values in lists in server part?

Martin^2


As was requested, I convert tuple to list instead handling both types.

Updated patch attached.

I assume you do not want to track the  .idea/ files in FreeIPA git :-)


Oh, thanks. My IDE was too smart again and add those files there itself.

updated patch attached

--
Martin Basti

From dae3109cb3b1ba9ae95c2b4cf44c94b22846584f Mon Sep 17 00:00:00 2001
From: Martin Basti mba...@redhat.com
Date: Tue, 16 Dec 2014 13:02:12 +0100
Subject: [PATCH] Fix warning message on client side

https://fedorahosted.org/freeipa/ticket/4793
---
 ipalib/frontend.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index a9a3dfeaac2ab7047c036ea7bbed7655dd93be56..565e1af29df5d39b80048f2af33281a31c374b9e 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -438,6 +438,12 @@ class Command(HasParam):
 (args, options) = self.params_2_args_options(**params)
 ret = self.run(*args, **options)
 if not version_provided and isinstance(ret, dict):
+# on client side the messages can be stored in tuple
+# convert them into list first
+ret_messages = ret.get('messages')
+if isinstance(ret_messages, tuple):
+ret['messages'] = list(ret_messages)
+
 messages.add_message(
 API_VERSION, ret,
 messages.VersionMissing(server_version=API_VERSION))
-- 
1.8.3.1

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

Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-11 Thread Jan Cholasta

Hi,

Dne 9.12.2014 v 16:07 Martin Basti napsal(a):

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.


Which test?



Patch attached.


What about:

result['messages'] = result.get('messages', ()) + (message.to_dict(),)

(My point is, don't support both lists and tuples, pick just one.)

Honza

--
Jan Cholasta

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


Re: [Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-11 Thread Martin Basti

On 11/12/14 11:19, Jan Cholasta wrote:

Hi,

Dne 9.12.2014 v 16:07 Martin Basti napsal(a):

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.


Which test?
If you apply my patch 170 and add a random forwardzone, then DNS root 
zone tests failed.




Patch attached.


What about:

result['messages'] = result.get('messages', ()) + 
(message.to_dict(),)


(My point is, don't support both lists and tuples, pick just one.)

Honza

This is question for framework guru (you?), I tried to preserve format 
unchanged.

Shouldn't be all values in lists in server part?

Martin^2

--
Martin Basti

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


[Freeipa-devel] [PATCH 0177] Fix adding (warning) messages on client side

2014-12-09 Thread Martin Basti

Ticket: https://fedorahosted.org/freeipa/ticket/4793

I'm able to reproduce it only in one nose test.

Patch attached.

--
Martin Basti

From a50874ff0d32b004545b76f987fc402548bd2de8 Mon Sep 17 00:00:00 2001
From: Martin Basti mba...@redhat.com
Date: Tue, 9 Dec 2014 12:27:42 +0100
Subject: [PATCH] Fix adding messages on client side

https://fedorahosted.org/freeipa/ticket/4793
---
 ipalib/messages.py | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/ipalib/messages.py b/ipalib/messages.py
index b44beca729f5483a7241e4c98a9f724ed663e70f..3076879009312fd342c652c57dbb6555dc3a905d 100644
--- a/ipalib/messages.py
+++ b/ipalib/messages.py
@@ -39,8 +39,18 @@ from ipalib.capabilities import client_has_capability
 
 
 def add_message(version, result, message):
+
+Add new message to result.
+Result can contain messages in tuple on client and in list on server.
+
 if client_has_capability(version, 'messages'):
-result.setdefault('messages', []).append(message.to_dict())
+messages = result.get('messages')
+if isinstance(messages, tuple):
+# messages are in tuple, concatenate it with new message
+result['messages'] = messages + (message.to_dict(),)
+else:
+# None, list
+result.setdefault('messages', []).append(message.to_dict())
 
 
 def process_message_arguments(obj, format=None, message=None, **kw):
-- 
1.8.3.1

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