[p4python] P4.fetch_client() and pickle

Sven Erik Knop sknop at perforce.com
Fri Sep 19 04:17:50 PDT 2008

Hi Tony,

Tony Whitley (Hotmail) wrote:
> Thanks Sven Erik, that's the answer.
> I'd better go and read the manual...
Glad to hear I could help. Yes, the documentation should be helpful, but 
please let us know if there is anything unclear or could be improved.


Sven Erik
> --
> /*Tony Whitley*/
>     ----- Original Message -----
>     *From:* Sven Erik Knop <mailto:sknop at perforce.com>
>     *To:* Tony Whitley (Hotmail) <mailto:tony_whitley at hotmail.com>
>     *Cc:* p4python at perforce.com <mailto:p4python at perforce.com>
>     *Sent:* Thursday, September 18, 2008 4:01 PM
>     *Subject:* Re: [p4python] P4.fetch_client() and pickle
>     Trivial? No.
>     Interesting? Yes
>     OK, I need to do some testing to prove this, but I am pretty sure
>     the problem is that p4c.fetch_client() does not return a dict. It
>     returns an object of type P4.Spec, and this object has (purposely)
>     no constructor, so the pickler will not be happy.
>     The solution is to not pickle the Spec object, but convert the
>     Spec into a string first. You do this with
>        spec = p4.fetch_client(clientName)
>        # create a String out of the spec:
>        specString = p4.format_client(spec)
>     Now you can pickle the string. When you unpickle the object,
>     convert this back into a spec with the following command
>         specString = pickle.load(fromSomeWhere)
>         spec = p4.parse_client(specString)
>         p4.save_client(spec)
>     The reason pickle worked in the previous release of P4Python was
>     that that version did not return a Spec object but a dict instead
>     - which pickle can handle.
>     Please check if this solves your problem.
>     Cheers
>     Sven Erik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20080919/b948f9b1/attachment-0001.html>

More information about the p4python mailing list