[Zope3-Users] OOBtrees & ZODB
Randy Crafton
randycrafton at gmail.com
Wed Jul 9 09:39:20 EDT 2008
Folder uses an OOBTree to store it's data, so it should be ok. But if you
want to use BTreeContainer and have it work as a Site, you just have the mix
the two together in a custom container class:
from zope.app.container.interfaces import IContainer
from zope.app.component.interfaces import IPossibleSite
class IMyFolder(IContainer, IPossibleSite):
"""My Custom Container"""
from zope.app.component.site import SiteManagerContainer
from zope.app.container import btree
class MyFolder(SiteManagerContainer, btree.BTreeContainer):
zope.interface.implements(IMyFolder)
Then the following should work:
if 'AR' not in root['Application']:
root['Application']['AR']=MyFolder()
sm = LocalSiteManager(root['Application']['AR'])
root['Application']['AR'].setSiteManager(sm)
transaction.commit()
Randy
On Tue, Jul 8, 2008 at 11:10 AM, Tim Cook <timothywayne.cook at gmail.com>
wrote:
> I am building a platform where I want to initialize the ZODB (that will
> be running under Zope) with three folders with sitemanagers.
>
> If I use Folders like this:
>
> if 'AR' not in root['Application']:
> root['Application']['AR']=folder.Folder()
> sm = LocalSiteManager(root['Application']['AR'])
> root['Application']['AR'].setSiteManager(sm)
> transaction.commit()
>
> it works great and I can then add initial objects to the folders.
>
> But, these folder sill potentially contain tens of thousands of objects
> so I really want to use BTree Folders. But when I do this:
>
> from zope.app.container.btree import BTreeContainer
>
> ... <lots of other stuff>
>
> if 'AR' not in root['Application']:
> root['Application']['AR']=BTreeContainer()
> sm = LocalSiteManager(root['Application']['AR'])
> root['Application']['AR'].setSiteManager(sm)
> transaction.commit()
>
> I get this:
>
> File
> "/home/tim/projects/ref_impl_python/TRUNK/oship/src/oship/atbldr/atbldr.py",
> line 78, in ?
> root['Application']['AR'].setSiteManager(sm)
> AttributeError: 'BTreeContainer' object has no attribute
> 'setSiteManager'
>
> So BtreeContainers don't have a siteManager.
>
> I would like to OOBTree but I have been unable to even discern the
> proper way to import it.
>
> Thanks.
>
> Tim
>
>
>
>
>
> --
> Timothy Cook, MSc
> Health Informatics Research & Development Services
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> Skype ID == timothy.cook
> **************************************************************
> *You may get my Public GPG key from popular keyservers or *
> *from this link http://timothywayne.cook.googlepages.com/home*
> **************************************************************
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20080709/8335ae39/attachment.html
More information about the Zope3-users
mailing list