Skip to content

Commit e010c90

Browse files
committed
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
1 parent 7edd837 commit e010c90

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

neutron/db/db_base_plugin_v2.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ def _get_marker_obj(self, context, resource, limit, marker):
217217
return getattr(self, '_get_%s' % resource)(context, marker)
218218
return None
219219

220+
def _filter_non_model_columns(self, data, model):
221+
"""Remove all the attributes from data which are not columns of
222+
the model passed as second parameter.
223+
"""
224+
columns = [c.name for c in model.__table__.columns]
225+
return dict((k, v) for (k, v) in
226+
data.iteritems() if k in columns)
227+
220228

221229
class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
222230
CommonDbMixin):
@@ -255,14 +263,6 @@ def register_dict_extend_funcs(cls, resource, funcs):
255263
cur_funcs.extend(funcs)
256264
cls._dict_extend_functions[resource] = cur_funcs
257265

258-
def _filter_non_model_columns(self, data, model):
259-
"""Remove all the attributes from data which are not columns of
260-
the model passed as second parameter.
261-
"""
262-
columns = [c.name for c in model.__table__.columns]
263-
return dict((k, v) for (k, v) in
264-
data.iteritems() if k in columns)
265-
266266
def _get_network(self, context, id):
267267
try:
268268
network = self._get_by_id(context, models_v2.Network, id)

0 commit comments

Comments
 (0)