]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move _filter_non_model_columns method to CommonDbMixin
authorEugene Nikanorov <enikanorov@mirantis.com>
Wed, 18 Jun 2014 14:13:28 +0000 (18:13 +0400)
committerenikanorov <enikanorov@mirantis.com>
Wed, 18 Jun 2014 20:11:12 +0000 (20:11 +0000)
Such way other non-core plugins may avoid duplicating this small
piece of code.

Change-Id: I00ae0b590fc2ad46d3667d18f29fccb5b40bde82

neutron/db/db_base_plugin_v2.py

index 976d89caa25647a8e9e5455eafc8ec1919b28eaf..4d804f559d896f9063fb43401d7e8fb6c003001f 100644 (file)
@@ -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)