[Grok-dev] Exclude a field from serialization

Hector Blanco white.lists at gmail.com
Wed Aug 3 13:52:55 EDT 2011


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.


More information about the Grok-dev mailing list