[zopeorg-checkins] CVS: Products/BTreeFolder - BTreeFolder.py:1.1 BTreeFolder.pyc:1.1 __init__.py:1.1 __init__.pyc:1.1 contents.dtml:1.1 folderAdd.dtml:1.1 version.txt:1.1
Sidnei da Silva
sidnei at x3ng.com.br
Fri May 30 11:17:26 EDT 2003
Update of /cvs-zopeorg/Products/BTreeFolder
In directory cvs.zope.org:/tmp/cvs-serv19195/BTreeFolder
Added Files:
BTreeFolder.py BTreeFolder.pyc __init__.py __init__.pyc
contents.dtml folderAdd.dtml version.txt
Log Message:
Adding products needed for migration of NZO
=== Added File Products/BTreeFolder/BTreeFolder.py ===
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''BTreeFolder Product
$Id: BTreeFolder.py,v 1.1 2003/05/30 15:17:25 sidnei Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
from AccessControl import getSecurityManager
from OFS.Folder import Folder
from BTree import BTree
from Globals import HTMLFile
from DocumentTemplate.DT_Util import html_quote
from urllib import quote
from cStringIO import StringIO
import Globals
manage_addBTreeFolderForm=HTMLFile('folderAdd', globals())
def manage_addBTreeFolder(self, id, title='',
type='full',
REQUEST=None):
"""Adds a new BTreeFolder object with id *id*.
"""
if type == 'full':
ob = BTreeFolder()
else:
ob = BasicBTreeFolder()
ob.id=str(id)
ob.title=title
self._setObject(id, ob)
ob=self._getOb(id)
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
def _replaceFolder(parent, id, type='basic'):
# Replaces an OFS.Folder with a BTreeFolder.
if type == 'full':
ob = BTreeFolder()
else:
ob = BasicBTreeFolder()
f = parent._getOb(id)
# Copy the contents of the folder to the new BTree folder.
ids = f.objectIds()
for key, value in f.__dict__.items():
if key not in ids:
# Not an ObjectManager item.
ob.__dict__[key] = value
for key in ids:
subob = f._getOb(key)
subob = getattr(subob, 'aq_base', subob)
ob._setOb(key, subob)
parent._setOb(id, ob)
listtext0 = '''<select name="ids:list" multiple size="%s">
'''
listtext1 = '''<option>%s</option>
'''
listtext2 = '''</select>
'''
_marker = [] # Create a new marker object.
class BasicBTreeFolder (Folder):
' '
meta_type = 'Basic BTree Folder'
__ac_permissions__=(
('View management screens', ('manage_main',
'manage_main_listing',
'manage_object_workspace',)),
)
manage_options=(
({'label':'Contents', 'action':'manage_main',},
) + Folder.manage_options[1:]
)
manage_main = HTMLFile('contents', globals())
def __init__(self):
self._tree = BTree()
def _getOb(self, id, default=_marker):
tree = self._tree
if not tree.has_key(id):
if default is _marker:
raise AttributeError, id
return default
else:
return tree[id].__of__(self)
def _setOb(self, id, object):
# Saves the object in the BTree instead of the dictionary.
tree = self._tree
tree[id] = object
# May add logic here to make BTreeFolder work as expected with
# transparent folders.
def _delOb(self, id):
# May add logic here to make BTreeFolder work as expected with
# transparent folders.
tree = self._tree
del tree[id]
def manage_main_listing(self, REQUEST):
'''Generates a select box.'''
if REQUEST.has_key('dtpref_rows'):
pref_rows = REQUEST['dtpref_rows']
else:
pref_rows = 20
rval = StringIO()
rval.write(listtext0 % pref_rows)
counter = 0
idlist = self.objectIds()
idlist.sort()
for id in idlist:
html_fmt = html_quote(id)
rval.write(listtext1 % html_fmt)
counter = counter + 1
rval.write(listtext2)
return rval.getvalue()
def manage_object_workspace(self, REQUEST):
'''Redirects to the workspace of the first object in
the list.'''
ids = REQUEST.get('ids', [])
if len(ids) > 0:
REQUEST.RESPONSE.redirect(
'%s/%s/manage_workspace' % (
self.absolute_url(), quote(ids[0])))
else:
return self.manage_main(self, REQUEST)
Globals.default__class_init__(BasicBTreeFolder)
class BTreeFolder (BasicBTreeFolder):
' '
meta_type = 'BTree Folder'
def __getattr__(self, name):
# Finds the attribute in the BTree instead of the dictionary.
tree = self._tree
if tree.has_key(name):
ob = tree[name]
return ob
else:
return higher_getattr(self, name)
try:
higher_getattr = BTreeFolder.inheritedAttribute('__getattr__')
except:
def higher_getattr(self, name):
raise AttributeError, name
Globals.default__class_init__(BTreeFolder)
=== Added File Products/BTreeFolder/BTreeFolder.pyc ===
<Binary-ish file>
=== Added File Products/BTreeFolder/__init__.py ===
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''BTreeFolder Product Initialization
$Id: __init__.py,v 1.1 2003/05/30 15:17:25 sidnei Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
import BTreeFolder
def initialize(context):
context.registerClass(
BTreeFolder.BTreeFolder,
constructors=(BTreeFolder.manage_addBTreeFolderForm,
BTreeFolder.manage_addBTreeFolder),
)
#context.registerHelp()
#context.registerHelpTitle('Zope Help')
#context.registerBaseClass(BTreeFolder.BTreeFolder)
=== Added File Products/BTreeFolder/__init__.pyc ===
*ë
³s>c s9 U d Z W d d d !Z Y d k Z [ d Z d S( s] BTreeFolder Product Initialization
$Id: __init__.pyc,v 1.1 2003/05/30 15:17:25 sidnei Exp $s $Revision: 1.1 $i i Nc s/ [ ] | i t i _ d t i t i f d S( Ns constructors( s contexts
registerClasss BTreeFolders manage_addBTreeFolderForms manage_addBTreeFolder( s context( ( s9 /slab/alpha/var/Instance/Products/BTreeFolder/__init__.pys
initialize[ s ( s __doc__s __version__s BTreeFolders
initialize( s BTreeFolders __version__s __doc__s
initialize( ( s9 /slab/alpha/var/Instance/Products/BTreeFolder/__init__.pys ?U s
=== Added File Products/BTreeFolder/contents.dtml ===
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML lang="en">
<HEAD>
<TITLE>Contents</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<dtml-var manage_tabs>
<P>
<FORM ACTION="<dtml-var URL1>" METHOD="POST">
<dtml-if objectIds>
<p><em>Item count: <dtml-var "_.len(objectIds)"></em></p>
<dtml-var expr="manage_main_listing(REQUEST)">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING=2>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="16"></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="SUBMIT" NAME="manage_object_workspace:method" VALUE="Edit">
<dtml-unless dontAllowCopyAndPaste>
<INPUT TYPE="SUBMIT" NAME="manage_renameForm:method" VALUE="Rename">
<INPUT TYPE="SUBMIT" NAME="manage_cutObjects:method" VALUE="Cut">
<INPUT TYPE="SUBMIT" NAME="manage_copyObjects:method" VALUE="Copy">
<dtml-if cb_dataValid>
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
</dtml-if>
</dtml-unless>
<dtml-if "_.SecurityCheckPermission('Delete objects',this())">
<INPUT TYPE="SUBMIT" NAME="manage_delObjects:method" VALUE="Delete">
</dtml-if>
<dtml-if "_.SecurityCheckPermission('Import/Export objects', this())">
<INPUT TYPE="SUBMIT" NAME="manage_importExportForm:method" VALUE="Export...">
</dtml-if>
</TD>
</TR>
</TABLE>
<dtml-else>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR>
<TD>
There are currently no items in <EM><dtml-var title_or_id></EM>
<P>
<dtml-unless dontAllowCopyAndPaste>
<dtml-if cb_dataValid>
<INPUT TYPE="SUBMIT" NAME="manage_pasteObjects:method" VALUE="Paste">
</dtml-if>
</dtml-unless>
</TD>
</TABLE>
</dtml-if>
</FORM>
<dtml-if filtered_meta_types>
<dtml-if "_.len(filtered_meta_types) > 1">
<TABLE ALIGN="LEFT">
<TR>
<TD VALIGN="MIDDLE">
To add a new item, select an item type
<NOSCRIPT>and click "Add"</NOSCRIPT>.
</TD>
</TR>
<TR>
<TD VALIGN="MIDDLE">
<FORM ACTION="<dtml-var URL1>/" METHOD="GET">
<SELECT NAME=":method" ONCHANGE="location.href='<dtml-var URL1
>/'+this.options[this.selectedIndex].value">
<OPTION value="manage_workspace" DISABLED>Available Objects
<dtml-in filtered_meta_types mapping sort=name>
<OPTION value="<dtml-var action fmt="url-quote">"><dtml-var name>
</dtml-in>
</SELECT>
<INPUT TYPE="SUBMIT" VALUE=" Add ">
</FORM>
</TD>
</TR>
</TABLE>
<dtml-else>
<FORM ACTION="<dtml-var URL1>/" METHOD="GET">
To add a new item click "Add".
<dtml-in filtered_meta_types mapping sort=name>
<input type=hidden name=":method" value="<dtml-var action fmt="url-quote">">
<INPUT TYPE="SUBMIT" VALUE=" Add ">
</dtml-in>
</FORM>
</dtml-if>
</dtml-if>
<dtml-if update_menu>
<SCRIPT LANGUAGE="javascript">
<!--
window.parent.update_menu();
//-->
</SCRIPT>
</dtml-if>
</BODY>
</HTML>
=== Added File Products/BTreeFolder/folderAdd.dtml ===
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML lang="en">
<HEAD>
<TITLE>Add BTreeFolder</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<H2>Add BTreeFolder</H2>
<dtml-var "HelpSys.HelpButton('Folder_Add.stx','OFSP')">
<P>
A Folder contains other objects. Use Folders to organize your
web objects in to logical groups.
</P>
<p>
A BTree folder may be able to handle a larger number
of objects than a standard folder because it does not need to
activate other subobjects in order to access a single subobject.
</p>
<P>
The form below allows you to create
a BTreeFolder. The <EM>Create public interface</EM> option creates
an <EM>index_html</EM> DTML Method inside the Folder to give the
Folder a default HTML representation. The <EM>Create user folder</EM>
option creates a User Folder inside the Folder to hold authorization
information for the Folder.
</P>
<FORM ACTION="manage_addBTreeFolder" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="id" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40">
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Type</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="radio" NAME="type" VALUE="basic">
Basic (does not implement <code>__getattr__</code>)
<br>
<INPUT TYPE="radio" NAME="type" VALUE="full" CHECKED="checked">
Full (implements <code>__getattr__</code> -- safer but slower)
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<BR><INPUT TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
=== Added File Products/BTreeFolder/version.txt ===
BTreeFolder-0.1.2
More information about the zopeorg-checkins
mailing list