[Zope-CVS] CVS: Products/BTreeFolder2 - CMFBTreeFolder.py:1.1 BTreeFolder2.py:1.4 __init__.py:1.2
Shane Hathaway
shane@cvs.zope.org
Wed, 8 May 2002 15:42:06 -0400
Update of /cvs-repository/Products/BTreeFolder2
In directory cvs.zope.org:/tmp/cvs-serv22979
Modified Files:
BTreeFolder2.py __init__.py
Added Files:
CMFBTreeFolder.py
Log Message:
Added optional CMFBTreeFolder.
=== Added File Products/BTreeFolder2/CMFBTreeFolder.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
#
##############################################################################
"""CMFBTreeFolder
$Id: CMFBTreeFolder.py,v 1.1 2002/05/08 19:42:06 shane Exp $
"""
import Globals
from BTreeFolder2 import BTreeFolder2Base
from Products.CMFCore.PortalFolder import PortalFolder
import Products.CMFCore.PortalFolder
_actions = Products.CMFCore.PortalFolder.factory_type_information[0]['actions']
factory_type_information = ( { 'id' : 'CMF BTree Folder',
'meta_type' : 'CMF BTree Folder',
'description' : """\
CMF folder designed to hold a lot of objects.""",
'icon' : 'folder_icon.gif',
'product' : 'BTreeFolder2',
'factory' : 'manage_addCMFBTreeFolder',
'filter_content_types' : 0,
'immediate_view' : 'folder_edit_form',
'actions' : _actions,
},
)
def manage_addCMFBTreeFolder(dispatcher, id, title='', REQUEST=None):
"""Adds a new BTreeFolder object with id *id*.
"""
id = str(id)
ob = CMFBTreeFolder(id)
ob.title = str(title)
dispatcher._setObject(id, ob)
ob = dispatcher._getOb(id)
if REQUEST is not None:
REQUEST['RESPONSE'].redirect(ob.absolute_url() + '/manage_main' )
class CMFBTreeFolder(BTreeFolder2Base, PortalFolder):
"""BTree folder for CMF sites.
"""
meta_type = 'CMF BTree Folder'
def _checkId(self, id, allow_dup=0):
PortalFolder._checkId(self, id, allow_dup)
BTreeFolder2Base._checkId(self, id, allow_dup)
Globals.InitializeClass(CMFBTreeFolder)
=== Products/BTreeFolder2/BTreeFolder2.py 1.3 => 1.4 ===
import Globals
from Globals import DTMLFile
+from ZODB import Persistent
from Acquisition import aq_base
from BTrees.OOBTree import OOBTree
from BTrees.OIBTree import OIBTree, union
@@ -62,10 +63,9 @@
_marker = [] # Create a new marker object.
-class BTreeFolder2(Folder):
+class BTreeFolder2Base (Persistent):
+ """Base for BTree-based folders.
"""
- """
- meta_type = 'BTreeFolder2'
security = ClassSecurityInfo()
@@ -81,6 +81,7 @@
_tree = None # OOBTree: { id -> object }
_count = None # A BTrees.Length
_v_nextid = 0 # The next computed ID
+ title = ''
def __init__(self, id):
@@ -267,7 +268,6 @@
def _checkId(self, id, allow_dup=0):
- BTreeFolder2.inheritedAttribute('_checkId')(self, id, allow_dup)
if not allow_dup and self.hasObject(id):
raise BadRequestException, ('The id "%s" is invalid--'
'it is already in use.' % id)
@@ -351,4 +351,18 @@
return id
+Globals.InitializeClass(BTreeFolder2Base)
+
+
+class BTreeFolder2 (BTreeFolder2Base, Folder):
+ """BTreeFolder2 based on OFS.Folder.
+ """
+ meta_type = 'BTreeFolder2'
+
+ def _checkId(self, id, allow_dup=0):
+ Folder._checkId(self, id, allow_dup)
+ BTreeFolder2Base._checkId(self, id, allow_dup)
+
+
Globals.InitializeClass(BTreeFolder2)
+
=== Products/BTreeFolder2/__init__.py 1.1.1.1 => 1.2 ===
context.registerBaseClass(BTreeFolder2.BTreeFolder2)
+
+ try:
+ from Products.CMFCore import utils
+ except ImportError:
+ # CMF not installed
+ pass
+ else:
+ # CMF installed; make available a special folder type.
+ import CMFBTreeFolder
+ ADD_FOLDERS_PERMISSION = 'Add portal folders'
+
+ utils.ContentInit('CMF BTree Folder'
+ , content_types=( CMFBTreeFolder.CMFBTreeFolder, )
+ , permission=ADD_FOLDERS_PERMISSION
+ , extra_constructors=(
+ CMFBTreeFolder.manage_addCMFBTreeFolder, )
+ , fti=CMFBTreeFolder.factory_type_information
+ ).initialize( context )
+