[p4python] P4.fetch_client() and pickle

Tony Whitley (Hotmail) tony_whitley at hotmail.com
Fri Sep 19 04:15:07 PDT 2008


Thanks Sven Erik, that's the answer.

I'd better go and read the manual...

--
Tony Whitley
  ----- Original Message ----- 
  From: Sven Erik Knop 
  To: Tony Whitley (Hotmail) 
  Cc: 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/50930d77/attachment-0001.html>


More information about the p4python mailing list