Re: missing required positional arguments

Jim Fulton <[email protected]>
Newsgroups gmane.comp.web.zope.zodb
Message-ID <CAPDm-Fj+zi8fJ=fQAgr4=jNve8r8XU+E8MjOkHJGErPV8=C6KQ@mail.gmail.com>
On Thu, Nov 17, 2016 at 1:35 AM, Marius Gedminas <[email protected]> wrote:

> On Thu, Nov 17, 2016 at 03:28:24AM +0000, Boylan, Ross wrote:
> > I'm having trouble pulling an instance back from the database (ZEO).
> It's a revision object from hglib package.  My first try did not import
> hglib in the client; the second try did.  Both got the same error; see
> below for fuller output.
> >
> > Maybe the type in the database is defined using some kind of nested
> class I can't easily access, maybe tng.hglib.revision?
> >
> > https://selenic.com/repo/python-hglib/file/tip/hglib/client.py defines
> > class revision(tuple):
> >     def __new__(cls, rev, node, tags, branch, author, desc, date):
> >         return tuple.__new__(cls, (rev, node, tags, branch, author,
> desc, date))
>
> This class does not support pickling.


Thanks Marius.


>   Try it:
>
>    >>> import pickle
>    >>> r = revision(1, 2, 3, 4, 5, 6, 7)
>    >>> p = pickle.dumps(r)
>    >>> r2 = pickle.loads(p)
>
> The simplest way to make it pickle-compatible would be to override
> revision.__getnewargs__().
>

Another way would be to create your own class for storing revision
information and copy data from the hglib revision instances to instances of
this new class. This has the advantage of remaining decoupled from hglib.

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.