<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2">hi,<br>notifier part calls:<br>def get_admin_context(show_deleted="no"):<br> context = RequestContext(None,<br> tenant=None,<br> is_admin=True,<br> show_deleted=show_deleted)<br> return context<br><br><br>def get_context_from_function_and_args(function, args, kwargs):<br> """Find an arg of type RequestContext and return it.<br><br> This is useful in a couple of decorators where we don't<br> know much about the function we're wrapping.<br> """<br><br> for arg in itertools.chain(kwargs.values(), args):<br> if isinstance(arg, RequestContext):<br> return arg<br><br> return None<br>which forces the projects' context to base on common RequestContext. Project has no way to redefine the get_admin_context() call.<br><br>Thanks<br>Yong Sheng Gong<br><span><br></span><br><br><font color="#990099">-----Russell Bryant <a class="moz-txt-link-rfc2396E" href="mailto:rbryant@redhat.com"><rbryant@redhat.com></a> wrote: -----</font><div style="padding-left: 5px;"><div style="padding-right: 0px; padding-left: 5px; border-left: 2px solid black;">To: <a class="moz-txt-link-abbreviated" href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a><br>From: Russell Bryant <a class="moz-txt-link-rfc2396E" href="mailto:rbryant@redhat.com"><rbryant@redhat.com></a><br>Date: 07/18/2012 09:22AM<br>Subject: Re: [openstack-dev] Context class of openstack common project<br><br><div><font face="Courier New,Courier,monospace" size="2">On 07/17/2012 07:24 PM, Yong Sheng Gong wrote:<br>> Hi,<br>> We ( quantum) are using notifier and rpc code of openstack common<br>> project, but found these common codes need a common Context class.<br>> I think the common Context class is from glance project, which is using<br>> user, and tenant instead of user_id and tenant_id in nova.<br>> Quantum's Context class is from nova originally.<br>> <br>> I think for all others to use the Common code, we have to redesign the<br>> common Context so that it is easy to be a base class.<br>> 1. Don't have fields, such as user, and tenant. Instead we can have<br>> methods.<br><br>The rpc code doesn't make any assumptions about what fields that context<br>has. I believe the only requirement is that it has a to_dict() method.<br><br>It also looks like the notifiers don't use the context at all, except to<br>pass it through to rpc. I'm not even sure the context is necessary or<br>useful for notifications.<br><br>I guess we could have a base class, but the only thing that I can find<br>that the common code cares about is that there is a to_dict() method.<br>Did you come across something else?<br><br>> 2. Don't use module methods since it is no way to be redefined.<br>> Consider factory or define it in configuration.<br><br><br>-- <br>Russell Bryant<br><br><br><br>_______________________________________________<br>OpenStack-dev mailing list<br><a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br><br></font></div></div></div></font>