[ovs-dev] [PATCH 3/5] python/ovs/db/idl: make SchemaHelper accept schema in json form
Ben Pfaff
blp at nicira.com
Wed Sep 12 18:52:09 UTC 2012
I agree about raising an error if both are provided.
There doesn't seem to be an issue with reading the file earlier. It
won't bother any in-tree users anyhow.
On Wed, Sep 12, 2012 at 08:41:55AM -0700, Reid Price wrote:
> Contextless phone review here also.
>
> Perhaps raise a value error if location and schema are both provided?
>
> Isaku/Ben, are there any side effects of keeping this data in memory before it is used, and removing entirely it after the 'schema =' line? Before it loaded it on demand. Isn't necessarily a problem, but definitely different behavior.
>
>
> On Sep 11, 2555 BE, at 23:17, Isaku Yamahata <yamahata at valinux.co.jp> wrote:
>
> > This is needed when using schema that was retrieved from ovsdb by get_schema
> > method.
> >
> > Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
> > ---
> > python/ovs/db/idl.py | 14 ++++++++------
> > 1 files changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
> > index c2278ba..7fed0cf 100644
> > --- a/python/ovs/db/idl.py
> > +++ b/python/ovs/db/idl.py
> > @@ -1198,13 +1198,15 @@ class SchemaHelper(object):
> > The location on disk of the schema used may be found in the
> > 'schema_location' variable."""
> >
> > - def __init__(self, location=None):
> > + def __init__(self, location=None, schema_json=None):
> > """Creates a new Schema object."""
> >
> > - if location is None:
> > - location = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR
> > + if schema_json is None:
> > + if location is None:
> > + location = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR
> > + schema_json = ovs.json.from_file(location)
> >
> > - self.schema_location = location
> > + self.schema_json = schema_json
> > self._tables = {}
> > self._all = False
> >
> > @@ -1237,8 +1239,8 @@ class SchemaHelper(object):
> > object based on columns registered using the register_columns()
> > function."""
> >
> > - schema = ovs.db.schema.DbSchema.from_json(
> > - ovs.json.from_file(self.schema_location))
> > + schema = ovs.db.schema.DbSchema.from_json(self.schema_json)
> > + self.schema_json = None
> >
> > if not self._all:
> > schema_tables = {}
> > --
> > 1.7.1.1
> >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list