[Zope3-dev] Re: Do not serialize one attribute

Rocky Burt rocky at serverzen.com
Thu Dec 14 17:30:23 EST 2006


On Thu, 2006-14-12 at 23:04 +0100, Florian Lindner wrote:
> I have a object, derived from Persistent when contain one attribute which is 
> not serializable and that's not a problem for me, but Zope complains about 
> that.
> Can I mark this attribute somehow as "not to serialize" and make Zope call a 
> member function when it has unserialized this object so I can reinstantiate 
> this attribute?

It *sounds* like you want _v_ attributes.  So you should probably do
something like this...

class MyClass(persistent.Persistent):
    @property
    def myattr(self):
        if not hasattr(self, '_v_myattr'):
            self._v_myattr = somecalculatedvalue
        return self._v_myattr

so then you can do:
myobj = MyClass()
print myobj.myattr
This will give you the content you want but you don't have to worry
about it getting persisted.

Regards,
Rocky

ps. I'm pulling over my zope2 knowledge here so if I did something a
little naive, please forgive me :)

-- 
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20061214/1145e754/attachment.bin


More information about the Zope3-dev mailing list