[openstack-dev] [Nova] Code question on dict copy in compute/volume api
unicell
unicell at gmail.com
Wed Aug 15 02:51:57 UTC 2012
Hi Folks,
One thing bothers me a lot when reading following code. Could someone
helps me out? Thanks a lot!
In nova/volume/api.py
Why it has to duplicate a dict copy on return? Or, why not directly
return the "rv", it's also a dictionary anyway.
def get_snapshot(self, context, snapshot_id):
check_policy(context, 'get_snapshot')
rv = self.db.snapshot_get(context, snapshot_id)
return dict(rv.iteritems())
And, why dicrectly return at following case?
def get_all_snapshots(self, context, search_opts=None):
...snip...
return self.db.snapshot_get_all_by_project(context,
context.project_id)
I kindof feel it is something related to python scoping rule, but not
quite sure.
Best Regards,
--
unicell
More information about the OpenStack-dev
mailing list