From e010c9015fa210050b6e4dcacf43773b648087e5 Mon Sep 17 00:00:00 2001 From: Eugene Nikanorov Date: Wed, 18 Jun 2014 18:13:28 +0400 Subject: [PATCH] Move _filter_non_model_columns method to CommonDbMixin Such way other non-core plugins may avoid duplicating this small piece of code. Change-Id: I00ae0b590fc2ad46d3667d18f29fccb5b40bde82 --- neutron/db/db_base_plugin_v2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index 976d89caa..4d804f559 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -217,6 +217,14 @@ class CommonDbMixin(object): return getattr(self, '_get_%s' % resource)(context, marker) return None + def _filter_non_model_columns(self, data, model): + """Remove all the attributes from data which are not columns of + the model passed as second parameter. + """ + columns = [c.name for c in model.__table__.columns] + return dict((k, v) for (k, v) in + data.iteritems() if k in columns) + class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2, CommonDbMixin): @@ -255,14 +263,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2, cur_funcs.extend(funcs) cls._dict_extend_functions[resource] = cur_funcs - def _filter_non_model_columns(self, data, model): - """Remove all the attributes from data which are not columns of - the model passed as second parameter. - """ - columns = [c.name for c in model.__table__.columns] - return dict((k, v) for (k, v) in - data.iteritems() if k in columns) - def _get_network(self, context, id): try: network = self._get_by_id(context, models_v2.Network, id) -- 2.45.2