Hi Udara/Milindu,

IMO there's little to be shared between disparate Python components in
Stratos since we are not distributing them as PIP packages (except for the
proposed CLI). Importing cannot be done unless a parent Python package
(with an __init__.py) is shared between the components (either an absolute
or a relative module path should be given to import a module), therefore
separating the REST client doesn't really fit in, w.r.t reuse. Furthermore,
when it comes to making REST calls, it will boil down to a set of urllib2
calls which is not a crucial level of complexity for modularization and
reuse. Without having a common Python root for all Python components,
separating modules anticipating reuse by different components might be
premature optimization.

+1 for a separate module with handlers to handle each response. In the
current CLI there are few shortcomings related to handling success or
failure of a particular command based on the response code. We would be
able to overcome these by a proper design.


Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com



On Tue, May 5, 2015 at 5:43 PM, Milindu Sanoj Kumarage <
agentmili...@gmail.com> wrote:

> Hi,
>
> Thanks for the suggestions :D
> I'll try to take out the REST part and implement it in a generic way. I
> saw a recent discussion on re-factoring the REST API to further standardize
> the status codes and Exception types, etc. Hope it would help me to get
> through.
>
> Thanks.
>
> On Mon, May 4, 2015 at 8:34 PM, Udara Liyanage <ud...@wso2.com> wrote:
>
>> HI Milindu,
>>
>> Few suggestions....
>>
>>
>> Isn't it better to take out REST client from Stratos.py. Rest client
>> seems a common module which other components may need. May be Cartridge
>> agent and CLI uses the same module.
>>
>> Handle responses in a generic way at one place(This is what we learn from
>> existing CLI). From version to version return codes, response format may
>> change in Stratos REST API. In that case you only need to change at one
>> place if you have handled in a generic manner.
>>
>> On Mon, May 4, 2015 at 2:16 PM, Milindu Sanoj Kumarage <
>> agentmili...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I thought of separating the Python CLI into 3 main parts, those are,
>>>
>>> 1. Main.py - that contains the entry point, it does the initializing
>>> parts, creates a CLI instance and runs the loop,
>>> 2. CLI.py - this is the actual CLI that extends Cmd2. This contains the
>>> command to def mappings, argument and flag handling, printing outputs, etc.
>>> 3. Stratos.py - this contains the actual business logic, that is, which
>>> REST end point to call, and do what with the response, what to show, what
>>> not, etc. At the end, this would be like a Python API for Stratos.
>>>
>>> This way, in the future, we can even replace Cmd2 CLI framework without
>>> any issue, if we have to.
>>>
>>> Your ideas? :)
>>>
>>
>>
>>
>> --
>>
>> Udara Liyanage
>> Software Engineer
>> WSO2, Inc.: http://wso2.com
>> lean. enterprise. middleware
>>
>> web: http://udaraliyanage.wordpress.com
>> phone: +94 71 443 6897
>>
>
>

Reply via email to