[Freeipa-devel] [PATCH] 137 Entitlement registration.

Endi Sukma Dewata edewata at redhat.com
Wed Apr 13 15:03:53 UTC 2011


On 4/13/2011 9:12 AM, Adam Young wrote:
> Please make sure all String literals come from the interal.py messages
> plugin. New button labels are defined in entitle.js for Consume and
> Register.

I'm thinking to do that once we have all the entitlement functionalities 
implemented. There are also hard-coded button labels in ipa.css which 
I'm not sure how to remove. Any suggestion?

> The consume dialog should be limited to accepting only integer values:
> pass the validation pattern in to the text widget. that.entity =
> function(spec) {

There's no pattern defined in the metadata for the quantity. There is an 
'int' type though. I think we can add a general purpose type checking in 
addition to pattern validation. This can be done in a separate patch.

> We are starting to see a proliferation of code like this:
>
> if (spec instanceof Object){
> var factory = spec.factory || IPA.entity;
> entity = factory(spec);
> } else {
> var name = spec;
> entity = IPA.entity({name: name});
> }
> return that;
> };
>
>
> Can we pull it into a helper function?

I checked the code, there are only 2 instances (in entity.js and 
search.js) where the structures appear to be identical. Other instances 
contain slight variation which is difficult to extract. I'd suggest we 
should try to standardize the invocations first then refactor them into 
a helper function.

> In dialog.js the code that.entity = IPA.get_entity(that.entity_name);
> should happen before init, in the initial construction of the object.
> The goal is to remove init functions; please don't put any more code
> into them from here on out. Same thing with Facet in entity.js

See IPA.start_entities(). I don't think that's possible because the 
entity is only added into IPA.entities_by_name in add_entity() while the 
constructors are executed before that in the factory() invocation.

     factory = that.entity_factories[name];
     var entity = factory();
     add_entity(entity);
     entity.init();

The entity.init() is executed last, that's why IPA.get_entity() for now 
can only be invoked during the init() phase.

We could pass the entity object instead of entity name in the spec, but 
that will be a major change.

-- 
Endi S. Dewata




More information about the Freeipa-devel mailing list