I have a dict that I need to be persistent. It's not tied to content per se nor is it even specific to one Plone site. There is some functionality associated with it so I was originally going to just write a global utility. But it does need to actually save some data, and thus be persistent. I could make the utility a subclass of Products.CMFCore.utils.UniqueObject but that seems like overkill here. I don't need it to be accessible in the ZMI or traversable, I just want a dict stored in a db.
What I tried to do was something like this
class IMyUtility(Interface): _history = schema.Dict( title='History', key_type=schema.TextLine(title='code'), value_type=schema.TextLine(title='title'), ) @implementer(IMyUtility) class MyUtility(Persistent): def __init__(self): self._history = OOBTree()
and in zcml
<utility provides=".mycode.IMyUtility" factory=".mycode.MyUtility"/>
This is incomplete - self._history will always be reinitialized to a new OOBTree on start up. What am I missing to make this something actually persistent, or is this just a completely wrongheaded approach?