############################################################################## # # Copyright (c) 2005-2006 Brian Sutherland. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Containers for sqlobjects. Mostly this is just customizing the sqlos.container containers to work with Z2. """ from OFS.SimpleItem import SimpleItem from sqlos.container import SQLObjectContainer, SQLIsolatedContainer from Products.FiveSQLOS.interfaces import IFiveSQLObject class FiveSQLObjectContainer(SQLObjectContainer, SimpleItem): """Zope2 made me do it.""" def __init__(self, id, title): self.id = id self.title = title def items(self): items = SQLObjectContainer.items(self) for i in items: # XXX do we really need __of__? yield (i[0], IFiveSQLObject(i[1]).__of__(self)) def __getitem__(self, name): item = SQLObjectContainer.__getitem__(self, name) # XXX do we really need __of__? return IFiveSQLObject(item).__of__(self) class FiveSQLIsolatedContainer(SQLIsolatedContainer, SimpleItem): """Zope2 made me do it.""" def __init__(self, id, title): self.id = id self.title = title def items(self): items = SQLIsolatedContainer.items(self) for i in items: # XXX do we really need __of__? yield (i[0], IFiveSQLObject(i[1]).__of__(self)) def __getitem__(self, name): item = SQLIsolatedContainer.__getitem__(self, name) # XXX do we really need __of__? return IFiveSQLObject(item).__of__(self)