[openstack-dev] Context class of openstack common project

John Garbutt John.Garbutt at citrix.com
Wed Jul 18 18:21:37 UTC 2012


> From: Andrew Bogott [mailto:abogott at wikimedia.org]
> > On Wed, 2012-07-18 at 07:24 +0800, Yong Sheng Gong wrote:
> >> Hi,
> >> We ( quantum) are using notifier and rpc code of openstack common
> >> project, but found these common codes need a common Context class.
> >> I think the common Context class is from glance project, which is
> >> using user, and tenant instead of user_id and tenant_id in nova.
> >> Quantum's Context class is from nova originally.
> > I see that while the common notifiers code uses this class - and Nova
> > uses the common notifiers code - Nova itself doesn't use the class.
> > So, I'm not sure how this is supposed to work.
> 
> At the moment, it probably doesn't :(
> 
> Request context is vital for the plugin framework, which needs the context it
> gets via notifications for various purposes.
> 
> The common notifier imports the common context base class only in order to
> call get_context_from_function_and_args, which does isinstance(arg,
> RequestContext) in order to identify the context. Any context which doesn't
> inherit from this class will be overlooked.
> 
> So, possible solutions are a) change get_context_from_function_and_args
> to work via duck-typing rather than checking the actual class type, or
> b) insist that project-specific request contexts inherit from the common context
> base class.  I would prefer b, even if the common class is essentially empty.

Would not option (a) be more pythonic?
If it were not python, I would say use in interface rather than an abstract bass class.

But (a) or (b), it sounds like a good step forward.

John



More information about the OpenStack-dev mailing list