← Back to team overview

openstack team mailing list archive

Re: Just JSON, and extensibility

 

On Sat, Apr 14, 2012 at 10:46 AM, Justin Santa Barbara
<justin@xxxxxxxxxxxx>wrote:

>
>>>    - Each (known) extension has its own strongly-typed model object.
>>>
>>>
>> Does that mean that an extension cannot add properties to an existing
>> object (such as adding a new attribute an Image), or just that all of those
>> properties will be an a nested object (such as
>> Image.my_extension.my_attribute)?
>>
>
> Good point - I should clarify...  I'm not using the standard Java XML
> binding code here, because they would require a wrapping object.  It's
> using custom code to do the binding whenever data from a different
> namespace is encountered, although it uses the standard JAXB annotations to
> guide it.  From the user's point of view, "it just works"; the
> implementation is not as nice :-)
>

OK. I was asking from a lack-of-knowledge of how this sort of thing is
usually done in Java. If an extension adds a piece of data to an object,
what does a client need to do to access it?


>
> Because we're not wrapping our extensions in their own elements, I didn't
> know how to get the standard tooling to work with it anyway.  Interesting
> data-point for the "standard tools" argument...
>
>
>> Now, how you would do something that awesome in Python, I don't know ;-)
>>>
>>
>> Probably the same way. I would use setuptools entry points to map
>> namespace prefixes to the class, so the client could load the handler
>> automatically when it encounters data it does not recognize.
>>
>
> Yes - I should have said "dictionary" rather than "registry"!  Are you
> doing this in python-novaclient?  Awesome!
>

I've done it before in other projects, but not in OpenStack, yet. I was
going to bring up the idea of using setuptools for plugins and extensions
like this at the summit during the session(s) on moving code into common
and revamping the CLI tools.

Doug

References