On Tue, 24 Apr 2018 07:38:35 -0500
"Edward K. Ream" <edream...@gmail.com> wrote:

> It looks like json.dumps may have problems with p.v.unknownAttributes
> fields.

In theory yes, in practice not so much, although still a potential
problem.

The leo_cloud plugin stores outlines (well, subtrees, without expansion
info. etc.) in JSON.  The two issues I found were todo.py storing
datetime dates, and the tags plugin storing sets.

Python's JSON module supports converting types on write - easy to make
set a list, and I think I converted dates to YYYYMMDDTHHMMSS format.

Then you have to handle them on read - so I tweaked tags to convert to
set, and todo was already reading text dates, seeing the datetime.dates
had been a problem with different pickle versions.

So I guess in general I didn't find actual problems, but there's still
the issue that currently someone can do:

  p.v.u['pantry'] = {
    ('beans', 'aug'): 17,
    ('beans', 'jun'): 12,
    ('flour', 'jul'): 11,
    ('flour', 'aug'): 10,
  }

and that just doesn't work in JSON.

I don't think we want to go down the track of letting users register
JSON read/write helpers for certain keys in p.v.u.  *Maybe* we could
handle the case of ints/floats/tuples/(frozen sets) as keys by
converting to/from string representations.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to