[Grok-dev] Exclude a field from serialization

Souheil CHELFOUH trollfot at gmail.com
Wed Aug 3 14:00:06 EDT 2011


you can prefix it with _v_

2011/8/3 Hector Blanco <white.lists at gmail.com>:
> Hello everybody
>
> I have a Grok application serialized in ZoDB. I want each of the
> containers to have an instance of a Timer. Something like:
>
> class BaseManager(grok.Container):
>        def __init__(self, queriedClass):
>                super(BaseManager, self).__init__()
>                self.queriedClass = queriedClass
>                self.__myTimer = threading.Timer(60, self.timerExecute)
>
> That timer (the __poster field) doesn't need to be serialized in the
> database. It probably even can't, because when I try to create the
> application I get.
>
>
> Module ZODB.serialize:422 in serialize
>>>  return self._dump(meta, obj.__getstate__())
> Module ZODB.serialize:431 in _dump
>>>  self._p.dump(state)
> Module copy_reg:70 in _reduce_ex
>>>  raise TypeError, "can't pickle %s objects" % base.__name__
> TypeError: can't pickle instancemethod objects
>
> (looks like it's trying to serialize the self.timerExecute field)
>
> Is there any way to exclude a field from serialization? Thank you in advance.
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>


More information about the Grok-dev mailing list