Re: [Freeipa-devel] [PATCH] 0228-create-entities-on-demand

2011-05-23 Thread Adam Young

On 05/23/2011 01:31 PM, Adam Young wrote:

On 05/23/2011 01:13 PM, Adam Young wrote:

On 05/23/2011 12:38 PM, Adam Young wrote:

On 05/23/2011 12:06 PM, Endi Sukma Dewata wrote:

On 5/23/2011 9:42 AM, Adam Young wrote:

Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.


A few issues in IPA.get_entity():

1. It executes that.entities.get() twice. The result of the first
   invocation can be stored in a variable and reused later. The result
   of the factory() invocation can be assigned to the same variable.

2. It executes factory = that.entity_factories[name] twice. The second
   one can be removed.

Other than that it's ACKed and can be pushed after fixing the above 
issues.



Now with fixed unit tests


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

Better navigation test


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



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

ACKed in IRC by edewata and pushed to master
___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 0228-create-entities-on-demand

2011-05-23 Thread Adam Young

On 05/23/2011 01:13 PM, Adam Young wrote:

On 05/23/2011 12:38 PM, Adam Young wrote:

On 05/23/2011 12:06 PM, Endi Sukma Dewata wrote:

On 5/23/2011 9:42 AM, Adam Young wrote:

Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.


A few issues in IPA.get_entity():

1. It executes that.entities.get() twice. The result of the first
   invocation can be stored in a variable and reused later. The result
   of the factory() invocation can be assigned to the same variable.

2. It executes factory = that.entity_factories[name] twice. The second
   one can be removed.

Other than that it's ACKed and can be pushed after fixing the above 
issues.



Now with fixed unit tests


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

Better navigation test


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


From 03303390031ae88c9df3a0e14d85550884bb1740 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Mon, 23 May 2011 10:39:09 -0400
Subject: [PATCH] create entities on demand. fixed changes from code review

Fixed unit tests for entity on demand changes.
---
 install/ui/ipa.js   |   31 ++-
 install/ui/test/details_tests.js|1 -
 install/ui/test/entity_tests.js |1 -
 install/ui/test/navigation_tests.js |9 -
 install/ui/webui.js |2 --
 5 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 8f11b92df2e86adc61758da1790e900e562f2510..13c894fa6b614eb982e22f9dc01784c130092e70 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -131,31 +131,28 @@ var IPA = ( function () {
 };
 
 that.get_entity = function(name) {
-return that.entities.get(name);
-};
-
-that.add_entity = function(entity) {
-that.entities.put(entity.name, entity);
-};
-
-that.remove_entity = function(name) {
-that.entities.remove(name);
-};
-
-that.start_entities = function() {
-var factory;
-var name;
-for (name in that.entity_factories) {
-factory = that.entity_factories[name];
+var entity = that.entities.get(name);
+if (!entity){
+var factory = that.entity_factories[name];
 try {
-var entity = factory();
+entity = factory();
 that.add_entity(entity);
 entity.init();
 } catch (e) {
 /*exceptions thrown by builder just mean that entities
   are not to be registered. */
+return null;
 }
 }
+return entity;
+};
+
+that.add_entity = function(entity) {
+that.entities.put(entity.name, entity);
+};
+
+that.remove_entity = function(name) {
+that.entities.remove(name);
 };
 
 that.test_dirty = function(){
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 8f98f1fef33e19ba8400266ee7faf632da40764c..ca4658f8712f7925001c8a59d4de3bb6ae5aeb3a 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -43,7 +43,6 @@ module('details', {
 return IPA.entity({name:obj_name,
metadata:IPA.metadata.objects.user});
 };
-IPA.start_entities();
 },
 teardown: function() {
 details_container.remove();
diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js
index c258976f8834f9cfdc7e33cf0346f792e19be042..41e4d5e47ef42f7881aab82ba4f6ce9e195262a6 100644
--- a/install/ui/test/entity_tests.js
+++ b/install/ui/test/entity_tests.js
@@ -39,7 +39,6 @@ module('entity',{
 columns:['uid']}).
 build();
 };
-IPA.start_entities();
 },
 function(xhr, text_status, error_thrown) {
 ok(false, "ipa_init() failed: "+error_thrown);
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index 0f8f1be4a886074ca6946316f356dc9b0c6aadd4..d9bcc8eb6dd0feadc518d840d03649f4b10b0ef5 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -20,6 +20,7 @@
 
 
 module('navigation', {
+
 setup: function() {
 IPA.ajax_options.async = false;
 IPA.init(
@@ -32,11 +33,14 @@ module('navigation', {
 }
 );
 }
+
 });
 
 test("Testing IPA.navigation.create().", function() {
 
 var entity;
+var user_mock_called = false;
+var group_mock_called = false;
 
 IPA.entity_factories.user =  function() {
 var that = IPA.entity({name: 'user',
@@ -59,13 +63,8 @@ test("Testing IPA.navigation.create().", func

Re: [Freeipa-devel] [PATCH] 0228-create-entities-on-demand

2011-05-23 Thread Adam Young

On 05/23/2011 12:38 PM, Adam Young wrote:

On 05/23/2011 12:06 PM, Endi Sukma Dewata wrote:

On 5/23/2011 9:42 AM, Adam Young wrote:

Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.


A few issues in IPA.get_entity():

1. It executes that.entities.get() twice. The result of the first
   invocation can be stored in a variable and reused later. The result
   of the factory() invocation can be assigned to the same variable.

2. It executes factory = that.entity_factories[name] twice. The second
   one can be removed.

Other than that it's ACKed and can be pushed after fixing the above 
issues.



Now with fixed unit tests


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

Better navigation test
From 3ad21ca10461d0b2f8d34ab1e658799bab0c72b7 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Mon, 23 May 2011 10:39:09 -0400
Subject: [PATCH] create entities on demand. fixed changes from code review

Fixed unit tests for entity on demand changes.
---
 install/ui/ipa.js   |   31 ++-
 install/ui/test/details_tests.js|1 -
 install/ui/test/navigation_tests.js |9 -
 install/ui/webui.js |2 --
 4 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 8f11b92df2e86adc61758da1790e900e562f2510..13c894fa6b614eb982e22f9dc01784c130092e70 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -131,31 +131,28 @@ var IPA = ( function () {
 };
 
 that.get_entity = function(name) {
-return that.entities.get(name);
-};
-
-that.add_entity = function(entity) {
-that.entities.put(entity.name, entity);
-};
-
-that.remove_entity = function(name) {
-that.entities.remove(name);
-};
-
-that.start_entities = function() {
-var factory;
-var name;
-for (name in that.entity_factories) {
-factory = that.entity_factories[name];
+var entity = that.entities.get(name);
+if (!entity){
+var factory = that.entity_factories[name];
 try {
-var entity = factory();
+entity = factory();
 that.add_entity(entity);
 entity.init();
 } catch (e) {
 /*exceptions thrown by builder just mean that entities
   are not to be registered. */
+return null;
 }
 }
+return entity;
+};
+
+that.add_entity = function(entity) {
+that.entities.put(entity.name, entity);
+};
+
+that.remove_entity = function(name) {
+that.entities.remove(name);
 };
 
 that.test_dirty = function(){
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 8f98f1fef33e19ba8400266ee7faf632da40764c..ca4658f8712f7925001c8a59d4de3bb6ae5aeb3a 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -43,7 +43,6 @@ module('details', {
 return IPA.entity({name:obj_name,
metadata:IPA.metadata.objects.user});
 };
-IPA.start_entities();
 },
 teardown: function() {
 details_container.remove();
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index 0f8f1be4a886074ca6946316f356dc9b0c6aadd4..d9bcc8eb6dd0feadc518d840d03649f4b10b0ef5 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -20,6 +20,7 @@
 
 
 module('navigation', {
+
 setup: function() {
 IPA.ajax_options.async = false;
 IPA.init(
@@ -32,11 +33,14 @@ module('navigation', {
 }
 );
 }
+
 });
 
 test("Testing IPA.navigation.create().", function() {
 
 var entity;
+var user_mock_called = false;
+var group_mock_called = false;
 
 IPA.entity_factories.user =  function() {
 var that = IPA.entity({name: 'user',
@@ -59,13 +63,8 @@ test("Testing IPA.navigation.create().", function() {
 return that;
 };
 
-IPA.start_entities();
-
-IPA.metadata = {};
 var navigation_container = $('').appendTo(document.body);
 var entity_container = $('').appendTo(document.body);
-var user_mock_called = false;
-var group_mock_called = false;
 
 var navigation = IPA.navigation({
 container: navigation_container,
diff --git a/install/ui/webui.js b/install/ui/webui.js
index b9d050c29a0c93d96d242c16b873e3825ed82a95..00c35b459d0f649b773e308916fdc1a845c6ec4e 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -143,8 +143,6 @@ $(function() {
 $('#loggedinas a').fragment(
 {'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
 
-IPA.start_entities();
-
 IPA.nav = create_navigation();
 IPA.nav

Re: [Freeipa-devel] [PATCH] 0228-create-entities-on-demand

2011-05-23 Thread Adam Young

On 05/23/2011 12:06 PM, Endi Sukma Dewata wrote:

On 5/23/2011 9:42 AM, Adam Young wrote:

Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.


A few issues in IPA.get_entity():

1. It executes that.entities.get() twice. The result of the first
   invocation can be stored in a variable and reused later. The result
   of the factory() invocation can be assigned to the same variable.

2. It executes factory = that.entity_factories[name] twice. The second
   one can be removed.

Other than that it's ACKed and can be pushed after fixing the above 
issues.



Now with fixed unit tests
From 55c3f6db2b7a297192622662e26ee9b22bc724a3 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Mon, 23 May 2011 10:39:09 -0400
Subject: [PATCH] create entities on demand. fixed changes from code review

Fixed unit tests for entity on demand changes.
---
 install/ui/ipa.js   |   31 ++-
 install/ui/test/details_tests.js|1 -
 install/ui/test/navigation_tests.js |4 +++-
 install/ui/webui.js |2 --
 4 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 8f11b92df2e86adc61758da1790e900e562f2510..72365cfe3c08d1a52f79cc686fa246b30f9a09f2 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -131,31 +131,28 @@ var IPA = ( function () {
 };
 
 that.get_entity = function(name) {
-return that.entities.get(name);
-};
-
-that.add_entity = function(entity) {
-that.entities.put(entity.name, entity);
-};
-
-that.remove_entity = function(name) {
-that.entities.remove(name);
-};
-
-that.start_entities = function() {
-var factory;
-var name;
-for (name in that.entity_factories) {
-factory = that.entity_factories[name];
+var entity = that.entities.get(name);
+if (!entity){
+var factory = that.entity_factories[name];
 try {
-var entity = factory();
+entity = factory();
 that.add_entity(entity);
 entity.init();
 } catch (e) {
 /*exceptions thrown by builder just mean that entities
   are not to be registered. */
+return null;
 }
 }
+return that.entities.get(name);
+};
+
+that.add_entity = function(entity) {
+that.entities.put(entity.name, entity);
+};
+
+that.remove_entity = function(name) {
+that.entities.remove(name);
 };
 
 that.test_dirty = function(){
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 8f98f1fef33e19ba8400266ee7faf632da40764c..ca4658f8712f7925001c8a59d4de3bb6ae5aeb3a 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -43,7 +43,6 @@ module('details', {
 return IPA.entity({name:obj_name,
metadata:IPA.metadata.objects.user});
 };
-IPA.start_entities();
 },
 teardown: function() {
 details_container.remove();
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index 0f8f1be4a886074ca6946316f356dc9b0c6aadd4..c6d696fb87bb638452ec17e2a7a14982727dd79e 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -59,7 +59,9 @@ test("Testing IPA.navigation.create().", function() {
 return that;
 };
 
-IPA.start_entities();
+IPA.get_entity('user');
+IPA.get_entity('group');
+
 
 IPA.metadata = {};
 var navigation_container = $('').appendTo(document.body);
diff --git a/install/ui/webui.js b/install/ui/webui.js
index b9d050c29a0c93d96d242c16b873e3825ed82a95..00c35b459d0f649b773e308916fdc1a845c6ec4e 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -143,8 +143,6 @@ $(function() {
 $('#loggedinas a').fragment(
 {'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
 
-IPA.start_entities();
-
 IPA.nav = create_navigation();
 IPA.nav.create();
 IPA.nav.update();
-- 
1.7.5.1

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

Re: [Freeipa-devel] [PATCH] 0228-create-entities-on-demand

2011-05-23 Thread Endi Sukma Dewata

On 5/23/2011 9:42 AM, Adam Young wrote:

Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.


A few issues in IPA.get_entity():

1. It executes that.entities.get() twice. The result of the first
   invocation can be stored in a variable and reused later. The result
   of the factory() invocation can be assigned to the same variable.

2. It executes factory = that.entity_factories[name] twice. The second
   one can be removed.

Other than that it's ACKed and can be pushed after fixing the above issues.

--
Endi S. Dewata

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