Vreman, Peter - Acision wrote:
> -----Original Message-----
> From: cobbler-devel-bounces(a)lists.fedorahosted.org [mailto:cobbler-devel-
> bounces(a)lists.fedorahosted.org] On Behalf Of Michael DeHaan
> Sent: woensdag 8 april 2009 14:18
> To: cobbler development list
> Subject: Re: api.find_system and remote.get_system
>
> Vreman, Peter - Acision wrote:
>
>> There is a difference in the internal and remote api.
>>
>>
>>
>> The internal api has find_system to retrieve a single or multiple
>> items with an optional filter.
>>
>>
>>
>> The remote api has a dedicated get_system to retrieve a single item
>>
>>
>>
>> Can this be changed to:
>>
>>
>>
>> Api.find_systems(matchtype,**kvargs) returns a list
>>
>> Api.get_system(name) returns a item
>>
>> Api.get_systems returns a list
>>
>>
>>
>> Remote.find_systems(matchtype,page,results_per_page,**kvargs) returns
>> a list
>>
>> Remote.get_system(name) returns a item
>>
>> Remote.get_systems() returns a list
>>
>>
>> This makes it more consistent and transparent. The remote functions
>> will become simple wrappers. Eventually the paginate function can also
>> be merged into the Api instead of Remote.
>>
>>
> We can do what we want with remote as long as the previous calling
> syntaxes still work.
>
> I think before you talked about implementing most of the remote
> functions via a wrapper to find, which I agree with.
>
> The important thing is to not break API calling signatures of any of the
> local or remote methods.
>
> Any new arguments should have default values so those new arguments are
> optional.
>
The backwards compatibility is the issue.
For example the current the api.find_system() call is used for both finding multiple
systems and for retrieving a single system.
For maintenance and extensibility the easiest is to have the following API methods:
Api.find_systems(matchtype,page,results_per_page,**kvargs)
Api.get_system(name) returns a item
Api.get_systems() returns a list
Changing the API signatures in a backwards compatible way can't happen.
Adding new methods and making the old ones use the code behind the new
ones is perfectly fine.
For remote we can create aliases using setattr/getattr with something
like:
setattr(self.__class__, 'find_%s' % what, getattr(self.api, 'find_%s' %
what))
We don't want to use this kind of magic in the codebase. We want
standand-ly defined methods ... readability counts.
This reduces the code duplication in api.py and remote.py
Peter
This e-mail and any attachment is for authorised use by the intended recipient(s) only.
It may contain proprietary material, confidential information and/or be subject to legal
privilege. It should not be copied, disclosed to, retained or used by, any other party. If
you are not an intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
cobbler-devel mailing list
cobbler-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler-devel