Several __getstate__ methods

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Güttler

    Several __getstate__ methods

    Hi!

    I use ZODB3. I want to pickle parts
    of my database and import it on a different system.

    Since, as far as I know, ZODB uses the __getstate__ method
    for pickling the objects.

    For my export, I want to ignore some parts of my objects.

    If I will change __getstate__ I am in trouble because Zope
    uses it.

    Using a global variable in __getstate__ to see if I am in
    "zope-getstate" or "my-export getstate" mode is dangerous, since
    the application is multithreaded.

    I thought about using a dict which holds the variable for each thread.

    What other solutions are possible?


    Example:

    class MyClass:
    def __init__(self, root)
    self.root=root

    I want to ignore the reference to root, since I want to import the
    object into a new root.


    thomas



Working...