Re: [dev] RFC: Transaction meta data
Jim Fulton <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <CAPDm-FhE=b5WgtoQ8QvEb3kDMN_NvEjuCabBCQx_eaGHFc=cQA@mail.gmail.com> |
On Thu, Mar 9, 2017 at 2:08 PM, David Glick (Glick Software) < [email protected]> wrote: > On 3/9/17 10:38 AM, Jim Fulton wrote: > > > > On Thu, Mar 9, 2017 at 1:02 PM, Hanno Schlichting <[email protected]> > wrote: > >> On Thu, Mar 9, 2017, at 18:58, Jim Fulton wrote: >> >> I propose to change the transaction to accept bytes for meta data. When >> getting bytes, it will: >> >> - Issue a deprecation warning, and >> >> - decode the data assuming latin-1. >> >> Any objections? >> >> >> At least in older Zope 2 releases, both None and integers are used in >> meta data as well. >> > > whimper. Well, None I'd be inclined to treat at a noop. How about if not > unicode and not bytes, the unicode/str of whatever is given. (I'm inclined > to be more loose/forgiving given that this is a deprecated feature.) > > > Here is what Zope master is doing to handle backwards-compatibility with > existing encoded transaction notes: > > def safe_unicode(value): > if isinstance(value, unicode): > return value > elif isinstance(value, basestring): > try: > value = unicode(value, 'utf-8') > except UnicodeDecodeError: > value = value.decode('utf-8', 'replace') > return value > > If transaction does something like that then we can likely use it even > with existing releases of Plone. > That works for me. Jim -- Jim Fulton http://jimfulton.info -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.