flexeval.classes.jsonview#

Classes

JsonView(text_field_attr_name)

Descriptor that provides dict-like access to a JSON text field.

JsonViewDict(model_instance, ...[, ...])

Dictionary that syncs changes back to the model field.

class flexeval.classes.jsonview.JsonView(text_field_attr_name)[source]#

Bases: object

Descriptor that provides dict-like access to a JSON text field.

Example: class SomeModel(pw.Model):

some_field = pw.TextField(default=”{}”) some_field_dict = JsonView(text_field_attr_name=”some_field”)

class flexeval.classes.jsonview.JsonViewDict(model_instance, text_field_attr_name, json_dumps_fn=<function dumps>, json_loads_fn=<function loads>)[source]#

Bases: UserDict

Dictionary that syncs changes back to the model field.

clear() None.  Remove all items from D.[source]#
pop(k[, d]) v, remove specified key and return the corresponding value.[source]#

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair[source]#

as a 2-tuple; but raise KeyError if D is empty.

refresh_from_model()[source]#

If the text attribute has been mutated in the model, this method brings the view back in sync.

If you’re going to use the JsonView, avoid mutating the text attribute directly.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D[source]#
update([E, ]**F) None.  Update D from mapping/iterable E and F.[source]#

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v