[openstack-dev] [wsme] Undefined attributes in WSME

Jamie Lennox jamielennox at redhat.com
Fri Jan 10 07:11:31 UTC 2014


On Thu, 2014-01-09 at 11:16 +0100, Julien Danjou wrote:
> On Thu, Jan 09 2014, Jamie Lennox wrote:
> 
> > Is there any way to have WSME pass through arbitrary attributes to the
> > created object? There is nothing that i can see in the documentation or code
> > that would seem to support this.
> >
> > In keystone we have the situation where arbitrary data was able to be
> > attached to our resources. For example there are a certain number of
> > predefined attributes for a user including name, email but if you want to
> > include an address you just add an 'address': 'value' to the resource
> > creation and it will be saved and returned to you when you request the
> > resource.
> >
> > Ignoring whether this is a good idea or not (it's done), is the option there
> > that i missed - or is there any plans/way to support something like this?
> 
> You can use something like:
> 
>   class Resource(object):
>       metadata = {wtypes.text: wtypes.text}
> 
> Would that solve your problem?
> 

That would still only give me 1 level and i would then have to manually
parse out the arguments i was expecting. Continuing the example there is
nothing in the current implementation stopping people from using
        
        {'address': {'street': '..', 'country': '..'}} 
        
So we can't just have the flat dictionary. (and i think wsme would fail
if someone passed an integer value for example).

What i'm kind of hoping for is some sort of remainder value in wsme such
that i could define my base types:

        class User(object): 
            id = wtypes.text
            email = wtypes.text
        
and later have a user: 

        >>> user.id
        '9da353d02c0546ab9b3b402f58c6ab0d'
        >>> user.email
        'user at provider'
        >>> user.remainder
        {'address': {'country': '..', 'street': '..'}}

now i'm obviously not expecting exactly that - but hoping for some kind
of catch all that i can use. 

Thanks, 

Jamie




More information about the OpenStack-dev mailing list