Commit bdb3057e authored by Martijn Pieters's avatar Martijn Pieters

Clean up indentation and trailing whitespace.

parent f90d18e7
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Global definitions""" """Global definitions"""
__version__='$Revision: 1.52 $'[11:-2] __version__='$Revision: 1.53 $'[11:-2]
# Global constants: __replaceable__ flags: # Global constants: __replaceable__ flags:
NOT_REPLACEABLE = 0 NOT_REPLACEABLE = 0
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Image object that is stored in a file""" """Image object that is stored in a file"""
__version__='$Revision: 1.12 $'[11:-2] __version__='$Revision: 1.13 $'[11:-2]
############################################################ ############################################################
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
# We've renamed this module to zLOG. This one will dissappear soon. # We've renamed this module to zLOG. This one will dissappear soon.
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Provide a Main application for the Zope framework """Provide a Main application for the Zope framework
...@@ -40,11 +40,11 @@ OFS.Application.import_products() ...@@ -40,11 +40,11 @@ OFS.Application.import_products()
revision=read_only=None revision=read_only=None
if os.environ.has_key('ZOPE_READ_ONLY'): if os.environ.has_key('ZOPE_READ_ONLY'):
read_only=1 read_only=1
try: try:
from DateTime import DateTime from DateTime import DateTime
revision=DateTime(os.environ['ZOPE_READ_ONLY']).timeTime() revision=DateTime(os.environ['ZOPE_READ_ONLY']).timeTime()
except: pass except: pass
Bobobase=Globals.Bobobase=BoboPOS.PickleDictionary( Bobobase=Globals.Bobobase=BoboPOS.PickleDictionary(
Globals.BobobaseName, read_only=read_only, revision=revision) Globals.BobobaseName, read_only=read_only, revision=revision)
Globals.opened.append(Bobobase) Globals.opened.append(Bobobase)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""External Method Product """External Method Product
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
This product provides support for external methods, which allow This product provides support for external methods, which allow
domain-specific customization of web environments. domain-specific customization of web environments.
""" """
__version__='$Revision: 1.50 $'[11:-2] __version__='$Revision: 1.51 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition import OFS.SimpleItem, Acquisition
import AccessControl.Role, sys, os, stat, traceback import AccessControl.Role, sys, os, stat, traceback
...@@ -30,7 +30,7 @@ manage_addExternalMethodForm=DTMLFile('dtml/methodAdd', globals()) ...@@ -30,7 +30,7 @@ manage_addExternalMethodForm=DTMLFile('dtml/methodAdd', globals())
def manage_addExternalMethod(self, id, title, module, function, REQUEST=None): def manage_addExternalMethod(self, id, title, module, function, REQUEST=None):
"""Add an external method to a folder """Add an external method to a folder
Un addition to the standard object-creation arguments, Un addition to the standard object-creation arguments,
'id' and title, the following arguments are defined: 'id' and title, the following arguments are defined:
...@@ -55,7 +55,7 @@ def manage_addExternalMethod(self, id, title, module, function, REQUEST=None): ...@@ -55,7 +55,7 @@ def manage_addExternalMethod(self, id, title, module, function, REQUEST=None):
title=str(title) title=str(title)
module=str(module) module=str(module)
function=str(function) function=str(function)
i=ExternalMethod(id,title,module,function) i=ExternalMethod(id,title,module,function)
self._setObject(id,i) self._setObject(id,i)
if REQUEST is not None: if REQUEST is not None:
...@@ -124,7 +124,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -124,7 +124,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
title=str(title) title=str(title)
module=str(module) module=str(module)
function=str(function) function=str(function)
self.title=title self.title=title
if module[-3:]=='.py': module=module[:-3] if module[-3:]=='.py': module=module[:-3]
elif module[-4:]=='.pyc': module=module[:-4] elif module[-4:]=='.pyc': module=module[:-4]
...@@ -143,7 +143,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -143,7 +143,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
self._v_func_defaults = ff.func_defaults self._v_func_defaults = ff.func_defaults
self._v_func_code = FuncCode(ff,f is not ff) self._v_func_code = FuncCode(ff,f is not ff)
self._v_f=f self._v_f=f
return f return f
...@@ -151,13 +151,13 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -151,13 +151,13 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
def reloadIfChanged(self): def reloadIfChanged(self):
# If the file has been modified since last loaded, force a reload. # If the file has been modified since last loaded, force a reload.
ts=os.stat(self.filepath())[stat.ST_MTIME] ts=os.stat(self.filepath())[stat.ST_MTIME]
if (not hasattr(self, '_v_last_read') or if (not hasattr(self, '_v_last_read') or
(ts != self._v_last_read)): (ts != self._v_last_read)):
self._v_f=self.getFunction(1) self._v_f=self.getFunction(1)
self._v_last_read=ts self._v_last_read=ts
if DevelopmentMode: if DevelopmentMode:
# In development mode we do an automatic reload # In development mode we do an automatic reload
# if the module code changed # if the module code changed
def getFuncDefaults(self): def getFuncDefaults(self):
self.reloadIfChanged() self.reloadIfChanged()
...@@ -210,7 +210,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -210,7 +210,7 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
raise RuntimeError,\ raise RuntimeError,\
"external method could not be called " \ "external method could not be called " \
"because the file does not exist" "because the file does not exist"
if DevelopmentMode: if DevelopmentMode:
self.reloadIfChanged() self.reloadIfChanged()
...@@ -229,10 +229,10 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit, ...@@ -229,10 +229,10 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
len(self._v_func_defaults or ()) - 1 == len(args)) len(self._v_func_defaults or ()) - 1 == len(args))
and self._v_func_code.co_varnames[0]=='self'): and self._v_func_code.co_varnames[0]=='self'):
return apply(f,(self.aq_parent.this(),)+args,kw) return apply(f,(self.aq_parent.this(),)+args,kw)
raise TypeError, v, tb raise TypeError, v, tb
finally: tb=None finally: tb=None
def function(self): return self._function def function(self): return self._function
def module(self): return self._module def module(self): return self._module
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''External Method Product Initialization __doc__='''External Method Product Initialization
$Id: __init__.py,v 1.14 2001/11/28 15:50:59 matt Exp $''' $Id: __init__.py,v 1.15 2002/08/14 22:14:10 mj Exp $'''
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
import ExternalMethod import ExternalMethod
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -17,7 +17,7 @@ def manage_addExternalMethod(id, title, module, function): ...@@ -17,7 +17,7 @@ def manage_addExternalMethod(id, title, module, function):
""" """
Add an external method to an Add an external method to an
'ObjectManager'. 'ObjectManager'.
In addition to the standard object-creation arguments, In addition to the standard object-creation arguments,
'id' and title, the following arguments are defined: 'id' and title, the following arguments are defined:
...@@ -98,5 +98,3 @@ class ExternalMethod: ...@@ -98,5 +98,3 @@ class ExternalMethod:
first argument. first argument.
""" """
from math import sqrt from math import sqrt
def testf(arg1, sqrt = sqrt): def testf(arg1, sqrt = sqrt):
return sqrt(arg1) return sqrt(arg1)
...@@ -2,17 +2,16 @@ ...@@ -2,17 +2,16 @@
# #
# Copyright (c) 2001, 2002 Zope Corporation and Contributors. # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved. # All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
""" """
$Id: __init__.py,v 1.3 2002/04/23 13:04:20 jim Exp $ $Id: __init__.py,v 1.4 2002/08/14 22:14:11 mj Exp $
""" """
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
# #
# Copyright (c) 2001, 2002 Zope Corporation and Contributors. # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved. # All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
""" """
Revision information: Revision information:
$Id: testExternalMethod.py,v 1.4 2002/04/24 00:20:15 jim Exp $ $Id: testExternalMethod.py,v 1.5 2002/08/14 22:14:11 mj Exp $
""" """
import math, os import math, os
...@@ -49,15 +49,15 @@ class Test(TestCase): ...@@ -49,15 +49,15 @@ class Test(TestCase):
def test_mapply(self): def test_mapply(self):
from ZPublisher.mapply import mapply from ZPublisher.mapply import mapply
em1 = ExternalMethod('em', 'test method', 'Test', 'testf') em1 = ExternalMethod('em', 'test method', 'Test', 'testf')
self.assertEqual(mapply(em1, (), {'arg1': 4}), math.sqrt(4)) self.assertEqual(mapply(em1, (), {'arg1': 4}), math.sqrt(4))
state = em1.__getstate__() state = em1.__getstate__()
em2 = ExternalMethod.__basicnew__() em2 = ExternalMethod.__basicnew__()
em2.__setstate__(state) em2.__setstate__(state)
self.assertEqual(mapply(em1, (), {'arg1': 9}), math.sqrt(9)) self.assertEqual(mapply(em1, (), {'arg1': 9}), math.sqrt(9))
def test_suite(): def test_suite():
return TestSuite(( return TestSuite((
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__rcs_id__='$Id: MIMETag.py,v 1.9 2002/03/11 15:54:38 andreasjung Exp $' __rcs_id__='$Id: MIMETag.py,v 1.10 2002/08/14 22:14:27 mj Exp $'
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
from DocumentTemplate.DT_Util import * from DocumentTemplate.DT_Util import *
from DocumentTemplate.DT_String import String from DocumentTemplate.DT_String import String
...@@ -56,7 +56,7 @@ class MIMETag: ...@@ -56,7 +56,7 @@ class MIMETag:
has_key=args.has_key has_key=args.has_key
if has_key('type'): if has_key('type'):
type = args['type'] type = args['type']
else: else:
type = 'application/octet-stream' type = 'application/octet-stream'
...@@ -120,7 +120,7 @@ class MIMETag: ...@@ -120,7 +120,7 @@ class MIMETag:
if has_key('skip_expr') and a['skip_expr'].eval(md): if has_key('skip_expr') and a['skip_expr'].eval(md):
continue continue
inner = mw.nextpart() inner = mw.nextpart()
if has_key('type_expr'): t=a['type_expr'].eval(md) if has_key('type_expr'): t=a['type_expr'].eval(md)
...@@ -134,7 +134,7 @@ class MIMETag: ...@@ -134,7 +134,7 @@ class MIMETag:
if has_key('name_expr'): n=a['name_expr'].eval(md) if has_key('name_expr'): n=a['name_expr'].eval(md)
else: n=a['name'] else: n=a['name']
if has_key('filename_expr'): f=a['filename_expr'].eval(md) if has_key('filename_expr'): f=a['filename_expr'].eval(md)
else: f=a['filename'] else: f=a['filename']
...@@ -175,8 +175,3 @@ class MIMETag: ...@@ -175,8 +175,3 @@ class MIMETag:
String.commands['mime'] = MIMETag String.commands['mime'] = MIMETag
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''MIMETools Product Initialization __doc__='''MIMETools Product Initialization
$Id: __init__.py,v 1.2 2001/11/28 15:50:59 matt Exp $''' $Id: __init__.py,v 1.3 2002/08/14 22:14:27 mj Exp $'''
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
import MIMETag import MIMETag
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""SMTP mail objects """SMTP mail objects
$Id: MailHost.py,v 1.73 2002/08/12 21:50:31 jens Exp $""" $Id: MailHost.py,v 1.74 2002/08/14 22:14:51 mj Exp $"""
__version__ = "$Revision: 1.73 $"[11:-2] __version__ = "$Revision: 1.74 $"[11:-2]
from Globals import Persistent, DTMLFile, InitializeClass from Globals import Persistent, DTMLFile, InitializeClass
from smtplib import SMTP from smtplib import SMTP
...@@ -54,7 +54,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -54,7 +54,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
manage_options=( manage_options=(
( (
{'icon':'', 'label':'Edit', {'icon':'', 'label':'Edit',
'action':'manage_main', 'action':'manage_main',
'help':('MailHost','Mail-Host_Edit.stx')}, 'help':('MailHost','Mail-Host_Edit.stx')},
) )
+RoleManager.manage_options +RoleManager.manage_options
...@@ -93,10 +93,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -93,10 +93,10 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
, REQUEST , REQUEST
, manage_tabs_message=msg , manage_tabs_message=msg
) )
security.declareProtected( use_mailhost_services, 'sendTemplate' ) security.declareProtected( use_mailhost_services, 'sendTemplate' )
def sendTemplate(trueself, self, messageTemplate, def sendTemplate(trueself, self, messageTemplate,
statusTemplate=None, mto=None, mfrom=None, statusTemplate=None, mto=None, mfrom=None,
encode=None, REQUEST=None): encode=None, REQUEST=None):
'render a mail template, then send it...' 'render a mail template, then send it...'
...@@ -124,7 +124,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -124,7 +124,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
self._send(mfrom, mto, messageText) self._send(mfrom, mto, messageText)
# This is here for backwards compatibility only. Possibly it could # This is here for backwards compatibility only. Possibly it could
# be used to send messages at a scheduled future time, or via a mail queue? # be used to send messages at a scheduled future time, or via a mail queue?
security.declareProtected( use_mailhost_services, 'scheduledSend' ) security.declareProtected( use_mailhost_services, 'scheduledSend' )
scheduledSend = send scheduledSend = send
...@@ -144,7 +144,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -144,7 +144,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
smtpserver.sendmail( mfrom, mto, messageText ) smtpserver.sendmail( mfrom, mto, messageText )
smtpserver.quit() smtpserver.quit()
InitializeClass( MailBase ) InitializeClass( MailBase )
class MailHost(Persistent, MailBase): class MailHost(Persistent, MailBase):
...@@ -155,7 +155,7 @@ def _encode(body, encode=None): ...@@ -155,7 +155,7 @@ def _encode(body, encode=None):
return body return body
mfile=StringIO(body) mfile=StringIO(body)
mo=mimetools.Message(mfile) mo=mimetools.Message(mfile)
if mo.getencoding() != '7bit': if mo.getencoding() != '7bit':
raise MailHostError, 'Message already encoded' raise MailHostError, 'Message already encoded'
newmfile=StringIO() newmfile=StringIO()
newmfile.write(''.join(mo.headers)) newmfile.write(''.join(mo.headers))
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__rcs_id__='$Id: SendMailTag.py,v 1.16 2002/03/11 15:54:38 andreasjung Exp $' __rcs_id__='$Id: SendMailTag.py,v 1.17 2002/08/14 22:14:51 mj Exp $'
__version__='$Revision: 1.16 $'[11:-2] __version__='$Revision: 1.17 $'[11:-2]
from MailHost import MailBase from MailHost import MailBase
from DocumentTemplate.DT_Util import parse_params,render_blocks from DocumentTemplate.DT_Util import parse_params,render_blocks
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''MailHost Product Initialization __doc__='''MailHost Product Initialization
$Id: __init__.py,v 1.21 2001/11/28 15:50:59 matt Exp $''' $Id: __init__.py,v 1.22 2002/08/14 22:14:51 mj Exp $'''
__version__='$Revision: 1.21 $'[11:-2] __version__='$Revision: 1.22 $'[11:-2]
import MailHost import MailHost
import SendMailTag import SendMailTag
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
def manage_addMailHost(id, title='', smtp_host=None, def manage_addMailHost(id, title='', smtp_host=None,
...@@ -31,15 +31,15 @@ class MailHost: ...@@ -31,15 +31,15 @@ class MailHost:
""" """
__constructor__=manage_addMailHost __constructor__=manage_addMailHost
def send(messageText, mto=None, mfrom=None, subject=None, def send(messageText, mto=None, mfrom=None, subject=None,
encode=None): encode=None):
""" """
Sends an email message. Sends an email message.
The arguments are: The arguments are:
messageText -- The mail message. It can either be a rfc822 messageText -- The mail message. It can either be a rfc822
formed text with header fields, or just a body without any formed text with header fields, or just a body without any
header fields. The other arguments given will override the header fields. The other arguments given will override the
header fields in the message, if they exist. header fields in the message, if they exist.
...@@ -54,6 +54,3 @@ class MailHost: ...@@ -54,6 +54,3 @@ class MailHost:
are 'base64', 'quoted-printable' and 'uuencode'. are 'base64', 'quoted-printable' and 'uuencode'.
""" """
...@@ -5,7 +5,7 @@ import ZODB, Acquisition ...@@ -5,7 +5,7 @@ import ZODB, Acquisition
from Products.MailHost.MailHost import MailHostError, _mungeHeaders from Products.MailHost.MailHost import MailHostError, _mungeHeaders
class TestMailHost( unittest.TestCase ): class TestMailHost( unittest.TestCase ):
def testAllHeaders( self ): def testAllHeaders( self ):
msg = """To: recipient@domain.com msg = """To: recipient@domain.com
From: sender@domain.com From: sender@domain.com
...@@ -57,4 +57,3 @@ def main(): ...@@ -57,4 +57,3 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Globals, AccessControl.User import Globals, AccessControl.User
from Globals import Persistent from Globals import Persistent
...@@ -43,7 +43,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -43,7 +43,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
self._version="%s/%s" % (version, id) self._version="%s/%s" % (version, id)
self.users__draft__=uf=AccessControl.User.UserFolder() self.users__draft__=uf=AccessControl.User.UserFolder()
self.__allow_groups__=uf self.__allow_groups__=uf
def icon(self): def icon(self):
try: return getattr(self.aq_parent.aq_base,self._refid).icon try: return getattr(self.aq_parent.aq_base,self._refid).icon
except: return 'p_/broken' except: return 'p_/broken'
...@@ -75,7 +75,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -75,7 +75,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
def __bobo_traverse__(self, REQUEST, name): def __bobo_traverse__(self, REQUEST, name):
if name[-9:]=='__draft__': return getattr(self, name) if name[-9:]=='__draft__': return getattr(self, name)
try: db=self._p_jar.db() try: db=self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
...@@ -86,15 +86,15 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -86,15 +86,15 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
cleanup=Cleanup() cleanup=Cleanup()
cleanup.__del__=jar.close cleanup.__del__=jar.close
REQUEST[Cleanup]=cleanup REQUEST[Cleanup]=cleanup
dself=getdraft(self, jar) dself=getdraft(self, jar)
ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself) ref=getattr(dself.aq_parent.aq_base,dself._refid).aq_base.__of__(dself)
if hasattr(ref, name): return dself, ref, getattr(ref, name) if hasattr(ref, name): return dself, ref, getattr(ref, name)
return getattr(self, name) return getattr(self, name)
def nonempty(self): def nonempty(self):
try: db=self._p_jar.db() try: db=self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
...@@ -117,7 +117,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -117,7 +117,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
d=self._p_jar.getVersion() d=self._p_jar.getVersion()
if d==s: d='' if d==s: d=''
db.commitVersion(s, d) db.commitVersion(s, d)
if REQUEST: if REQUEST:
REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
...@@ -141,7 +141,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -141,7 +141,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
if not self._version: if not self._version:
self._version=self.absolute_url(1) self._version=self.absolute_url(1)
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
if self.nonempty(): if self.nonempty():
raise 'Version Error', ( raise 'Version Error', (
'Attempt to %sdelete a non-empty version.<p>' 'Attempt to %sdelete a non-empty version.<p>'
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Backward compatability! """Backward compatability!
""" """
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Version object""" """Version object"""
__version__='$Revision: 1.52 $'[11:-2] __version__='$Revision: 1.53 $'[11:-2]
import Globals, time import Globals, time
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
...@@ -79,12 +79,12 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -79,12 +79,12 @@ class Version(Persistent,Implicit,RoleManager,Item):
r=Version.inheritedAttribute('title_and_id')(self) r=Version.inheritedAttribute('title_and_id')(self)
try: db=self._p_jar.db() try: db=self._p_jar.db()
except: except:
# BoboPOS 2 # BoboPOS 2
if Globals.VersionBase[self.cookie].nonempty(): return '%s *' % r if Globals.VersionBase[self.cookie].nonempty(): return '%s *' % r
else: else:
# ZODB 3 # ZODB 3
if not db.versionEmpty(self.cookie): return '%s *' % r if not db.versionEmpty(self.cookie): return '%s *' % r
return r return r
def manage_edit(self, title, REQUEST=None): def manage_edit(self, title, REQUEST=None):
...@@ -111,7 +111,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -111,7 +111,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
% self.id) % self.id)
) )
return RESPONSE.redirect(REQUEST['URL1']+'/manage_main') return RESPONSE.redirect(REQUEST['URL1']+'/manage_main')
def leave(self, REQUEST, RESPONSE): def leave(self, REQUEST, RESPONSE):
"""Temporarily stop working in a version""" """Temporarily stop working in a version"""
RESPONSE.setCookie( RESPONSE.setCookie(
...@@ -129,7 +129,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -129,7 +129,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
% self.id) % self.id)
) )
return RESPONSE.redirect(REQUEST['URL1']+'/manage_main') return RESPONSE.redirect(REQUEST['URL1']+'/manage_main')
def leave_another(self, REQUEST, RESPONSE): def leave_another(self, REQUEST, RESPONSE):
"""Leave a version that may not be the current version""" """Leave a version that may not be the current version"""
return self.leave(REQUEST, RESPONSE) return self.leave(REQUEST, RESPONSE)
...@@ -150,7 +150,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -150,7 +150,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
if REQUEST is not None: if REQUEST is not None:
REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main')
def discard(self, remark='', REQUEST=None): def discard(self, remark='', REQUEST=None):
'Discard changes made during the version' 'Discard changes made during the version'
try: db=self._p_jar.db() try: db=self._p_jar.db()
...@@ -164,7 +164,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -164,7 +164,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
if REQUEST is not None: if REQUEST is not None:
REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main') REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main')
def nonempty(self): def nonempty(self):
try: db=self._p_jar.db() try: db=self._p_jar.db()
except: except:
...@@ -175,7 +175,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -175,7 +175,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
return not db.versionEmpty(self.cookie) return not db.versionEmpty(self.cookie)
# Prevent copy/move/rename of versions. It's better that way, really. # Prevent copy/move/rename of versions. It's better that way, really.
def _canCopy(self, op=0): def _canCopy(self, op=0):
return 0 return 0
...@@ -187,18 +187,18 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -187,18 +187,18 @@ class Version(Persistent,Implicit,RoleManager,Item):
# Physical path # Physical path
self.cookie='/'.join(self.getPhysicalPath()) self.cookie='/'.join(self.getPhysicalPath())
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
if self.nonempty(): if self.nonempty():
raise VersionException( raise VersionException(
'Attempt to %sdelete a non-empty version.<br />' % 'Attempt to %sdelete a non-empty version.<br />' %
((self is not item) and 'indirectly ' or '')) ((self is not item) and 'indirectly ' or ''))
try: REQUEST=self.REQUEST try: REQUEST=self.REQUEST
except: pass except: pass
else: else:
v=self.cookie v=self.cookie
if REQUEST.get(Globals.VersionNameName, '') == v: if REQUEST.get(Globals.VersionNameName, '') == v:
raise VersionException( raise VersionException(
'An attempt was made to delete a version, %s, or an\n' 'An attempt was made to delete a version, %s, or an\n'
'object containing %s while\n working in the\n' 'object containing %s while\n working in the\n'
'version %s. This would lead to a &quot;version\n' 'version %s. This would lead to a &quot;version\n'
...@@ -208,4 +208,3 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -208,4 +208,3 @@ class Version(Persistent,Implicit,RoleManager,Item):
'version, because the version would no longer\n' 'version, because the version would no longer\n'
'be accessable.<p>\n' 'be accessable.<p>\n'
% (v,v,v)) % (v,v,v))
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''Object system core __doc__='''Object system core
$Id: __init__.py,v 1.36 2001/11/28 15:51:00 matt Exp $''' $Id: __init__.py,v 1.37 2002/08/14 22:16:04 mj Exp $'''
__version__='$Revision: 1.36 $'[11:-2] __version__='$Revision: 1.37 $'[11:-2]
import Version, OFS.Image, OFS.Folder, AccessControl.User import Version, OFS.Image, OFS.Folder, AccessControl.User
import OFS.DTMLMethod, OFS.DTMLDocument, OFS.PropertySheets import OFS.DTMLMethod, OFS.DTMLDocument, OFS.PropertySheets
...@@ -80,7 +80,7 @@ def initialize(context): ...@@ -80,7 +80,7 @@ def initialize(context):
icon='images/File_icon.gif', icon='images/File_icon.gif',
legacy=(OFS.Image.manage_addFile,), legacy=(OFS.Image.manage_addFile,),
) )
context.registerClass( context.registerClass(
OFS.Folder.Folder, OFS.Folder.Folder,
constructors=(OFS.Folder.manage_addFolderForm, constructors=(OFS.Folder.manage_addFolderForm,
...@@ -88,7 +88,7 @@ def initialize(context): ...@@ -88,7 +88,7 @@ def initialize(context):
icon='images/Folder_icon.gif', icon='images/Folder_icon.gif',
legacy=(OFS.Folder.manage_addFolder,), legacy=(OFS.Folder.manage_addFolder,),
) )
context.registerClass( context.registerClass(
AccessControl.User.UserFolder, AccessControl.User.UserFolder,
......
...@@ -23,17 +23,17 @@ class SecurityManager: ...@@ -23,17 +23,17 @@ class SecurityManager:
Validate access. Validate access.
Arguments: Arguments:
accessed -- the object that was being accessed accessed -- the object that was being accessed
container -- the object the value was found in container -- the object the value was found in
name -- The name used to access the value name -- The name used to access the value
value -- The value retrieved though the access. value -- The value retrieved though the access.
roles -- The roles of the object if already known. roles -- The roles of the object if already known.
The arguments may be provided as keyword arguments. Some of The arguments may be provided as keyword arguments. Some of
these arguments may be omitted, however, the policy may these arguments may be omitted, however, the policy may
reject access in some cases when arguments are omitted. It reject access in some cases when arguments are omitted. It
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
class AuthenticatedUser: class AuthenticatedUser:
...@@ -65,7 +65,6 @@ class AuthenticatedUser: ...@@ -65,7 +65,6 @@ class AuthenticatedUser:
def getDomains(): def getDomains():
""" """
Return the list of domain restrictions for a user. Return the list of domain restrictions for a user.
Permission -- Always available Permission -- Always available
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -23,12 +23,12 @@ class DTMLDocument: ...@@ -23,12 +23,12 @@ class DTMLDocument:
A DTML Document is a Zope object that contains and executes DTML A DTML Document is a Zope object that contains and executes DTML
code. It is useful to represent web pages. code. It is useful to represent web pages.
""" """
__extends__=( __extends__=(
'OFSP.ObjectManagerItem.ObjectManagerItem', 'OFSP.ObjectManagerItem.ObjectManagerItem',
'OFSP.PropertyManager.PropertyManager', 'OFSP.PropertyManager.PropertyManager',
) )
def __call__(client=None, REQUEST={}, RESPONSE=None, **kw): def __call__(client=None, REQUEST={}, RESPONSE=None, **kw):
""" """
...@@ -101,7 +101,7 @@ class DTMLDocument: ...@@ -101,7 +101,7 @@ class DTMLDocument:
When the URL of a DTML Document is fetched from Zope, the When the URL of a DTML Document is fetched from Zope, the
DTML Document is called by the publisher. The REQUEST DTML Document is called by the publisher. The REQUEST
object is passed as the second argument to the Document. object is passed as the second argument to the Document.
Permission -- 'View' Permission -- 'View'
""" """
...@@ -111,19 +111,19 @@ class DTMLDocument: ...@@ -111,19 +111,19 @@ class DTMLDocument:
Change the DTML Document, replacing its contents with 'data' Change the DTML Document, replacing its contents with 'data'
and and
changing its title. changing its title.
The data argument may be a file object or a string. The data argument may be a file object or a string.
Permission -- 'Change DTML Documents' Permission -- 'Change DTML Documents'
""" """
def document_src(): def document_src():
""" """
Returns the unrendered source text of the DTML Document. Returns the unrendered source text of the DTML Document.
Permission -- 'View management screens' Permission -- 'View management screens'
""" """
def get_size(): def get_size():
""" """
Returns the size of the unrendered source text of the DTML Returns the size of the unrendered source text of the DTML
...@@ -133,5 +133,3 @@ class DTMLDocument: ...@@ -133,5 +133,3 @@ class DTMLDocument:
""" """
__constructor__=manage_addDocument __constructor__=manage_addDocument
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
def manage_addDTMLMethod(id, title): def manage_addDTMLMethod(id, title):
...@@ -26,11 +26,11 @@ class DTMLMethod: ...@@ -26,11 +26,11 @@ class DTMLMethod:
The DTML Method's id is available via the 'document_id' The DTML Method's id is available via the 'document_id'
variable and the title is available via the 'document_title' variable and the title is available via the 'document_title'
variable. variable.
""" """
__extends__=('OFSP.ObjectManagerItem.ObjectManagerItem',) __extends__=('OFSP.ObjectManagerItem.ObjectManagerItem',)
def __call__(client=None, REQUEST={}, **kw): def __call__(client=None, REQUEST={}, **kw):
""" """
...@@ -101,7 +101,7 @@ class DTMLMethod: ...@@ -101,7 +101,7 @@ class DTMLMethod:
When the URL of a DTML Method is fetched from Zope, the DTML When the URL of a DTML Method is fetched from Zope, the DTML
Method is called by the publisher. The REQUEST object is Method is called by the publisher. The REQUEST object is
passed as the second argument to the Method. passed as the second argument to the Method.
Permission -- 'View' Permission -- 'View'
""" """
...@@ -109,19 +109,19 @@ class DTMLMethod: ...@@ -109,19 +109,19 @@ class DTMLMethod:
""" """
Change the DTML Method, replacing its contents with 'data' and Change the DTML Method, replacing its contents with 'data' and
changing its title. changing its title.
The data argument may be a file object or a string. The data argument may be a file object or a string.
Permission -- 'Change DTML Methods' Permission -- 'Change DTML Methods'
""" """
def document_src(): def document_src():
""" """
Returns the unrendered source text of the DTML Method. Returns the unrendered source text of the DTML Method.
Permission -- 'View management screens' Permission -- 'View management screens'
""" """
def get_size(): def get_size():
""" """
Returns the size of the unrendered source text of the DTML Returns the size of the unrendered source text of the DTML
...@@ -129,5 +129,5 @@ class DTMLMethod: ...@@ -129,5 +129,5 @@ class DTMLMethod:
Permission -- 'View' Permission -- 'View'
""" """
__constructor__ = manage_addDTMLMethod __constructor__ = manage_addDTMLMethod
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -21,9 +21,9 @@ class DateTime: ...@@ -21,9 +21,9 @@ class DateTime:
DateTime objects represent instants in time and provide DateTime objects represent instants in time and provide
interfaces for controlling its representation without interfaces for controlling its representation without
affecting the absolute value of the object. affecting the absolute value of the object.
DateTime objects may be created from a wide variety of string DateTime objects may be created from a wide variety of string
or numeric data, or may be computed from other DateTime objects. or numeric data, or may be computed from other DateTime objects.
DateTimes support the ability to convert their representations DateTimes support the ability to convert their representations
to many major timezones, as well as the ability to create a to many major timezones, as well as the ability to create a
...@@ -49,7 +49,7 @@ class DateTime: ...@@ -49,7 +49,7 @@ class DateTime:
object. object.
DateTime objects may be converted to integer, long, or float DateTime objects may be converted to integer, long, or float
numbers of days since January 1, 1901, using the standard int, numbers of days since January 1, 1901, using the standard int,
long, and float functions (Compatibility Note: int, long and long, and float functions (Compatibility Note: int, long and
float return the number of days since 1901 in GMT rather than float return the number of days since 1901 in GMT rather than
local machine timezone). DateTime objects also provide access local machine timezone). DateTime objects also provide access
...@@ -61,7 +61,7 @@ class DateTime: ...@@ -61,7 +61,7 @@ class DateTime:
and numeric operations return a new DateTime object rather than and numeric operations return a new DateTime object rather than
modify the current object. modify the current object.
A DateTime object always maintains its value as an absolute A DateTime object always maintains its value as an absolute
UTC time, and is represented in the context of some timezone UTC time, and is represented in the context of some timezone
based on the arguments used to create the object. A DateTime based on the arguments used to create the object. A DateTime
object's methods return values based on the timezone context. object's methods return values based on the timezone context.
...@@ -72,8 +72,8 @@ class DateTime: ...@@ -72,8 +72,8 @@ class DateTime:
DateTimes may be created with from zero to DateTimes may be created with from zero to
seven arguments. seven arguments.
- If the function is called with no arguments, then the - If the function is called with no arguments, then the
current date/time is returned, represented in the current date/time is returned, represented in the
timezone of the local machine. timezone of the local machine.
- If the function is invoked with a single string argument - If the function is invoked with a single string argument
...@@ -85,7 +85,7 @@ class DateTime: ...@@ -85,7 +85,7 @@ class DateTime:
representing a valid date/time, an object representing representing a valid date/time, an object representing
that date/time will be returned. that date/time will be returned.
As a general rule, any date-time representation that is As a general rule, any date-time representation that is
recognized and unambiguous to a resident of North America is recognized and unambiguous to a resident of North America is
acceptable.(The reason for this qualification is that acceptable.(The reason for this qualification is that
in North America, a date like: 2/1/1994 is interpreted in North America, a date like: 2/1/1994 is interpreted
...@@ -139,11 +139,11 @@ class DateTime: ...@@ -139,11 +139,11 @@ class DateTime:
case a 12-hour clock is assumed. case a 12-hour clock is assumed.
- If the DateTime function is invoked with a single - If the DateTime function is invoked with a single
Numeric argument, the number is assumed to be Numeric argument, the number is assumed to be
a floating point value such as that returned by a floating point value such as that returned by
time.time(). time.time().
A DateTime object is returned that represents A DateTime object is returned that represents
the gmt value of the time.time() float represented in the gmt value of the time.time() float represented in
the local machine's timezone. the local machine's timezone.
...@@ -152,7 +152,7 @@ class DateTime: ...@@ -152,7 +152,7 @@ class DateTime:
second argument is taken to be an offset in days from second argument is taken to be an offset in days from
the beginning of the year, in the context of the local the beginning of the year, in the context of the local
machine timezone. machine timezone.
The date-time value returned is the given offset number of The date-time value returned is the given offset number of
days from the beginning of the given year, represented in days from the beginning of the given year, represented in
the timezone of the local machine. The offset may be positive the timezone of the local machine. The offset may be positive
or negative. or negative.
...@@ -161,7 +161,7 @@ class DateTime: ...@@ -161,7 +161,7 @@ class DateTime:
- If the function is invoked with two arguments, the first - If the function is invoked with two arguments, the first
a float representing a number of seconds past the epoch a float representing a number of seconds past the epoch
in gmt (such as those returned by time.time()) and the in gmt (such as those returned by time.time()) and the
second a string naming a recognized timezone, a DateTime second a string naming a recognized timezone, a DateTime
with a value of that gmt time will be returned, represented with a value of that gmt time will be returned, represented
in the given timezone.:: in the given timezone.::
...@@ -197,10 +197,10 @@ class DateTime: ...@@ -197,10 +197,10 @@ class DateTime:
If a string argument passed to the DateTime constructor cannot be If a string argument passed to the DateTime constructor cannot be
parsed, it will raise DateTime.SyntaxError. Invalid date, time, or parsed, it will raise DateTime.SyntaxError. Invalid date, time, or
timezone components will raise a DateTime.DateTimeError. timezone components will raise a DateTime.DateTimeError.
The module function Timezones() will return a list of the The module function Timezones() will return a list of the
timezones recognized by the DateTime module. Recognition of timezones recognized by the DateTime module. Recognition of
timezone names is case-insensitive. timezone names is case-insensitive.
""" """
...@@ -470,7 +470,7 @@ class DateTime: ...@@ -470,7 +470,7 @@ class DateTime:
""" """
def Day(): def Day():
""" """
Return the full name of the day of the week Return the full name of the day of the week
...@@ -603,7 +603,7 @@ class DateTime: ...@@ -603,7 +603,7 @@ class DateTime:
Permission -- Always available Permission -- Always available
""" """
def TimeMinutes(): def TimeMinutes():
""" """
Return the time string for an object not showing seconds. Return the time string for an object not showing seconds.
...@@ -739,18 +739,3 @@ class DateTime: ...@@ -739,18 +739,3 @@ class DateTime:
Permission -- Always available Permission -- Always available
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -54,37 +54,35 @@ class File: ...@@ -54,37 +54,35 @@ class File:
Also see ObjectManager for details on the 'objectValues' Also see ObjectManager for details on the 'objectValues'
method. method.
""" """
__constructor__=manage_addFile __constructor__=manage_addFile
__extends__=( __extends__=(
'OFSP.ObjectManagerItem.ObjectManagerItem', 'OFSP.ObjectManagerItem.ObjectManagerItem',
'OFSP.PropertyManager.PropertyManager', 'OFSP.PropertyManager.PropertyManager',
) )
def update_data(data, content_type=None, size=None): def update_data(data, content_type=None, size=None):
""" """
Updates the contents of the File with 'data'. Updates the contents of the File with 'data'.
The 'data' argument must be a string. If 'content_type' is not The 'data' argument must be a string. If 'content_type' is not
provided, then a content type will not be set. If size is not provided, then a content type will not be set. If size is not
provided, the size of the file will be computed from 'data'. provided, the size of the file will be computed from 'data'.
Permission -- Python only Permission -- Python only
""" """
def getSize(): def getSize():
""" """
Returns the size of the file in bytes. Returns the size of the file in bytes.
Permission -- 'View' Permission -- 'View'
""" """
def getContentType(): def getContentType():
""" """
Returns the content type of the file. Returns the content type of the file.
Permission -- 'View' Permission -- 'View'
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -31,19 +31,8 @@ class Folder: ...@@ -31,19 +31,8 @@ class Folder:
__extends__=( __extends__=(
'OFSP.ObjectManagerItem.ObjectManagerItem', 'OFSP.ObjectManagerItem.ObjectManagerItem',
'OFSP.ObjectManager.ObjectManager', 'OFSP.ObjectManager.ObjectManager',
'OFSP.PropertyManager.PropertyManager', 'OFSP.PropertyManager.PropertyManager',
) )
__constructor__ = manage_addFolder __constructor__ = manage_addFolder
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
def manage_addImage(id, file, title='', precondition='', content_type=''): def manage_addImage(id, file, title='', precondition='', content_type=''):
...@@ -54,7 +54,7 @@ class Image: ...@@ -54,7 +54,7 @@ class Image:
method. For example:: method. For example::
<dtml-var "ImageObject.tag(border='5', align='left')"> <dtml-var "ImageObject.tag(border='5', align='left')">
""" """
__constructor__=manage_addImage __constructor__=manage_addImage
...@@ -66,13 +66,13 @@ class Image: ...@@ -66,13 +66,13 @@ class Image:
""" """
This method returns a string which contains an HTML IMG tag This method returns a string which contains an HTML IMG tag
reference to the image. reference to the image.
Optionally, the 'height', 'width', 'alt', 'scale', 'xscale' Optionally, the 'height', 'width', 'alt', 'scale', 'xscale'
and 'yscale' arguments can be provided which are turned into and 'yscale' arguments can be provided which are turned into
HTML IMG tag attributes. Note, 'height' and 'width' are HTML IMG tag attributes. Note, 'height' and 'width' are
provided by default, and 'alt' comes from the 'title_or_id' provided by default, and 'alt' comes from the 'title_or_id'
method. method.
Keyword arguments may be provided to support other or future IMG Keyword arguments may be provided to support other or future IMG
tag attributes. The one exception to this is the HTML Cascading tag attributes. The one exception to this is the HTML Cascading
Style Sheet tag 'class'. Because the word 'class' is a reserved Style Sheet tag 'class'. Because the word 'class' is a reserved
...@@ -82,10 +82,3 @@ class Image: ...@@ -82,10 +82,3 @@ class Image:
Permission -- 'View' Permission -- 'View'
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
class ObjectManager: class ObjectManager:
...@@ -39,7 +39,7 @@ class ObjectManager: ...@@ -39,7 +39,7 @@ class ObjectManager:
""" """
This method returns a list of the ids of the contained This method returns a list of the ids of the contained
objects. objects.
Optionally, you can pass an argument specifying what object Optionally, you can pass an argument specifying what object
meta_type(es) to restrict the results to. This argument can be meta_type(es) to restrict the results to. This argument can be
a string specifying one meta_type, or it can be a list of a string specifying one meta_type, or it can be a list of
...@@ -62,7 +62,7 @@ class ObjectManager: ...@@ -62,7 +62,7 @@ class ObjectManager:
def objectValues(type=None): def objectValues(type=None):
""" """
This method returns a sequence of contained objects. This method returns a sequence of contained objects.
Like objectItems and objectIds, it accepts one argument, Like objectItems and objectIds, it accepts one argument,
either a string or a list to restrict the results to objects either a string or a list to restrict the results to objects
of a given meta_type or set of meta_types. of a given meta_type or set of meta_types.
...@@ -76,16 +76,16 @@ class ObjectManager: ...@@ -76,16 +76,16 @@ class ObjectManager:
There are no Folders. There are no Folders.
</dtml-in> </dtml-in>
The results were restricted to Folders by passing a The results were restricted to Folders by passing a
meta_type to 'objectValues' method. meta_type to 'objectValues' method.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def objectItems(type=None): def objectItems(type=None):
""" """
This method returns a sequence of (id, object) tuples. This method returns a sequence of (id, object) tuples.
Like objectValues and objectIds, it accepts one argument, Like objectValues and objectIds, it accepts one argument,
either a string or a list to restrict the results to objects either a string or a list to restrict the results to objects
of a given meta_type or set of meta_types. of a given meta_type or set of meta_types.
...@@ -93,7 +93,7 @@ class ObjectManager: ...@@ -93,7 +93,7 @@ class ObjectManager:
Each tuple's first element is the id of an object contained in Each tuple's first element is the id of an object contained in
the Object Manager, and the second element is the object the Object Manager, and the second element is the object
itself. itself.
Example:: Example::
<dtml-in objectItems> <dtml-in objectItems>
...@@ -102,7 +102,7 @@ class ObjectManager: ...@@ -102,7 +102,7 @@ class ObjectManager:
<dtml-else> <dtml-else>
There are no sub-objects. There are no sub-objects.
</dtml-in> </dtml-in>
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
...@@ -111,11 +111,11 @@ class ObjectManager: ...@@ -111,11 +111,11 @@ class ObjectManager:
This method returns a list of objects of a given meta_type(es) This method returns a list of objects of a given meta_type(es)
contained in the Object Manager and all its parent Object contained in the Object Manager and all its parent Object
Managers. Managers.
The type argument specifies the meta_type(es). It can be a string The type argument specifies the meta_type(es). It can be a string
specifying one meta_type, or it can be a list of strings to specifying one meta_type, or it can be a list of strings to
specify many. specify many.
Permission -- Python only Permission -- Python only
""" """
...@@ -131,7 +131,7 @@ class ObjectManager: ...@@ -131,7 +131,7 @@ class ObjectManager:
def __getitem__(id): def __getitem__(id):
""" """
Returns a child object given a child id. If there is no child Returns a child object given a child id. If there is no child
with the given id, a KeyError is raised. This method makes it easy with the given id, a KeyError is raised. This method makes it easy
to refer to children that have id with file extensions. For to refer to children that have id with file extensions. For
example:: example::
...@@ -148,22 +148,22 @@ class ObjectManager: ...@@ -148,22 +148,22 @@ class ObjectManager:
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def setBrowserDefaultId(id='', acquire=0): def setBrowserDefaultId(id='', acquire=0):
""" """
Sets the id of the object or method used as the default method when Sets the id of the object or method used as the default method when
the object manager is published. If acquire is set then the default the object manager is published. If acquire is set then the default
method id will be acquired from the parent container. method id will be acquired from the parent container.
Permission -- 'Manage folderish settings' Permission -- 'Manage folderish settings'
""" """
def getBrowserDefaultId(acquire=0): def getBrowserDefaultId(acquire=0):
""" """
Returns the id of the object or method used as the default when the Returns the id of the object or method used as the default when the
object manager is published. By default, this setting is acquired. If object manager is published. By default, this setting is acquired. If
the acquire argument is true, then the return value will be acquired the acquire argument is true, then the return value will be acquired
from the parent if it is not set locally. Otherwise, None is returned from the parent if it is not set locally. Otherwise, None is returned
if the default id is not set on this object manager. if the default id is not set on this object manager.
Permission -- 'View' Permission -- 'View'
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
class ObjectManagerItem: class ObjectManagerItem:
...@@ -19,21 +19,21 @@ class ObjectManagerItem: ...@@ -19,21 +19,21 @@ class ObjectManagerItem:
ObjectMangerItems have these instance ObjectMangerItems have these instance
attributes: attributes:
'title' -- The title of the object. 'title' -- The title of the object.
This is an optional one-line string description of the object. This is an optional one-line string description of the object.
'meta_type' -- A short name for the type of the object. 'meta_type' -- A short name for the type of the object.
This is the name that shows up in product add list for the This is the name that shows up in product add list for the
object and is used when filtering objects by type. object and is used when filtering objects by type.
This attribute is provided by the object's class and should This attribute is provided by the object's class and should
not be changed directly. not be changed directly.
'REQUEST' -- The current web request. 'REQUEST' -- The current web request.
This object is acquired and should not be set. This object is acquired and should not be set.
""" """
...@@ -49,12 +49,12 @@ class ObjectManagerItem: ...@@ -49,12 +49,12 @@ class ObjectManagerItem:
Permission -- Always available Permission -- Always available
""" """
def title_or_id(): def title_or_id():
""" """
If the title is not blank, return it, otherwise If the title is not blank, return it, otherwise
return the id. return the id.
Permission -- Always available Permission -- Always available
""" """
...@@ -75,11 +75,11 @@ class ObjectManagerItem: ...@@ -75,11 +75,11 @@ class ObjectManagerItem:
Permission -- 'View management screens' Permission -- 'View management screens'
""" """
def this(): def this():
""" """
Return the object. Return the object.
This turns out to be handy in two situations. First, it This turns out to be handy in two situations. First, it
provides a way to refer to an object in DTML expressions. provides a way to refer to an object in DTML expressions.
...@@ -100,14 +100,14 @@ class ObjectManagerItem: ...@@ -100,14 +100,14 @@ class ObjectManagerItem:
the URL returned is relative to the site object. Note, if the URL returned is relative to the site object. Note, if
virtual hosts are being used, then the path returned is a virtual hosts are being used, then the path returned is a
logical, rather than a physical path. logical, rather than a physical path.
Permission -- Always available Permission -- Always available
""" """
def getPhysicalRoot(): def getPhysicalRoot():
""" """
Returns the top-level Zope Application object. Returns the top-level Zope Application object.
Permission -- Python only Permission -- Python only
""" """
...@@ -136,9 +136,9 @@ class ObjectManagerItem: ...@@ -136,9 +136,9 @@ class ObjectManagerItem:
def restrictedTraverse(path, default=None): def restrictedTraverse(path, default=None):
""" """
Return the object obtained by traversing the given path from Return the object obtained by traversing the given path from
the object on which the method was called, performing security the object on which the method was called, performing security
checks along the way. checks along the way.
If an object is not found then the 'default' argument will be If an object is not found then the 'default' argument will be
returned. returned.
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
class PropertyManager: class PropertyManager:
...@@ -16,7 +16,7 @@ class PropertyManager: ...@@ -16,7 +16,7 @@ class PropertyManager:
A Property Manager object has a collection of typed attributes A Property Manager object has a collection of typed attributes
called properties. Properties can be managed through the web or called properties. Properties can be managed through the web or
via DTML. via DTML.
In addition to having a type, properties can be writable or In addition to having a type, properties can be writable or
read-only and can have default values. read-only and can have default values.
""" """
...@@ -25,7 +25,7 @@ class PropertyManager: ...@@ -25,7 +25,7 @@ class PropertyManager:
""" """
Return the value of the property 'id'. If the property is not Return the value of the property 'id'. If the property is not
found the optional second argument or None is returned. found the optional second argument or None is returned.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
...@@ -33,7 +33,7 @@ class PropertyManager: ...@@ -33,7 +33,7 @@ class PropertyManager:
""" """
Get the type of property 'id'. Returns None if no such Get the type of property 'id'. Returns None if no such
property exists. property exists.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
...@@ -41,28 +41,28 @@ class PropertyManager: ...@@ -41,28 +41,28 @@ class PropertyManager:
""" """
Returns a true value if the Property Manager has the property Returns a true value if the Property Manager has the property
'id'. Otherwise returns a false value. 'id'. Otherwise returns a false value.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def propertyIds(): def propertyIds():
""" """
Returns a list of property ids. Returns a list of property ids.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def propertyValues(): def propertyValues():
""" """
Returns a list of property values. Returns a list of property values.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def propertyItems(): def propertyItems():
""" """
Return a list of (id, property) tuples. Return a list of (id, property) tuples.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
...@@ -70,7 +70,6 @@ class PropertyManager: ...@@ -70,7 +70,6 @@ class PropertyManager:
""" """
Returns a tuple of mappings, giving meta-data for properties. Returns a tuple of mappings, giving meta-data for properties.
The meta-data includes 'id', 'type', and 'mode'. The meta-data includes 'id', 'type', and 'mode'.
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
class PropertySheet: class PropertySheet:
...@@ -16,8 +16,8 @@ class PropertySheet: ...@@ -16,8 +16,8 @@ class PropertySheet:
A PropertySheet is an abstraction for organizing and working A PropertySheet is an abstraction for organizing and working
with a set of related properties. Conceptually it acts like a with a set of related properties. Conceptually it acts like a
container for a set of related properties and meta-data describing container for a set of related properties and meta-data describing
those properties. A PropertySheet may or may not provide a web those properties. A PropertySheet may or may not provide a web
interface for managing its properties. interface for managing its properties.
""" """
...@@ -26,7 +26,7 @@ class PropertySheet: ...@@ -26,7 +26,7 @@ class PropertySheet:
""" """
Return a namespace string usable as an xml namespace Return a namespace string usable as an xml namespace
for this property set. This may be an empty string if for this property set. This may be an empty string if
there is no default namespace for a given property sheet there is no default namespace for a given property sheet
(especially property sheets added in ZClass definitions). (especially property sheets added in ZClass definitions).
...@@ -37,27 +37,27 @@ class PropertySheet: ...@@ -37,27 +37,27 @@ class PropertySheet:
def getProperty(id, d=None): def getProperty(id, d=None):
""" """
Get the property 'id', returning the optional second Get the property 'id', returning the optional second
argument or None if no such property is found. argument or None if no such property is found.
Permission -- Python only Permission -- Python only
""" """
def getPropertyType(id): def getPropertyType(id):
""" """
Get the type of property 'id'. Returns None if no such Get the type of property 'id'. Returns None if no such
property exists. property exists.
Permission -- Python only Permission -- Python only
""" """
def hasProperty(id): def hasProperty(id):
""" """
Returns true if 'self' has a property with the given 'id', Returns true if 'self' has a property with the given 'id',
false otherwise. false otherwise.
Permission -- 'Access contents information' Permission -- 'Access contents information'
...@@ -90,7 +90,7 @@ class PropertySheet: ...@@ -90,7 +90,7 @@ class PropertySheet:
Permission -- 'Access contents information' Permission -- 'Access contents information'
""" """
def propertyMap(): def propertyMap():
""" """
...@@ -117,26 +117,26 @@ class PropertySheet: ...@@ -117,26 +117,26 @@ class PropertySheet:
These are the These are the
property types: property types:
'boolean' -- 1 or 0. 'boolean' -- 1 or 0.
'date' -- A 'DateTime' value, for example '12/31/1999 15:42:52 PST'. 'date' -- A 'DateTime' value, for example '12/31/1999 15:42:52 PST'.
'float' -- A decimal number, for example '12.4'. 'float' -- A decimal number, for example '12.4'.
'int' -- An integer number, for example, '12'. 'int' -- An integer number, for example, '12'.
'lines' -- A list of strings, one per line. 'lines' -- A list of strings, one per line.
'long' -- A long integer, for example '12232322322323232323423'. 'long' -- A long integer, for example '12232322322323232323423'.
'string' -- A string of characters, for example 'This is a string'. 'string' -- A string of characters, for example 'This is a string'.
'text' -- A multi-line string, for example a paragraph. 'text' -- A multi-line string, for example a paragraph.
'tokens' -- A list of strings separated by white space, for example 'tokens' -- A list of strings separated by white space, for example
'one two three'. 'one two three'.
'selection' -- A string selected by a pop-up menu. 'selection' -- A string selected by a pop-up menu.
'multiple selection' -- A list of strings selected by a selection list. 'multiple selection' -- A list of strings selected by a selection list.
...@@ -166,17 +166,17 @@ class PropertySheet: ...@@ -166,17 +166,17 @@ class PropertySheet:
def manage_changeProperties(REQUEST=None, **kw): def manage_changeProperties(REQUEST=None, **kw):
""" """
Change existing object properties by passing either a mapping Change existing object properties by passing either a mapping
object as 'REQUEST' containing name:value pairs or by passing object as 'REQUEST' containing name:value pairs or by passing
name=value keyword arguments. name=value keyword arguments.
Some objects have "special" properties defined by product Some objects have "special" properties defined by product
authors that cannot be changed. If you try to change one of authors that cannot be changed. If you try to change one of
these properties through this method, an error will be raised. these properties through this method, an error will be raised.
Note that no type checking or conversion happens when this Note that no type checking or conversion happens when this
method is called, so it is the caller's responsibility to method is called, so it is the caller's responsibility to
ensure that the updated values are of the correct type. ensure that the updated values are of the correct type.
*This should probably change*. *This should probably change*.
If a value is provided for 'REQUEST' (as it will be when If a value is provided for 'REQUEST' (as it will be when
...@@ -195,11 +195,11 @@ class PropertySheet: ...@@ -195,11 +195,11 @@ class PropertySheet:
def manage_delProperties(ids=None, REQUEST=None): def manage_delProperties(ids=None, REQUEST=None):
""" """
Delete one or more properties with the given 'ids'. The 'ids' Delete one or more properties with the given 'ids'. The 'ids'
argument should be a sequence (tuple or list) containing the argument should be a sequence (tuple or list) containing the
ids of the properties to be deleted. If 'ids' is empty no ids of the properties to be deleted. If 'ids' is empty no
action will be taken. If any of the properties named in 'ids' action will be taken. If any of the properties named in 'ids'
does not exist, an error will be raised. does not exist, an error will be raised.
Some objects have "special" properties defined by product Some objects have "special" properties defined by product
authors that cannot be deleted. If one of these properties is authors that cannot be deleted. If one of these properties is
...@@ -216,10 +216,3 @@ class PropertySheet: ...@@ -216,10 +216,3 @@ class PropertySheet:
Permission -- 'Manage Properties' Permission -- 'Manage Properties'
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -31,7 +31,7 @@ class PropertySheets: ...@@ -31,7 +31,7 @@ class PropertySheets:
dictionary-style key indexing. dictionary-style key indexing.
""" """
def values(): def values():
""" """
...@@ -39,7 +39,7 @@ class PropertySheets: ...@@ -39,7 +39,7 @@ class PropertySheets:
in the collection. in the collection.
Permission -- Python only Permission -- Python only
""" """
def items(): def items():
...@@ -59,6 +59,5 @@ class PropertySheets: ...@@ -59,6 +59,5 @@ class PropertySheets:
given in 'default' if the named PropertySheet is not found. given in 'default' if the named PropertySheet is not found.
Permission -- Python only Permission -- Python only
"""
"""
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -121,10 +121,10 @@ class Request: ...@@ -121,10 +121,10 @@ class Request:
This name and value is stored in the 'Other' category. This name and value is stored in the 'Other' category.
Permission -- Always available Permission -- Always available
""" """
def get_header(name, default=None): def get_header(name, default=None):
""" """
...@@ -136,7 +136,7 @@ class Request: ...@@ -136,7 +136,7 @@ class Request:
if available. if available.
Permission -- Always available Permission -- Always available
""" """
...@@ -147,7 +147,7 @@ class Request: ...@@ -147,7 +147,7 @@ class Request:
returns a false value otherwise. returns a false value otherwise.
Permission -- Always available Permission -- Always available
""" """
...@@ -157,7 +157,7 @@ class Request: ...@@ -157,7 +157,7 @@ class Request:
Returns a sorted sequence of all keys in the REQUEST object. Returns a sorted sequence of all keys in the REQUEST object.
Permission -- Always available Permission -- Always available
""" """
def items(): def items():
...@@ -167,7 +167,7 @@ class Request: ...@@ -167,7 +167,7 @@ class Request:
the REQUEST object. the REQUEST object.
Permission -- Always available Permission -- Always available
""" """
def values(): def values():
...@@ -177,7 +177,7 @@ class Request: ...@@ -177,7 +177,7 @@ class Request:
object. object.
Permission -- Always available Permission -- Always available
""" """
def setServerURL(protocol=None, hostname=None, port=None): def setServerURL(protocol=None, hostname=None, port=None):
...@@ -214,5 +214,3 @@ class Request: ...@@ -214,5 +214,3 @@ class Request:
Permissions -- Always available Permissions -- Always available
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
...@@ -22,7 +22,7 @@ class Response: ...@@ -22,7 +22,7 @@ class Response:
def setStatus(status, reason=None): def setStatus(status, reason=None):
''' '''
Sets the HTTP status code of the response; the argument may Sets the HTTP status code of the response; the argument may
either be an integer or one of the following strings: either be an integer or one of the following strings:
...@@ -41,7 +41,7 @@ class Response: ...@@ -41,7 +41,7 @@ class Response:
NotImplemented, NotImplemented,
BadGateway, BadGateway,
ServiceUnavailable ServiceUnavailable
that will be converted to the correct integer value. that will be converted to the correct integer value.
Permission -- Always available Permission -- Always available
...@@ -50,7 +50,7 @@ class Response: ...@@ -50,7 +50,7 @@ class Response:
def setHeader(name, value): def setHeader(name, value):
''' '''
Sets an HTTP return header "name" with value "value", clearing Sets an HTTP return header "name" with value "value", clearing
the previous value set for the header, if one exists. If the the previous value set for the header, if one exists. If the
literal flag is true, the case of the header name is literal flag is true, the case of the header name is
...@@ -63,12 +63,12 @@ class Response: ...@@ -63,12 +63,12 @@ class Response:
def addHeader(name, value): def addHeader(name, value):
''' '''
Set a new HTTP return header with the given value, while Set a new HTTP return header with the given value, while
retaining any previously set headers with the same name. retaining any previously set headers with the same name.
Permission -- Always available Permission -- Always available
''' '''
def setBase(base): def setBase(base):
...@@ -77,27 +77,27 @@ class Response: ...@@ -77,27 +77,27 @@ class Response:
Set the base URL for the returned document. Set the base URL for the returned document.
Permission -- Always available Permission -- Always available
""" """
def appendCookie(name, value): def appendCookie(name, value):
''' '''
Returns an HTTP header that sets a cookie on cookie-enabled Returns an HTTP header that sets a cookie on cookie-enabled
browsers with a key "name" and value "value". If a value for the browsers with a key "name" and value "value". If a value for the
cookie has previously been set in the response object, the new cookie has previously been set in the response object, the new
value is appended to the old one separated by a colon. value is appended to the old one separated by a colon.
Permission -- Always available Permission -- Always available
''' '''
def expireCookie(name, **kw): def expireCookie(name, **kw):
''' '''
Cause an HTTP cookie to be removed from the browser Cause an HTTP cookie to be removed from the browser
The response will include an HTTP header that will remove the cookie The response will include an HTTP header that will remove the cookie
corresponding to "name" on the client, if one exists. This is corresponding to "name" on the client, if one exists. This is
accomplished by sending a new cookie with an expiration date accomplished by sending a new cookie with an expiration date
...@@ -107,12 +107,12 @@ class Response: ...@@ -107,12 +107,12 @@ class Response:
argument. argument.
Permission -- Always available Permission -- Always available
''' '''
def setCookie(name,value,**kw): def setCookie(name,value,**kw):
''' '''
Set an HTTP cookie on the browser Set an HTTP cookie on the browser
The response will include an HTTP header that sets a cookie on The response will include an HTTP header that sets a cookie on
...@@ -126,20 +126,20 @@ class Response: ...@@ -126,20 +126,20 @@ class Response:
the browser and stored in REQUEST.cookies. the browser and stored in REQUEST.cookies.
Permission -- Always available Permission -- Always available
''' '''
def appendHeader(name, value, delimiter=","): def appendHeader(name, value, delimiter=","):
''' '''
Append a value to a header. Append a value to a header.
Sets an HTTP return header "name" with value "value", Sets an HTTP return header "name" with value "value",
appending it following a comma if there was a previous value appending it following a comma if there was a previous value
set for the header. set for the header.
Permission -- Always available Permission -- Always available
''' '''
def redirect(location, lock=0): def redirect(location, lock=0):
...@@ -152,7 +152,7 @@ class Response: ...@@ -152,7 +152,7 @@ class Response:
been called). been called).
Permission -- Always available Permission -- Always available
""" """
def write(data): def write(data):
...@@ -167,9 +167,8 @@ class Response: ...@@ -167,9 +167,8 @@ class Response:
cookies on the response object. cookies on the response object.
Note that published objects must not generate any errors Note that published objects must not generate any errors
after beginning stream-oriented output. after beginning stream-oriented output.
Permission -- Always available Permission -- Always available
""" """
...@@ -13,7 +13,3 @@ math: Python 'math' module ...@@ -13,7 +13,3 @@ math: Python 'math' module
module":http://www.python.org/doc/current/lib/module-math.html module":http://www.python.org/doc/current/lib/module-math.html
documentation at Python.org documentation at Python.org
""" """
...@@ -14,5 +14,3 @@ random: Python 'random' module ...@@ -14,5 +14,3 @@ random: Python 'random' module
module":http://www.python.org/doc/current/lib/module-random.html module":http://www.python.org/doc/current/lib/module-random.html
documentation at Python.org documentation at Python.org
""" """
...@@ -12,9 +12,9 @@ def sort(seq, sort): ...@@ -12,9 +12,9 @@ def sort(seq, sort):
that describe the sort order. that describe the sort order.
key -- Attribute of the object to be sorted. key -- Attribute of the object to be sorted.
func -- Defines the compare function (optional). Allowed values: func -- Defines the compare function (optional). Allowed values:
"cmp" -- Standard Python comparison function "cmp" -- Standard Python comparison function
"nocase" -- Case-insensitive comparison "nocase" -- Case-insensitive comparison
...@@ -23,7 +23,7 @@ def sort(seq, sort): ...@@ -23,7 +23,7 @@ def sort(seq, sort):
"strcoll_nocase" or "locale_nocase" -- Locale-aware "strcoll_nocase" or "locale_nocase" -- Locale-aware
case-insensitive string comparison case-insensitive string comparison
other -- A specified, user-defined comparison function, should other -- A specified, user-defined comparison function, should
return 1, 0, -1. return 1, 0, -1.
...@@ -31,7 +31,7 @@ def sort(seq, sort): ...@@ -31,7 +31,7 @@ def sort(seq, sort):
(allowed values: "asc", "desc") (allowed values: "asc", "desc")
DTML Examples DTML Examples
Sort child object (using the 'objectValues' method) by id (using Sort child object (using the 'objectValues' method) by id (using
the 'getId' method), ignoring case:: the 'getId' method), ignoring case::
...@@ -64,7 +64,7 @@ def sort(seq, sort): ...@@ -64,7 +64,7 @@ def sort(seq, sort):
<tr tal:repeat="item sorted_objects"> <tr tal:repeat="item sorted_objects">
<td tal:content="item/title">title</td> <td tal:content="item/title">title</td>
<td tal:content="item/bobobase_modification_time"> <td tal:content="item/bobobase_modification_time">
modification date</td> modification date</td>
</tr> </tr>
</table> </table>
...@@ -75,9 +75,5 @@ def sort(seq, sort): ...@@ -75,9 +75,5 @@ def sort(seq, sort):
See Also See Also
"Python cmp function":http://www.python.org/doc/lib/built-in-funcs.html "Python cmp function":http://www.python.org/doc/lib/built-in-funcs.html
"""
"""
...@@ -13,8 +13,3 @@ string: Python 'string' module ...@@ -13,8 +13,3 @@ string: Python 'string' module
module":http://www.python.org/doc/current/lib/module-string.html module":http://www.python.org/doc/current/lib/module-string.html
documentation at Python.org documentation at Python.org
""" """
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Page Template Expression Engine """Page Template Expression Engine
...@@ -17,7 +17,7 @@ Page Template-specific implementation of TALES, with handlers ...@@ -17,7 +17,7 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, string literals, and paths. for Python expressions, string literals, and paths.
""" """
__version__='$Revision: 1.35 $'[11:-2] __version__='$Revision: 1.36 $'[11:-2]
import re, sys import re, sys
from TALES import Engine, CompilerError, _valid_name, NAME_RE, \ from TALES import Engine, CompilerError, _valid_name, NAME_RE, \
...@@ -196,7 +196,7 @@ class PathExpr: ...@@ -196,7 +196,7 @@ class PathExpr:
def __repr__(self): def __repr__(self):
return '%s:%s' % (self._name, `self._s`) return '%s:%s' % (self._name, `self._s`)
_interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE}) _interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE})
class StringExpr: class StringExpr:
...@@ -223,7 +223,7 @@ class StringExpr: ...@@ -223,7 +223,7 @@ class StringExpr:
parts.append(exp) parts.append(exp)
expr = ''.join(parts) expr = ''.join(parts)
self._expr = expr self._expr = expr
def __call__(self, econtext): def __call__(self, econtext):
vvals = [] vvals = []
for var in self._vars: for var in self._vars:
...@@ -244,7 +244,7 @@ class NotExpr: ...@@ -244,7 +244,7 @@ class NotExpr:
def __init__(self, name, expr, compiler): def __init__(self, name, expr, compiler):
self._s = expr = expr.lstrip() self._s = expr = expr.lstrip()
self._c = compiler.compile(expr) self._c = compiler.compile(expr)
def __call__(self, econtext): def __call__(self, econtext):
return not econtext.evaluateBoolean(self._c) return not econtext.evaluateBoolean(self._c)
...@@ -266,7 +266,7 @@ class DeferExpr: ...@@ -266,7 +266,7 @@ class DeferExpr:
def __init__(self, name, expr, compiler): def __init__(self, name, expr, compiler):
self._s = expr = expr.lstrip() self._s = expr = expr.lstrip()
self._c = compiler.compile(expr) self._c = compiler.compile(expr)
def __call__(self, econtext): def __call__(self, econtext):
return DeferWrapper(self._c, econtext) return DeferWrapper(self._c, econtext)
...@@ -286,7 +286,7 @@ def restrictedTraverse(self, path, securityManager, ...@@ -286,7 +286,7 @@ def restrictedTraverse(self, path, securityManager,
if not securityManager.validateValue(self): if not securityManager.validateValue(self):
raise Unauthorized, name raise Unauthorized, name
path.pop(0) path.pop(0)
path.reverse() path.reverse()
validate = securityManager.validate validate = securityManager.validate
object = self object = self
...@@ -313,7 +313,7 @@ def restrictedTraverse(self, path, securityManager, ...@@ -313,7 +313,7 @@ def restrictedTraverse(self, path, securityManager,
t=get(object, '__bobo_traverse__', N) t=get(object, '__bobo_traverse__', N)
if t is not N: if t is not N:
o=t(REQUEST, name) o=t(REQUEST, name)
container = None container = None
if has(o, 'im_self'): if has(o, 'im_self'):
container = o.im_self container = o.im_self
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Page Template module """Page Template module
HTML- and XML-based template objects using TAL, TALES, and METAL. HTML- and XML-based template objects using TAL, TALES, and METAL.
""" """
__version__='$Revision: 1.24 $'[11:-2] __version__='$Revision: 1.25 $'[11:-2]
import sys import sys
...@@ -31,7 +31,7 @@ from ComputedAttribute import ComputedAttribute ...@@ -31,7 +31,7 @@ from ComputedAttribute import ComputedAttribute
class PageTemplate(Base): class PageTemplate(Base):
"Page Templates using TAL, TALES, and METAL" "Page Templates using TAL, TALES, and METAL"
content_type = 'text/html' content_type = 'text/html'
expand = 0 expand = 0
_v_errors = () _v_errors = ()
...@@ -70,7 +70,7 @@ class PageTemplate(Base): ...@@ -70,7 +70,7 @@ class PageTemplate(Base):
parent = getattr(self, 'aq_parent', None) parent = getattr(self, 'aq_parent', None)
c['root'] = self c['root'] = self
return c return c
def pt_render(self, source=0, extra_context={}): def pt_render(self, source=0, extra_context={}):
"""Render this Page Template""" """Render this Page Template"""
if not self._v_cooked: if not self._v_cooked:
...@@ -106,7 +106,7 @@ class PageTemplate(Base): ...@@ -106,7 +106,7 @@ class PageTemplate(Base):
self.pt_render(source=1) self.pt_render(source=1)
except: except:
return ('Macro expansion failed', '%s: %s' % sys.exc_info()[:2]) return ('Macro expansion failed', '%s: %s' % sys.exc_info()[:2])
def pt_warnings(self): def pt_warnings(self):
if not self._v_cooked: if not self._v_cooked:
self._cook() self._cook()
...@@ -145,7 +145,7 @@ class PageTemplate(Base): ...@@ -145,7 +145,7 @@ class PageTemplate(Base):
return ('%s\n Macro expansion failed\n %s\n-->\n%s' % return ('%s\n Macro expansion failed\n %s\n-->\n%s' %
(self._error_start, "%s: %s" % sys.exc_info()[:2], (self._error_start, "%s: %s" % sys.exc_info()[:2],
self._text) ) self._text) )
return ('%s\n %s\n-->\n%s' % (self._error_start, return ('%s\n %s\n-->\n%s' % (self._error_start,
'\n '.join(self._v_errors), '\n '.join(self._v_errors),
self._text)) self._text))
...@@ -203,4 +203,3 @@ class PageTemplateTracebackSupplement: ...@@ -203,4 +203,3 @@ class PageTemplateTracebackSupplement:
if e: if e:
w = list(w) + list(e) w = list(w) + list(e)
self.warnings = w self.warnings = w
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Filesystem Page Template module """Filesystem Page Template module
Zope object encapsulating a Page Template from the filesystem. Zope object encapsulating a Page Template from the filesystem.
""" """
__version__='$Revision: 1.18 $'[11:-2] __version__='$Revision: 1.19 $'[11:-2]
import os, AccessControl, Acquisition, sys import os, AccessControl, Acquisition, sys
from Globals import package_home, DevelopmentMode from Globals import package_home, DevelopmentMode
...@@ -32,7 +32,7 @@ from Acquisition import aq_parent, aq_inner ...@@ -32,7 +32,7 @@ from Acquisition import aq_parent, aq_inner
class PageTemplateFile(Script, PageTemplate, Traversable): class PageTemplateFile(Script, PageTemplate, Traversable):
"Zope wrapper for filesystem Page Template using TAL, TALES, and METAL" "Zope wrapper for filesystem Page Template using TAL, TALES, and METAL"
meta_type = 'Page Template (File)' meta_type = 'Page Template (File)'
func_defaults = None func_defaults = None
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Path Iterator """Path Iterator
...@@ -17,7 +17,7 @@ A TALES Iterator with the ability to use first() and last() on ...@@ -17,7 +17,7 @@ A TALES Iterator with the ability to use first() and last() on
subpaths of elements. subpaths of elements.
""" """
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
import TALES import TALES
from Expressions import restrictedTraverse, Undefs, getSecurityManager from Expressions import restrictedTraverse, Undefs, getSecurityManager
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Generic Python Expression Handler """Generic Python Expression Handler
""" """
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from TALES import CompilerError from TALES import CompilerError
from sys import exc_info from sys import exc_info
...@@ -61,7 +61,7 @@ class PythonExpr: ...@@ -61,7 +61,7 @@ class PythonExpr:
def __call__(self, econtext): def __call__(self, econtext):
__traceback_info__ = self.expr __traceback_info__ = self.expr
f = self._f f = self._f
f.func_globals.update(self._bind_used_names(econtext)) f.func_globals.update(self._bind_used_names(econtext))
return f() return f()
def __str__(self): def __str__(self):
...@@ -78,4 +78,3 @@ class ExprTypeProxy: ...@@ -78,4 +78,3 @@ class ExprTypeProxy:
def __call__(self, text): def __call__(self, text):
return self._handler(self._name, text, return self._handler(self._name, text,
self._econtext._engine)(self._econtext) self._econtext._engine)(self._econtext)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""TALES """TALES
An implementation of a generic TALES engine An implementation of a generic TALES engine
""" """
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
import re, sys, ZTUtils import re, sys, ZTUtils
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
...@@ -132,7 +132,7 @@ class Engine: ...@@ -132,7 +132,7 @@ class Engine:
raise CompilerError, ( raise CompilerError, (
'Unrecognized expression type "%s".' % type) 'Unrecognized expression type "%s".' % type)
return handler(type, expr, self) return handler(type, expr, self)
def getContext(self, contexts=None, **kwcontexts): def getContext(self, contexts=None, **kwcontexts):
if contexts is not None: if contexts is not None:
if kwcontexts: if kwcontexts:
...@@ -282,4 +282,3 @@ class SimpleExpr: ...@@ -282,4 +282,3 @@ class SimpleExpr:
return self._name, self._expr return self._name, self._expr
def __repr__(self): def __repr__(self):
return '<SimpleExpr %s %s>' % (self._name, `self._expr`) return '<SimpleExpr %s %s>' % (self._name, `self._expr`)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Old Zope-specific Python Expression Handler """Old Zope-specific Python Expression Handler
...@@ -17,7 +17,7 @@ Handler for Python expressions, using the pre-Python 2.1 restriction ...@@ -17,7 +17,7 @@ Handler for Python expressions, using the pre-Python 2.1 restriction
machinery from PythonScripts. machinery from PythonScripts.
""" """
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Products.PythonScripts.Guarded import _marker, \ from Products.PythonScripts.Guarded import _marker, \
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Zope-specific Python Expression Handler """Zope-specific Python Expression Handler
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Handler for Python expressions that uses the RestrictedPython package. Handler for Python expressions that uses the RestrictedPython package.
""" """
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
from AccessControl import full_read_guard, full_write_guard, \ from AccessControl import full_read_guard, full_write_guard, \
safe_builtins, getSecurityManager safe_builtins, getSecurityManager
...@@ -39,12 +39,12 @@ class PythonExpr(PythonExpr): ...@@ -39,12 +39,12 @@ class PythonExpr(PythonExpr):
'\n'.join(err) ) '\n'.join(err) )
self._f_varnames = use.keys() self._f_varnames = use.keys()
self._code = code self._code = code
def __call__(self, econtext): def __call__(self, econtext):
__traceback_info__ = self.expr __traceback_info__ = self.expr
code = self._code code = self._code
g = self._bind_used_names(econtext) g = self._bind_used_names(econtext)
g.update(self._globals) g.update(self._globals)
return eval(code, g, {}) return eval(code, g, {})
class _SecureModuleImporter: class _SecureModuleImporter:
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Zope Page Template module """Zope Page Template module
Zope object encapsulating a Page Template. Zope object encapsulating a Page Template.
""" """
__version__='$Revision: 1.41 $'[11:-2] __version__='$Revision: 1.42 $'[11:-2]
import os, AccessControl, Acquisition, sys import os, AccessControl, Acquisition, sys
from types import StringType from types import StringType
...@@ -48,7 +48,7 @@ except ImportError: ...@@ -48,7 +48,7 @@ except ImportError:
class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
Traversable, PropertyManager): Traversable, PropertyManager):
"Zope wrapper for Page Template using TAL, TALES, and METAL" "Zope wrapper for Page Template using TAL, TALES, and METAL"
if SUPPORTS_WEBDAV_LOCKS: if SUPPORTS_WEBDAV_LOCKS:
__implements__ = (WriteLockInterface,) __implements__ = (WriteLockInterface,)
...@@ -117,7 +117,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -117,7 +117,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
REQUEST.set('text', self.read()) # May not equal 'text'! REQUEST.set('text', self.read()) # May not equal 'text'!
message = "Saved changes." message = "Saved changes."
if getattr(self, '_v_warnings', None): if getattr(self, '_v_warnings', None):
message = ("<strong>Warning:</strong> <i>%s</i>" message = ("<strong>Warning:</strong> <i>%s</i>"
% '<br>'.join(self._v_warnings)) % '<br>'.join(self._v_warnings))
return self.pt_editForm(manage_tabs_message=message) return self.pt_editForm(manage_tabs_message=message)
...@@ -132,7 +132,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -132,7 +132,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
if type(file) is not StringType: if type(file) is not StringType:
if not file: raise ValueError, 'File not specified' if not file: raise ValueError, 'File not specified'
file = file.read() file = file.read()
self.write(file) self.write(file)
message = 'Saved changes.' message = 'Saved changes.'
return self.pt_editForm(manage_tabs_message=message) return self.pt_editForm(manage_tabs_message=message)
...@@ -142,7 +142,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -142,7 +142,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
"""Change editing preferences.""" """Change editing preferences."""
szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchh = {'Taller': 1, 'Shorter': -1, None: 0}
szchw = {'Wider': 5, 'Narrower': -5, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0}
# The <textarea> can have dimensions expressed in percentages # The <textarea> can have dimensions expressed in percentages
if type(width) is StringType and width.endswith('%'): if type(width) is StringType and width.endswith('%'):
cols = int(width[:-1]) cols = int(width[:-1])
...@@ -157,7 +157,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -157,7 +157,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
else: # Absolute width else: # Absolute width
try: cols = int(width) try: cols = int(width)
except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0))
try: rows = int(height) try: rows = int(height)
except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0))
e = (DateTime('GMT') + 365).rfc822() e = (DateTime('GMT') + 365).rfc822()
...@@ -244,7 +244,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -244,7 +244,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
self.write(REQUEST.get('BODY', '')) self.write(REQUEST.get('BODY', ''))
RESPONSE.setStatus(204) RESPONSE.setStatus(204)
return RESPONSE return RESPONSE
manage_FTPput = PUT manage_FTPput = PUT
...@@ -309,7 +309,7 @@ class Src(Acquisition.Explicit): ...@@ -309,7 +309,7 @@ class Src(Acquisition.Explicit):
def __before_publishing_traverse__(self, ob, request): def __before_publishing_traverse__(self, ob, request):
if getattr(request, '_hacked_path', 0): if getattr(request, '_hacked_path', 0):
request._hacked_path = 0 request._hacked_path = 0
def __call__(self, REQUEST, RESPONSE): def __call__(self, REQUEST, RESPONSE):
" " " "
return self.document_src(REQUEST) return self.document_src(REQUEST)
...@@ -342,7 +342,7 @@ def manage_addPageTemplate(self, id, title=None, text=None, ...@@ -342,7 +342,7 @@ def manage_addPageTemplate(self, id, title=None, text=None,
zpt = ZopePageTemplate(id) zpt = ZopePageTemplate(id)
else: else:
zpt = ZopePageTemplate(id, file, headers.get('content_type')) zpt = ZopePageTemplate(id, file, headers.get('content_type'))
self._setObject(id, zpt) self._setObject(id, zpt)
try: try:
...@@ -368,4 +368,3 @@ def initialize(context): ...@@ -368,4 +368,3 @@ def initialize(context):
) )
context.registerHelp() context.registerHelp()
context.registerHelpTitle('Zope Help') context.registerHelpTitle('Zope Help')
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''Package wrapper for Page Templates __doc__='''Package wrapper for Page Templates
This wrapper allows the Page Template modules to be segregated in a This wrapper allows the Page Template modules to be segregated in a
separate package. separate package.
$Id: __init__.py,v 1.3 2001/11/28 15:51:01 matt Exp $''' $Id: __init__.py,v 1.4 2002/08/14 22:17:24 mj Exp $'''
__version__='$$'[11:-2] __version__='$$'[11:-2]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
ZTUtils: Page Template Utilities ZTUtils: Page Template Utilities
The classes in this module are available from Page Templates. The classes in this module are available from Page Templates.
""" """
class Batch: class Batch:
...@@ -23,7 +23,7 @@ class Batch: ...@@ -23,7 +23,7 @@ class Batch:
4 4
>>> b[10] >>> b[10]
IndexError: list index out of range IndexError: list index out of range
Batches have these public attributes: Batches have these public attributes:
start -- The first element number (counting from 1). start -- The first element number (counting from 1).
...@@ -64,7 +64,7 @@ class Batch: ...@@ -64,7 +64,7 @@ class Batch:
start -- The index of the start of the batch (counting from 0). start -- The index of the start of the batch (counting from 0).
end -- The index of the end of the batch (counting from 0). end -- The index of the end of the batch (counting from 0).
orphan -- The desired minimum batch size. This controls how orphan -- The desired minimum batch size. This controls how
sequences are split into batches. If a batch smaller than the sequences are split into batches. If a batch smaller than the
orphan size would occur, then no split is performed, and a orphan size would occur, then no split is performed, and a
......
...@@ -19,7 +19,7 @@ class harness1: ...@@ -19,7 +19,7 @@ class harness1:
'Harness method name "%s" called, "%s" expected.' % 'Harness method name "%s" called, "%s" expected.' %
(name, cs[0][0]) ) (name, cs[0][0]) )
return self._method_ return self._method_
def _method_(self, *args, **kwargs): def _method_(self, *args, **kwargs):
name, aargs, akwargs = self.__callstack.pop(0) name, aargs, akwargs = self.__callstack.pop(0)
assert aargs == args, "Harness method arguments" assert aargs == args, "Harness method arguments"
...@@ -34,4 +34,3 @@ class harness2(harness1): ...@@ -34,4 +34,3 @@ class harness2(harness1):
assert aargs == args, "Harness method arguments" assert aargs == args, "Harness method arguments"
assert akwargs == kwargs, "Harness method keyword args" assert akwargs == kwargs, "Harness method keyword args"
return result return result
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
###################################################################### ######################################################################
...@@ -32,7 +32,7 @@ class batch(util.Base): ...@@ -32,7 +32,7 @@ class batch(util.Base):
self._last=end-1 self._last=end-1
self._first=start-1 self._first=start-1
self._sequence=sequence self._sequence=sequence
self._size=size self._size=size
self._start=start self._start=start
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os, sys, unittest import os, sys, unittest
...@@ -20,7 +20,7 @@ from AccessControl import SecurityManager ...@@ -20,7 +20,7 @@ from AccessControl import SecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
class AqPageTemplate(Implicit, PageTemplate): class AqPageTemplate(Implicit, PageTemplate):
pass pass
class UnitTestSecurityPolicy: class UnitTestSecurityPolicy:
""" """
...@@ -39,105 +39,104 @@ class UnitTestSecurityPolicy: ...@@ -39,105 +39,104 @@ class UnitTestSecurityPolicy:
, *args , *args
, **kw): , **kw):
return 1 return 1
def checkPermission( self, permission, object, context) : def checkPermission( self, permission, object, context) :
return 1 return 1
class DTMLTests(unittest.TestCase): class DTMLTests(unittest.TestCase):
def setUp(self): def setUp(self):
self.t=(AqPageTemplate()) self.t=(AqPageTemplate())
self.policy = UnitTestSecurityPolicy() self.policy = UnitTestSecurityPolicy()
self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy ) self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
noSecurityManager() # Use the new policy. noSecurityManager() # Use the new policy.
def tearDown(self): def tearDown(self):
SecurityManager.setSecurityPolicy( self.oldPolicy ) SecurityManager.setSecurityPolicy( self.oldPolicy )
noSecurityManager() # Reset to old policy. noSecurityManager() # Reset to old policy.
def check1(self): def check1(self):
"""DTML test 1: if, in, and var: """DTML test 1: if, in, and var:
%(comment)[ blah %(comment)]
<html><head><title>Test of documentation templates</title></head>
<body>
%(if args)[
<dl><dt>The arguments to this test program were:<p>
<dd>
<ul>
%(in args)[
<li>Argument number %(num)d was %(arg)s
%(in args)]
</ul></dl><p>
%(if args)]
%(else args)[
No arguments were given.<p>
%(else args)]
And thats da trooth.
</body></html>
"""
tal = util.read_input('DTML1.html')
self.t.write(tal)
aa=util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
o=self.t.__of__(aa)()
expect = util.read_output('DTML1a.html')
util.check_xml(expect, o)
aa=util.argv(())
o=self.t.__of__(aa)()
expect = util.read_output('DTML1b.html')
util.check_xml(expect, o)
def check3(self):
"""DTML test 3: batches and formatting:
%(comment)[ blah %(comment)]
<html><head><title>Test of documentation templates</title></head> <html><head><title>Test of documentation templates</title></head>
<body> <body>
<!--#if args--> %(if args)[
The arguments were: <dl><dt>The arguments to this test program were:<p>
<!--#in args size=size end=end--> <dd>
<!--#if previous-sequence--> <ul>
(<!--#var previous-sequence-start-arg-->- %(in args)[
<!--#var previous-sequence-end-arg-->) <li>Argument number %(num)d was %(arg)s
<!--#/if previous-sequence--> %(in args)]
<!--#if sequence-start--> </ul></dl><p>
<dl> %(if args)]
<!--#/if sequence-start--> %(else args)[
<dt><!--#var sequence-arg-->.</dt> No arguments were given.<p>
<dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd> %(else args)]
<!--#if next-sequence--> And thats da trooth.
(<!--#var next-sequence-start-arg-->-
<!--#var next-sequence-end-arg-->)
<!--#/if next-sequence-->
<!--#/in args-->
</dl>
<!--#else args-->
No arguments were given.<p>
<!--#/if args-->
And I\'m 100% sure!
</body></html> </body></html>
""" """
tal = util.read_input('DTML3.html') tal = util.read_input('DTML1.html')
self.t.write(tal) self.t.write(tal)
aa=util.argv(('one', 'two', 'three', 'four', 'five', aa=util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
'six', 'seven', 'eight', 'nine', 'ten', o=self.t.__of__(aa)()
'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', expect = util.read_output('DTML1a.html')
'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty',
)) util.check_xml(expect, o)
from Products.PageTemplates.tests import batch
o=self.t.__of__(aa)(batch=batch.batch(aa.args, 5)) aa=util.argv(())
o=self.t.__of__(aa)()
expect = util.read_output('DTML3.html') expect = util.read_output('DTML1b.html')
util.check_xml(expect, o) util.check_xml(expect, o)
def check3(self):
"""DTML test 3: batches and formatting:
<html><head><title>Test of documentation templates</title></head>
<body>
<!--#if args-->
The arguments were:
<!--#in args size=size end=end-->
<!--#if previous-sequence-->
(<!--#var previous-sequence-start-arg-->-
<!--#var previous-sequence-end-arg-->)
<!--#/if previous-sequence-->
<!--#if sequence-start-->
<dl>
<!--#/if sequence-start-->
<dt><!--#var sequence-arg-->.</dt>
<dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
<!--#if next-sequence-->
(<!--#var next-sequence-start-arg-->-
<!--#var next-sequence-end-arg-->)
<!--#/if next-sequence-->
<!--#/in args-->
</dl>
<!--#else args-->
No arguments were given.<p>
<!--#/if args-->
And I\'m 100% sure!
</body></html>
"""
tal = util.read_input('DTML3.html')
self.t.write(tal)
aa=util.argv(('one', 'two', 'three', 'four', 'five',
'six', 'seven', 'eight', 'nine', 'ten',
'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty',
))
from Products.PageTemplates.tests import batch
o=self.t.__of__(aa)(batch=batch.batch(aa.args, 5))
expect = util.read_output('DTML3.html')
util.check_xml(expect, o)
def test_suite(): def test_suite():
return unittest.makeSuite(DTMLTests, 'check') return unittest.makeSuite(DTMLTests, 'check')
if __name__=='__main__': if __name__=='__main__':
main() main()
...@@ -15,7 +15,7 @@ class ExpressionTests(unittest.TestCase): ...@@ -15,7 +15,7 @@ class ExpressionTests(unittest.TestCase):
e.compile('string:a ${x/y} b ${y/z} c') e.compile('string:a ${x/y} b ${y/z} c')
e.compile('python: 2 + 2') e.compile('python: 2 + 2')
e.compile('python: 2 \n+\n 2\n') e.compile('python: 2 \n+\n 2\n')
def test_suite(): def test_suite():
return unittest.makeSuite(ExpressionTests) return unittest.makeSuite(ExpressionTests)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os, sys, unittest import os, sys, unittest
...@@ -20,10 +20,10 @@ from AccessControl.SecurityManagement import noSecurityManager ...@@ -20,10 +20,10 @@ from AccessControl.SecurityManagement import noSecurityManager
from Acquisition import Implicit from Acquisition import Implicit
class AqPageTemplate(Implicit, PageTemplate): class AqPageTemplate(Implicit, PageTemplate):
pass pass
class Folder(util.Base): class Folder(util.Base):
pass pass
class UnitTestSecurityPolicy: class UnitTestSecurityPolicy:
...@@ -43,91 +43,90 @@ class UnitTestSecurityPolicy: ...@@ -43,91 +43,90 @@ class UnitTestSecurityPolicy:
, *args , *args
, **kw): , **kw):
return 1 return 1
def checkPermission( self, permission, object, context) : def checkPermission( self, permission, object, context) :
return 1 return 1
class HTMLTests(unittest.TestCase): class HTMLTests(unittest.TestCase):
def setUp(self): def setUp(self):
self.folder = f = Folder() self.folder = f = Folder()
f.laf = AqPageTemplate() f.laf = AqPageTemplate()
f.t = AqPageTemplate() f.t = AqPageTemplate()
self.policy = UnitTestSecurityPolicy() self.policy = UnitTestSecurityPolicy()
self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy ) self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
noSecurityManager() # Use the new policy. noSecurityManager() # Use the new policy.
def tearDown(self): def tearDown(self):
SecurityManager.setSecurityPolicy( self.oldPolicy ) SecurityManager.setSecurityPolicy( self.oldPolicy )
noSecurityManager() # Reset to old policy. noSecurityManager() # Reset to old policy.
def assert_expected(self, t, fname, *args, **kwargs): def assert_expected(self, t, fname, *args, **kwargs):
t.write(util.read_input(fname)) t.write(util.read_input(fname))
assert not t._v_errors, 'Template errors: %s' % t._v_errors assert not t._v_errors, 'Template errors: %s' % t._v_errors
expect = util.read_output(fname) expect = util.read_output(fname)
out = apply(t, args, kwargs) out = apply(t, args, kwargs)
util.check_html(expect, out) util.check_html(expect, out)
def getProducts(self): def getProducts(self):
return [ return [
{'description': 'This is the tee for those who LOVE Zope. ' {'description': 'This is the tee for those who LOVE Zope. '
'Show your heart on your tee.', 'Show your heart on your tee.',
'price': 12.99, 'image': 'smlatee.jpg' 'price': 12.99, 'image': 'smlatee.jpg'
}, },
{'description': 'This is the tee for Jim Fulton. ' {'description': 'This is the tee for Jim Fulton. '
'He\'s the Zope Pope!', 'He\'s the Zope Pope!',
'price': 11.99, 'image': 'smpztee.jpg' 'price': 11.99, 'image': 'smpztee.jpg'
}, },
] ]
def check1(self): def check1(self):
self.assert_expected(self.folder.laf, 'TeeShopLAF.html') self.assert_expected(self.folder.laf, 'TeeShopLAF.html')
def check2(self): def check2(self):
self.folder.laf.write(util.read_input('TeeShopLAF.html')) self.folder.laf.write(util.read_input('TeeShopLAF.html'))
self.assert_expected(self.folder.t, 'TeeShop2.html', self.assert_expected(self.folder.t, 'TeeShop2.html',
getProducts=self.getProducts) getProducts=self.getProducts)
def check3(self): def check3(self):
self.folder.laf.write(util.read_input('TeeShopLAF.html')) self.folder.laf.write(util.read_input('TeeShopLAF.html'))
self.assert_expected(self.folder.t, 'TeeShop1.html', self.assert_expected(self.folder.t, 'TeeShop1.html',
getProducts=self.getProducts) getProducts=self.getProducts)
def checkSimpleLoop(self): def checkSimpleLoop(self):
self.assert_expected(self.folder.t, 'Loop1.html') self.assert_expected(self.folder.t, 'Loop1.html')
def checkFancyLoop(self): def checkFancyLoop(self):
self.assert_expected(self.folder.t, 'Loop2.html') self.assert_expected(self.folder.t, 'Loop2.html')
def checkGlobalsShadowLocals(self): def checkGlobalsShadowLocals(self):
self.assert_expected(self.folder.t, 'GlobalsShadowLocals.html') self.assert_expected(self.folder.t, 'GlobalsShadowLocals.html')
def checkStringExpressions(self): def checkStringExpressions(self):
self.assert_expected(self.folder.t, 'StringExpression.html') self.assert_expected(self.folder.t, 'StringExpression.html')
def checkReplaceWithNothing(self): def checkReplaceWithNothing(self):
self.assert_expected(self.folder.t, 'CheckNothing.html') self.assert_expected(self.folder.t, 'CheckNothing.html')
def checkWithXMLHeader(self): def checkWithXMLHeader(self):
self.assert_expected(self.folder.t, 'CheckWithXMLHeader.html') self.assert_expected(self.folder.t, 'CheckWithXMLHeader.html')
def checkNotExpression(self): def checkNotExpression(self):
self.assert_expected(self.folder.t, 'CheckNotExpression.html') self.assert_expected(self.folder.t, 'CheckNotExpression.html')
def checkPathNothing(self): def checkPathNothing(self):
self.assert_expected(self.folder.t, 'CheckPathNothing.html') self.assert_expected(self.folder.t, 'CheckPathNothing.html')
def checkPathAlt(self): def checkPathAlt(self):
self.assert_expected(self.folder.t, 'CheckPathAlt.html') self.assert_expected(self.folder.t, 'CheckPathAlt.html')
def checkBatchIteration(self): def checkBatchIteration(self):
self.assert_expected(self.folder.t, 'CheckBatchIteration.html') self.assert_expected(self.folder.t, 'CheckBatchIteration.html')
def test_suite(): def test_suite():
return unittest.makeSuite(HTMLTests, 'check') return unittest.makeSuite(HTMLTests, 'check')
if __name__=='__main__': if __name__=='__main__':
main() main()
...@@ -94,7 +94,7 @@ class TALESTests(unittest.TestCase): ...@@ -94,7 +94,7 @@ class TALESTests(unittest.TestCase):
ctxt.setLocal('v2', 2) ctxt.setLocal('v2', 2)
assert c['v1'] == 1, 'Variable "v1"' assert c['v1'] == 1, 'Variable "v1"'
ctxt.beginScope() ctxt.beginScope()
ctxt.setLocal('v1', 3) ctxt.setLocal('v1', 3)
ctxt.setGlobal('g', 1) ctxt.setGlobal('g', 1)
...@@ -109,7 +109,7 @@ class TALESTests(unittest.TestCase): ...@@ -109,7 +109,7 @@ class TALESTests(unittest.TestCase):
assert c['g'] == 1, "Global from inner scope" assert c['g'] == 1, "Global from inner scope"
ctxt.endScope() ctxt.endScope()
def test_suite(): def test_suite():
return unittest.makeSuite(TALESTests) return unittest.makeSuite(TALESTests)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
###################################################################### ######################################################################
...@@ -28,15 +28,15 @@ class Bruce(Base): ...@@ -28,15 +28,15 @@ class Bruce(Base):
def items(self): return [('bruce',self)]*7 def items(self): return [('bruce',self)]*7
def __len__(self): return 7 def __len__(self): return 7
def __getitem__(self,index): def __getitem__(self,index):
if (type(index) is type(1) and if (type(index) is type(1) and
(index < 0 or index > 6)): raise IndexError, index (index < 0 or index > 6)): raise IndexError, index
return self return self
isDocTemp=0 isDocTemp=0
def __getattr__(self,name): def __getattr__(self,name):
if name[:1]=='_': raise AttributeError, name if name[:1]=='_': raise AttributeError, name
return self return self
bruce=Bruce() bruce=Bruce()
class arg(Base): class arg(Base):
__allow_access_to_unprotected_subobjects__=1 __allow_access_to_unprotected_subobjects__=1
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""$Id: DateIndex.py,v 1.6 2002/07/30 16:25:46 shane Exp $ """$Id: DateIndex.py,v 1.7 2002/08/14 22:19:27 mj Exp $
""" """
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
...@@ -99,12 +99,12 @@ class DateIndex(UnIndex): ...@@ -99,12 +99,12 @@ class DateIndex(UnIndex):
index = self._index index = self._index
r = None r = None
opr = None opr = None
#experimental code for specifing the operator #experimental code for specifing the operator
operator = record.get( 'operator', self.useOperator ) operator = record.get( 'operator', self.useOperator )
if not operator in self.operators : if not operator in self.operators :
raise RuntimeError, "operator not valid: %s" % operator raise RuntimeError, "operator not valid: %s" % operator
# depending on the operator we use intersection or union # depending on the operator we use intersection or union
if operator=="or": if operator=="or":
set_func = union set_func = union
...@@ -145,7 +145,7 @@ class DateIndex(UnIndex): ...@@ -145,7 +145,7 @@ class DateIndex(UnIndex):
#for k, set in setlist: #for k, set in setlist:
#if type(set) is IntType: #if type(set) is IntType:
#set = IISet((set,)) #set = IISet((set,))
#r = set_func(r, set) #r = set_func(r, set)
# XXX: Use multiunion! # XXX: Use multiunion!
r = multiunion(setlist) r = multiunion(setlist)
...@@ -201,4 +201,3 @@ def manage_addDateIndex( self, id, REQUEST=None, RESPONSE=None, URL3=None): ...@@ -201,4 +201,3 @@ def manage_addDateIndex( self, id, REQUEST=None, RESPONSE=None, URL3=None):
"""Add a Date index""" """Add a Date index"""
return self.manage_addIndex(id, 'DateIndex', extra=None, \ return self.manage_addIndex(id, 'DateIndex', extra=None, \
REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3) REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Zope import Zope
...@@ -71,7 +71,7 @@ class DI_Tests(unittest.TestCase): ...@@ -71,7 +71,7 @@ class DI_Tests(unittest.TestCase):
if hasattr(result, 'keys'): if hasattr(result, 'keys'):
result = result.keys() result = result.keys()
self.failUnlessEqual(used, ('date',)) self.failUnlessEqual(used, ('date',))
self.failUnlessEqual(len(result), len(expectedValues), self.failUnlessEqual(len(result), len(expectedValues),
'%s | %s' % (map(None, result), expectedValues)) '%s | %s' % (map(None, result), expectedValues))
for k, v in expectedValues: for k, v in expectedValues:
self.failUnless(k in result) self.failUnless(k in result)
...@@ -88,7 +88,7 @@ class DI_Tests(unittest.TestCase): ...@@ -88,7 +88,7 @@ class DI_Tests(unittest.TestCase):
self.failUnlessEqual(len(empty), 0) self.failUnlessEqual(len(empty), 0)
self.failUnlessEqual(len(empty.referencedObjects()), 0) self.failUnlessEqual(len(empty.referencedObjects()), 0)
self.failUnless(empty.getEntryForObject(1234) is None) self.failUnless(empty.getEntryForObject(1234) is None)
marker = [] marker = []
self.failUnless(empty.getEntryForObject(1234, marker) is marker) self.failUnless(empty.getEntryForObject(1234, marker) is marker)
...@@ -118,7 +118,7 @@ class DI_Tests(unittest.TestCase): ...@@ -118,7 +118,7 @@ class DI_Tests(unittest.TestCase):
marker = [] marker = []
self.failUnless(index.getEntryForObject(1234, marker) is marker) self.failUnless(index.getEntryForObject(1234, marker) is marker)
index.unindex_object(1234) # shouldn't throw index.unindex_object(1234) # shouldn't throw
for k, v in values: for k, v in values:
if v.date(): if v.date():
self.failUnlessEqual(self._index.getEntryForObject(k), self.failUnlessEqual(self._index.getEntryForObject(k),
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""$Id: DateRangeIndex.py,v 1.3 2002/06/26 13:37:19 caseman Exp $ """$Id: DateRangeIndex.py,v 1.4 2002/08/14 22:19:28 mj Exp $
""" """
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
...@@ -39,7 +39,7 @@ class DateRangeIndex(UnIndex): ...@@ -39,7 +39,7 @@ class DateRangeIndex(UnIndex):
start or the end date: for the start date, this should be start or the end date: for the start date, this should be
the logical equivalent of "since the beginning of time"; for the the logical equivalent of "since the beginning of time"; for the
end date, "until the end of time". end date, "until the end of time".
Therefore, divide the space of indexed objects into four containers: Therefore, divide the space of indexed objects into four containers:
- Objects which always match ( i.e., they returned None for both ); - Objects which always match ( i.e., they returned None for both );
...@@ -125,7 +125,7 @@ class DateRangeIndex(UnIndex): ...@@ -125,7 +125,7 @@ class DateRangeIndex(UnIndex):
""" """
Start over fresh. Start over fresh.
""" """
self._always = IITreeSet() self._always = IITreeSet()
self._since_only = IOBTree() self._since_only = IOBTree()
self._until_only = IOBTree() self._until_only = IOBTree()
self._since = IOBTree() self._since = IOBTree()
...@@ -137,11 +137,11 @@ class DateRangeIndex(UnIndex): ...@@ -137,11 +137,11 @@ class DateRangeIndex(UnIndex):
# #
def getEntryForObject( self, documentId, default=None ): def getEntryForObject( self, documentId, default=None ):
""" """
Get all information contained for the specific object Get all information contained for the specific object
identified by 'documentId'. Return 'default' if not found. identified by 'documentId'. Return 'default' if not found.
""" """
return self._unindex.get( documentId, default ) return self._unindex.get( documentId, default )
def index_object( self, documentId, obj, threshold=None ): def index_object( self, documentId, obj, threshold=None ):
""" """
Index an object: Index an object:
...@@ -288,7 +288,7 @@ class DateRangeIndex(UnIndex): ...@@ -288,7 +288,7 @@ class DateRangeIndex(UnIndex):
#map( since.update, self._since.values( None, term ) ) #map( since.update, self._since.values( None, term ) )
# XXX use multi-union # XXX use multi-union
since = multiunion( self._since.values( None, term ) ) since = multiunion( self._since.values( None, term ) )
bounded = intersection( until, since ) bounded = intersection( until, since )
# Merge from smallest to largest. # Merge from smallest to largest.
...@@ -381,14 +381,14 @@ class DateRangeIndex(UnIndex): ...@@ -381,14 +381,14 @@ class DateRangeIndex(UnIndex):
set = self._since.get( since, None ) set = self._since.get( since, None )
if set is not None: if set is not None:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
del self._since[ since ] del self._since[ since ]
set = self._until.get( until, None ) set = self._until.get( until, None )
if set is not None: if set is not None:
set.remove( documentId ) set.remove( documentId )
if not set: if not set:
del self._until[ until ] del self._until[ until ]
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Zope import Zope
...@@ -63,7 +63,7 @@ def matchingDummies( value ): ...@@ -63,7 +63,7 @@ def matchingDummies( value ):
return result return result
class DRI_Tests( unittest.TestCase ): class DRI_Tests( unittest.TestCase ):
def setUp( self ): def setUp( self ):
pass pass
...@@ -71,7 +71,7 @@ class DRI_Tests( unittest.TestCase ): ...@@ -71,7 +71,7 @@ class DRI_Tests( unittest.TestCase ):
pass pass
def test_empty( self ): def test_empty( self ):
empty = DateRangeIndex( 'empty' ) empty = DateRangeIndex( 'empty' )
assert empty.getEntryForObject( 1234 ) is None assert empty.getEntryForObject( 1234 ) is None
......
############################################################################# #############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # This software is subject to the provisions of the Zope Public License,
...@@ -8,15 +8,15 @@ ...@@ -8,15 +8,15 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Simple column indices """Simple column indices
$Id: FieldIndex.py,v 1.9 2002/06/20 20:00:34 jeremy Exp $ $Id: FieldIndex.py,v 1.10 2002/08/14 22:19:29 mj Exp $
""" """
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.UnIndex import UnIndex from Products.PluginIndexes.common.UnIndex import UnIndex
from Globals import DTMLFile from Globals import DTMLFile
...@@ -29,7 +29,7 @@ class FieldIndex(UnIndex): ...@@ -29,7 +29,7 @@ class FieldIndex(UnIndex):
meta_type="FieldIndex" meta_type="FieldIndex"
manage_options= ( manage_options= (
{'label': 'Settings', {'label': 'Settings',
'action': 'manage_main', 'action': 'manage_main',
'help': ('FieldIndex','FieldIndex_Settings.stx')}, 'help': ('FieldIndex','FieldIndex_Settings.stx')},
) )
...@@ -47,4 +47,3 @@ def manage_addFieldIndex(self, id, REQUEST=None, RESPONSE=None, URL3=None): ...@@ -47,4 +47,3 @@ def manage_addFieldIndex(self, id, REQUEST=None, RESPONSE=None, URL3=None):
"""Add a field index""" """Add a field index"""
return self.manage_addIndex(id, 'FieldIndex', extra=None, \ return self.manage_addIndex(id, 'FieldIndex', extra=None, \
REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3) REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os, sys, unittest import os, sys, unittest
...@@ -26,7 +26,7 @@ class Dummy: ...@@ -26,7 +26,7 @@ class Dummy:
def __str__( self ): def __str__( self ):
return '<Dummy: %s>' % self._foo return '<Dummy: %s>' % self._foo
__repr__ = __str__ __repr__ = __str__
class TestCase( unittest.TestCase ): class TestCase( unittest.TestCase ):
...@@ -54,7 +54,7 @@ class TestCase( unittest.TestCase ): ...@@ -54,7 +54,7 @@ class TestCase( unittest.TestCase ):
self._backward[k] = v self._backward[k] = v
keys = self._forward.get( v, [] ) keys = self._forward.get( v, [] )
self._forward[v] = keys self._forward[v] = keys
self._noop_req = { 'bar': 123 } self._noop_req = { 'bar': 123 }
self._request = { 'foo': 'abce' } self._request = { 'foo': 'abce' }
self._min_req = { 'foo': 'abc' self._min_req = { 'foo': 'abc'
...@@ -77,7 +77,7 @@ class TestCase( unittest.TestCase ): ...@@ -77,7 +77,7 @@ class TestCase( unittest.TestCase ):
def _populateIndex( self ): def _populateIndex( self ):
for k, v in self._values: for k, v in self._values:
self._index.index_object( k, v ) self._index.index_object( k, v )
def _checkApply( self, req, expectedValues ): def _checkApply( self, req, expectedValues ):
result, used = self._index._apply_index( req ) result, used = self._index._apply_index( req )
if hasattr(result, 'keys'): if hasattr(result, 'keys'):
...@@ -87,7 +87,7 @@ class TestCase( unittest.TestCase ): ...@@ -87,7 +87,7 @@ class TestCase( unittest.TestCase ):
'%s | %s' % ( map( None, result ), expectedValues ) '%s | %s' % ( map( None, result ), expectedValues )
for k, v in expectedValues: for k, v in expectedValues:
assert k in result assert k in result
def testEmpty( self ): def testEmpty( self ):
"Test an empty FieldIndex." "Test an empty FieldIndex."
...@@ -108,7 +108,7 @@ class TestCase( unittest.TestCase ): ...@@ -108,7 +108,7 @@ class TestCase( unittest.TestCase ):
self._checkApply( self._min_req, [] ) self._checkApply( self._min_req, [] )
self._checkApply( self._max_req, [] ) self._checkApply( self._max_req, [] )
self._checkApply( self._range_req, [] ) self._checkApply( self._range_req, [] )
def testPopulated( self ): def testPopulated( self ):
""" Test a populated FieldIndex """ """ Test a populated FieldIndex """
self._populateIndex() self._populateIndex()
...@@ -170,7 +170,7 @@ class TestCase( unittest.TestCase ): ...@@ -170,7 +170,7 @@ class TestCase( unittest.TestCase ):
else: else:
# before Collector #291 this would be 'world' # before Collector #291 this would be 'world'
raise ValueError(repr(should_not_be)) raise ValueError(repr(should_not_be))
def testRange(self): def testRange(self):
"""Test a range search""" """Test a range search"""
index = FieldIndex( 'foo' ) index = FieldIndex( 'foo' )
...@@ -191,8 +191,8 @@ class TestCase( unittest.TestCase ): ...@@ -191,8 +191,8 @@ class TestCase( unittest.TestCase ):
40, 41, 42, 43, 50, 51, 52, 53, 60, 61, 62, 63, 70, 71, 72, 73, 40, 41, 42, 43, 50, 51, 52, 53, 60, 61, 62, 63, 70, 71, 72, 73,
80, 81, 82, 83, 90, 91, 92, 93 80, 81, 82, 83, 90, 91, 92, 93
] ]
assert r==expect, r assert r==expect, r
# #
# Make sure that range tests with incompatible paramters # Make sure that range tests with incompatible paramters
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
from BTrees.OOBTree import OOSet, difference from BTrees.OOBTree import OOSet, difference
from Globals import DTMLFile from Globals import DTMLFile
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.UnIndex import UnIndex from Products.PluginIndexes.common.UnIndex import UnIndex
class KeywordIndex(UnIndex): class KeywordIndex(UnIndex):
...@@ -26,16 +26,16 @@ class KeywordIndex(UnIndex): ...@@ -26,16 +26,16 @@ class KeywordIndex(UnIndex):
meta_type="KeywordIndex" meta_type="KeywordIndex"
manage_options= ( manage_options= (
{'label': 'Settings', {'label': 'Settings',
'action': 'manage_main', 'action': 'manage_main',
'help': ('KeywordIndex','KeywordIndex_Settings.stx')}, 'help': ('KeywordIndex','KeywordIndex_Settings.stx')},
) )
query_options = ["query","operator"] query_options = ["query","operator"]
"""Like an UnIndex only it indexes sequences of items """Like an UnIndex only it indexes sequences of items
Searches match any keyword. Searches match any keyword.
This should have an _apply_index that returns a relevance score This should have an _apply_index that returns a relevance score
...@@ -91,7 +91,7 @@ class KeywordIndex(UnIndex): ...@@ -91,7 +91,7 @@ class KeywordIndex(UnIndex):
if hasattr(newKeywords,'capitalize'): # is it string-like ? if hasattr(newKeywords,'capitalize'): # is it string-like ?
newKeywords = (newKeywords, ) newKeywords = (newKeywords, )
return newKeywords return newKeywords
def unindex_objectKeywords(self, documentId, keywords): def unindex_objectKeywords(self, documentId, keywords):
""" carefully unindex the object with integer id 'documentId'""" """ carefully unindex the object with integer id 'documentId'"""
...@@ -122,4 +122,3 @@ def manage_addKeywordIndex(self, id, REQUEST=None, RESPONSE=None, URL3=None): ...@@ -122,4 +122,3 @@ def manage_addKeywordIndex(self, id, REQUEST=None, RESPONSE=None, URL3=None):
"""Add a keyword index""" """Add a keyword index"""
return self.manage_addIndex(id, 'KeywordIndex', extra=None, \ return self.manage_addIndex(id, 'KeywordIndex', extra=None, \
REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3) REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL3)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os, sys, unittest, zLOG import os, sys, unittest, zLOG
...@@ -21,10 +21,10 @@ class Dummy: ...@@ -21,10 +21,10 @@ class Dummy:
def foo( self ): def foo( self ):
return self._foo return self._foo
def __str__( self ): def __str__( self ):
return '<Dummy: %s>' % self._foo return '<Dummy: %s>' % self._foo
__repr__ = __str__ __repr__ = __str__
class TestCase( unittest.TestCase ): class TestCase( unittest.TestCase ):
...@@ -45,7 +45,7 @@ class TestCase( unittest.TestCase ): ...@@ -45,7 +45,7 @@ class TestCase( unittest.TestCase ):
, ( 4, Dummy( ['a', 'b', 'c', 'd'] ) ) , ( 4, Dummy( ['a', 'b', 'c', 'd'] ) )
, ( 5, Dummy( ['a', 'b', 'c', 'e'] ) ) , ( 5, Dummy( ['a', 'b', 'c', 'e'] ) )
, ( 6, Dummy( ['a', 'b', 'c', 'e', 'f'] )) , ( 6, Dummy( ['a', 'b', 'c', 'e', 'f'] ))
, ( 7, Dummy( [0] ) ) , ( 7, Dummy( [0] ) )
] ]
self._noop_req = { 'bar': 123 } self._noop_req = { 'bar': 123 }
self._all_req = { 'foo': ['a'] } self._all_req = { 'foo': ['a'] }
...@@ -102,7 +102,7 @@ class TestCase( unittest.TestCase ): ...@@ -102,7 +102,7 @@ class TestCase( unittest.TestCase ):
self._index.index_object(999, None) self._index.index_object(999, None)
finally: finally:
self._ignore_log_errors() self._ignore_log_errors()
def testEmpty( self ): def testEmpty( self ):
assert len( self._index ) == 0 assert len( self._index ) == 0
assert len( self._index.referencedObjects() ) == 0 assert len( self._index.referencedObjects() ) == 0
...@@ -121,7 +121,7 @@ class TestCase( unittest.TestCase ): ...@@ -121,7 +121,7 @@ class TestCase( unittest.TestCase ):
self._checkApply( self._some_req, [] ) self._checkApply( self._some_req, [] )
self._checkApply( self._overlap_req, [] ) self._checkApply( self._overlap_req, [] )
self._checkApply( self._string_req, [] ) self._checkApply( self._string_req, [] )
def testPopulated( self ): def testPopulated( self ):
self._populateIndex() self._populateIndex()
values = self._values values = self._values
...@@ -166,7 +166,7 @@ class TestCase( unittest.TestCase ): ...@@ -166,7 +166,7 @@ class TestCase( unittest.TestCase ):
) )
result = result.keys() result = result.keys()
assert 6 not in result assert 6 not in result
def testReindexNoChange(self): def testReindexNoChange(self):
self._populateIndex() self._populateIndex()
expected = Dummy(['foo', 'bar']) expected = Dummy(['foo', 'bar'])
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__version__ = '$Id: PathIndex.py,v 1.24 2002/06/20 20:07:20 jeremy Exp $' __version__ = '$Id: PathIndex.py,v 1.25 2002/08/14 22:19:31 mj Exp $'
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest from Products.PluginIndexes.common.util import parseIndexRequest
from Globals import Persistent, DTMLFile from Globals import Persistent, DTMLFile
...@@ -29,26 +29,26 @@ import re, warnings ...@@ -29,26 +29,26 @@ import re, warnings
_marker = [] _marker = []
class PathIndex(Persistent, Implicit, SimpleItem): class PathIndex(Persistent, Implicit, SimpleItem):
""" A path index stores all path components of the physical """ A path index stores all path components of the physical
path of an object: path of an object:
Internal datastructure: Internal datastructure:
- a physical path of an object is split into its components - a physical path of an object is split into its components
- every component is kept as a key of a OOBTree in self._indexes - every component is kept as a key of a OOBTree in self._indexes
- the value is a mapping 'level of the path component' to - the value is a mapping 'level of the path component' to
'all documentIds with this path component on this level' 'all documentIds with this path component on this level'
""" """
__implements__ = (PluggableIndex.PluggableIndexInterface,) __implements__ = (PluggableIndex.PluggableIndexInterface,)
meta_type="PathIndex" meta_type="PathIndex"
manage_options= ( manage_options= (
{'label': 'Settings', {'label': 'Settings',
'action': 'manage_main', 'action': 'manage_main',
'help': ('PathIndex','PathIndex_Settings.stx')}, 'help': ('PathIndex','PathIndex_Settings.stx')},
) )
...@@ -60,24 +60,24 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -60,24 +60,24 @@ class PathIndex(Persistent, Implicit, SimpleItem):
self.id = id self.id = id
# experimental code for specifing the operator # experimental code for specifing the operator
self.operators = ['or','and'] self.operators = ['or','and']
self.useOperator = 'or' self.useOperator = 'or'
self.clear() self.clear()
def getId(self): return self.id def getId(self): return self.id
def clear(self): def clear(self):
""" clear everything """ """ clear everything """
self._depth = 0 self._depth = 0
self._index = OOBTree() self._index = OOBTree()
self._unindex = IOBTree() self._unindex = IOBTree()
def insertEntry(self,comp,id,level): def insertEntry(self,comp,id,level):
""" """
k is a path component (generated by splitPath() ) k is a path component (generated by splitPath() )
v is the documentId v is the documentId
level is the level of the component inside the path level is the level of the component inside the path
...@@ -90,10 +90,10 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -90,10 +90,10 @@ class PathIndex(Persistent, Implicit, SimpleItem):
self._index[comp][level] = IISet() self._index[comp][level] = IISet()
self._index[comp][level].insert(id) self._index[comp][level].insert(id)
if level > self._depth: self._depth = level if level > self._depth: self._depth = level
def index_object(self, documentId, obj ,threshold=100): def index_object(self, documentId, obj ,threshold=100):
""" hook for (Z)Catalog """ """ hook for (Z)Catalog """
...@@ -110,11 +110,11 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -110,11 +110,11 @@ class PathIndex(Persistent, Implicit, SimpleItem):
except: except:
return 0 return 0
if not (isinstance(path,StringType) or if not (isinstance(path,StringType) or
isinstance(path,TupleType)): isinstance(path,TupleType)):
raise TypeError, "attribute/method must be/return string or tuple" raise TypeError, "attribute/method must be/return string or tuple"
else: else:
try: try:
path = obj.getPhysicalPath() path = obj.getPhysicalPath()
...@@ -148,7 +148,7 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -148,7 +148,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
for level in range(len(comps[1:])-1): for level in range(len(comps[1:])-1):
comp = comps[level+1] comp = comps[level+1]
self._index[comp][level].remove(documentId) self._index[comp][level].remove(documentId)
if len(self._index[comp][level])==0: if len(self._index[comp][level])==0:
...@@ -167,8 +167,8 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -167,8 +167,8 @@ class PathIndex(Persistent, Implicit, SimpleItem):
for k1,v1 in v.items(): for k1,v1 in v.items():
print k1,v1, print k1,v1,
print print
def splitPath(self,path,obj=None): def splitPath(self,path,obj=None):
""" split physical path of object. If the object has """ split physical path of object. If the object has
...@@ -192,7 +192,7 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -192,7 +192,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
level>=0 starts searching at the given level level>=0 starts searching at the given level
level<0 not implemented yet level<0 not implemented yet
""" """
if isinstance(path,StringType): if isinstance(path,StringType):
level = default_level level = default_level
...@@ -201,13 +201,13 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -201,13 +201,13 @@ class PathIndex(Persistent, Implicit, SimpleItem):
path = path[0] path = path[0]
comps = self.splitPath(path) comps = self.splitPath(path)
if level >=0: if level >=0:
results = [] results = []
for i in range(len(comps)): for i in range(len(comps)):
comp = comps[i] comp = comps[i]
if not self._index.has_key(comp): return IISet() if not self._index.has_key(comp): return IISet()
...@@ -227,19 +227,19 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -227,19 +227,19 @@ class PathIndex(Persistent, Implicit, SimpleItem):
results = IISet() results = IISet()
for level in range(0,self._depth): for level in range(0,self._depth):
ids = None ids = None
error = 0 error = 0
for cn in range(0,len(comps)): for cn in range(0,len(comps)):
comp = comps[cn] comp = comps[cn]
try: try:
ids = intersection(ids,self._index[comp][level+cn]) ids = intersection(ids,self._index[comp][level+cn])
except: except:
error = 1 error = 1
if error==0: if error==0:
results = union(results,ids) results = union(results,ids)
return results return results
...@@ -256,20 +256,20 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -256,20 +256,20 @@ class PathIndex(Persistent, Implicit, SimpleItem):
return len(self._unindex) return len(self._unindex)
def keys(self): def keys(self):
""" return list of all path components """ """ return list of all path components """
keys = [] keys = []
for k in self._index.keys(): keys.append(k) for k in self._index.keys(): keys.append(k)
return keys return keys
def values(self): def values(self):
values = [] values = []
for k in self._index.values(): values.append(k) for k in self._index.values(): values.append(k)
return values return values
def items(self): def items(self):
""" mapping path components : documentIds """ """ mapping path components : documentIds """
items = [] items = []
...@@ -277,7 +277,7 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -277,7 +277,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
return items return items
def _apply_index(self, request, cid=''): def _apply_index(self, request, cid=''):
""" hook for (Z)Catalog """ hook for (Z)Catalog
request mapping type (usually {"path": "..." } request mapping type (usually {"path": "..." }
additionaly a parameter "path_level" might be passed additionaly a parameter "path_level" might be passed
...@@ -296,7 +296,7 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -296,7 +296,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
"'level' key to specify the operator." % cid) "'level' key to specify the operator." % cid)
# get the level parameter # get the level parameter
level = record.get("level",0) level = record.get("level",0)
# experimental code for specifing the operator # experimental code for specifing the operator
...@@ -314,10 +314,10 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -314,10 +314,10 @@ class PathIndex(Persistent, Implicit, SimpleItem):
if res: if res:
return res, (self.id,) return res, (self.id,)
else: else:
return IISet(), (self.id,) return IISet(), (self.id,)
def uniqueValues(self,name=None,withLength=0): def uniqueValues(self,name=None,withLength=0):
""" needed to be consistent with the interface """ """ needed to be consistent with the interface """
...@@ -328,11 +328,11 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -328,11 +328,11 @@ class PathIndex(Persistent, Implicit, SimpleItem):
""" Takes a document ID and returns all the information we have """ Takes a document ID and returns all the information we have
on that specific object. """ on that specific object. """
try: try:
return self._unindex[documentId] return self._unindex[documentId]
except: except:
return None return None
index_html = DTMLFile('dtml/index', globals()) index_html = DTMLFile('dtml/index', globals())
manage_workspace = DTMLFile('dtml/managePathIndex', globals()) manage_workspace = DTMLFile('dtml/managePathIndex', globals())
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os, sys, unittest import os, sys, unittest
...@@ -25,10 +25,10 @@ class Dummy: ...@@ -25,10 +25,10 @@ class Dummy:
def getPhysicalPath(self): def getPhysicalPath(self):
return self.path.split('/') return self.path.split('/')
def __str__( self ): def __str__( self ):
return '<Dummy: %s>' % self.path return '<Dummy: %s>' % self.path
__repr__ = __str__ __repr__ = __str__
class TestCase( unittest.TestCase ): class TestCase( unittest.TestCase ):
...@@ -78,11 +78,11 @@ class TestCase( unittest.TestCase ): ...@@ -78,11 +78,11 @@ class TestCase( unittest.TestCase ):
assert len(self._index._index)==0 assert len(self._index._index)==0
assert len(self._index._unindex)==0 assert len(self._index._unindex)==0
def testSimpleTests(self): def testSimpleTests(self):
self._populateIndex() self._populateIndex()
tests = [ tests = [
("aa",0, [1,2,3,4,5,6,7,8,9]), ("aa",0, [1,2,3,4,5,6,7,8,9]),
("aa",1, [1,2,3,10,11,12] ), ("aa",1, [1,2,3,10,11,12] ),
...@@ -109,11 +109,11 @@ class TestCase( unittest.TestCase ): ...@@ -109,11 +109,11 @@ class TestCase( unittest.TestCase ):
{"path":{'query':( (path,level),)}}) {"path":{'query':( (path,level),)}})
lst = list(res[0].keys()) lst = list(res[0].keys())
self.assertEqual(lst,results) self.assertEqual(lst,results)
def testComplexOrTests(self): def testComplexOrTests(self):
self._populateIndex() self._populateIndex()
tests = [ tests = [
(['aa','bb'],1,[1,2,3,4,5,6,10,11,12,13,14,15]), (['aa','bb'],1,[1,2,3,4,5,6,10,11,12,13,14,15]),
(['aa','bb','xx'],1,[1,2,3,4,5,6,10,11,12,13,14,15]), (['aa','bb','xx'],1,[1,2,3,4,5,6,10,11,12,13,14,15]),
...@@ -130,7 +130,7 @@ class TestCase( unittest.TestCase ): ...@@ -130,7 +130,7 @@ class TestCase( unittest.TestCase ):
def testComplexANDTests(self): def testComplexANDTests(self):
self._populateIndex() self._populateIndex()
tests = [ tests = [
(['aa','bb'],1,[]), (['aa','bb'],1,[]),
([('aa',0),('bb',1)],0,[4,5,6]), ([('aa',0),('bb',1)],0,[4,5,6]),
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # This software is subject to the provisions of the Zope Public License,
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################# #############################################################################
from Lexicon import Lexicon from Lexicon import Lexicon
...@@ -25,7 +25,7 @@ from BTrees.OOBTree import OOBTree ...@@ -25,7 +25,7 @@ from BTrees.OOBTree import OOBTree
from Products.PluginIndexes.TextIndex.TextIndex import Or,Op from Products.PluginIndexes.TextIndex.TextIndex import Or,Op
from Products.PluginIndexes.common.randid import randid from Products.PluginIndexes.common.randid import randid
from types import UnicodeType from types import UnicodeType
class GlobbingLexicon(Lexicon): class GlobbingLexicon(Lexicon):
"""Lexicon which supports basic globbing function ('*' and '?'). """Lexicon which supports basic globbing function ('*' and '?').
...@@ -80,11 +80,11 @@ class GlobbingLexicon(Lexicon): ...@@ -80,11 +80,11 @@ class GlobbingLexicon(Lexicon):
def createDigrams(self, word): def createDigrams(self, word):
"""Returns a list with the set of digrams in the word.""" """Returns a list with the set of digrams in the word."""
word = '$'+word+'$' word = '$'+word+'$'
return [ word[i:i+2] for i in range(len(word)-1)] return [ word[i:i+2] for i in range(len(word)-1)]
def getWordId(self, word): def getWordId(self, word):
"""Provided 'word', return the matching integer word id.""" """Provided 'word', return the matching integer word id."""
...@@ -112,7 +112,7 @@ class GlobbingLexicon(Lexicon): ...@@ -112,7 +112,7 @@ class GlobbingLexicon(Lexicon):
try: insert=inverse.insert try: insert=inverse.insert
except AttributeError: except AttributeError:
# we have an "old" BTree object # we have an "old" BTree object
if inverse: if inverse:
wid=inverse.keys()[-1]+1 wid=inverse.keys()[-1]+1
else: else:
self._inverseLex=IOBTree() self._inverseLex=IOBTree()
...@@ -135,7 +135,7 @@ class GlobbingLexicon(Lexicon): ...@@ -135,7 +135,7 @@ class GlobbingLexicon(Lexicon):
return wid return wid
def get(self, pattern): def get(self, pattern):
""" Query the lexicon for words matching a pattern.""" """ Query the lexicon for words matching a pattern."""
...@@ -170,7 +170,7 @@ class GlobbingLexicon(Lexicon): ...@@ -170,7 +170,7 @@ class GlobbingLexicon(Lexicon):
if result is None: if result is None:
return () return ()
return (result, ) return (result, )
## now get all of the intsets that contain the result digrams ## now get all of the intsets that contain the result digrams
result = None result = None
for digram in digrams: for digram in digrams:
...@@ -194,7 +194,7 @@ class GlobbingLexicon(Lexicon): ...@@ -194,7 +194,7 @@ class GlobbingLexicon(Lexicon):
hits.insert(x) hits.insert(x)
return hits return hits
def __getitem__(self, word): def __getitem__(self, word):
""" """ """ """
return self.get(word) return self.get(word)
...@@ -235,8 +235,8 @@ class GlobbingLexicon(Lexicon): ...@@ -235,8 +235,8 @@ class GlobbingLexicon(Lexicon):
try: try:
return self.SplitterFunc( return self.SplitterFunc(
astring, astring,
words, words,
encoding=encoding, encoding=encoding,
singlechar=self.splitterParams.splitterSingleChars, singlechar=self.splitterParams.splitterSingleChars,
indexnumbers=self.splitterParams.splitterIndexNumbers, indexnumbers=self.splitterParams.splitterIndexNumbers,
...@@ -269,5 +269,4 @@ class GlobbingLexicon(Lexicon): ...@@ -269,5 +269,4 @@ class GlobbingLexicon(Lexicon):
# Next, we need to deal with single-character globbing # Next, we need to deal with single-character globbing
result = result.replace( '?', '.') result = result.replace( '?', '.')
return "%s$" % result return "%s$" % result
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__=""" Module breaks out Zope specific methods and behavior. In __doc__=""" Module breaks out Zope specific methods and behavior. In
...@@ -48,7 +48,7 @@ class Lexicon(Persistent, Implicit): ...@@ -48,7 +48,7 @@ class Lexicon(Persistent, Implicit):
self.stop_syn = {} self.stop_syn = {}
else: else:
self.stop_syn = stop_syn self.stop_syn = stop_syn
self.useSplitter = Splitter.splitterNames[0] self.useSplitter = Splitter.splitterNames[0]
if useSplitter: self.useSplitter=useSplitter if useSplitter: self.useSplitter=useSplitter
self.splitterParams = extra self.splitterParams = extra
...@@ -58,7 +58,7 @@ class Lexicon(Persistent, Implicit): ...@@ -58,7 +58,7 @@ class Lexicon(Persistent, Implicit):
def clear(self): def clear(self):
self._lexicon = OIBTree() self._lexicon = OIBTree()
self._inverseLex = IOBTree() self._inverseLex = IOBTree()
def _convertBTrees(self, threshold=200): def _convertBTrees(self, threshold=200):
if (type(self._lexicon) is OIBTree and if (type(self._lexicon) is OIBTree and
type(getattr(self, '_inverseLex', None)) is IOBTree): type(getattr(self, '_inverseLex', None)) is IOBTree):
...@@ -81,7 +81,7 @@ class Lexicon(Persistent, Implicit): ...@@ -81,7 +81,7 @@ class Lexicon(Persistent, Implicit):
self._inverseLex._p_jar=self._p_jar self._inverseLex._p_jar=self._p_jar
convert(inverseLex, self._inverseLex, threshold) convert(inverseLex, self._inverseLex, threshold)
def set_stop_syn(self, stop_syn): def set_stop_syn(self, stop_syn):
""" pass in a mapping of stopwords and synonyms. Format is: """ pass in a mapping of stopwords and synonyms. Format is:
...@@ -92,22 +92,22 @@ class Lexicon(Persistent, Implicit): ...@@ -92,22 +92,22 @@ class Lexicon(Persistent, Implicit):
""" """
self.stop_syn = stop_syn self.stop_syn = stop_syn
def getWordId(self, word): def getWordId(self, word):
""" return the word id of 'word' """ """ return the word id of 'word' """
wid=self._lexicon.get(word, None) wid=self._lexicon.get(word, None)
if wid is None: if wid is None:
wid=self.assignWordId(word) wid=self.assignWordId(word)
return wid return wid
set = getWordId set = getWordId
def getWord(self, wid): def getWord(self, wid):
""" post-2.3.1b2 method, will not work with unconverted lexicons """ """ post-2.3.1b2 method, will not work with unconverted lexicons """
return self._inverseLex.get(wid, None) return self._inverseLex.get(wid, None)
def assignWordId(self, word): def assignWordId(self, word):
"""Assigns a new word id to the provided word and returns it.""" """Assigns a new word id to the provided word and returns it."""
# First make sure it's not already in there # First make sure it's not already in there
...@@ -126,11 +126,11 @@ class Lexicon(Persistent, Implicit): ...@@ -126,11 +126,11 @@ class Lexicon(Persistent, Implicit):
while not inverse.insert(wid, word): while not inverse.insert(wid, word):
wid=randid() wid=randid()
if isinstance(word,StringType): if isinstance(word,StringType):
self._lexicon[intern(word)] = wid self._lexicon[intern(word)] = wid
else: else:
self._lexicon[word] = wid self._lexicon[word] = wid
return wid return wid
...@@ -156,8 +156,8 @@ class Lexicon(Persistent, Implicit): ...@@ -156,8 +156,8 @@ class Lexicon(Persistent, Implicit):
try: try:
return self.SplitterFunc( return self.SplitterFunc(
astring, astring,
words, words,
encoding=encoding, encoding=encoding,
singlechar=self.splitterParams.splitterSingleChars, singlechar=self.splitterParams.splitterSingleChars,
indexnumbers=self.splitterParams.splitterIndexNumbers, indexnumbers=self.splitterParams.splitterIndexNumbers,
...@@ -218,4 +218,3 @@ stop_words=( ...@@ -218,4 +218,3 @@ stop_words=(
) )
stop_word_dict={} stop_word_dict={}
for word in stop_words: stop_word_dict[word]=None for word in stop_words: stop_word_dict[word]=None
...@@ -18,7 +18,7 @@ class UnicodeSplitterTests(unittest.TestCase): ...@@ -18,7 +18,7 @@ class UnicodeSplitterTests(unittest.TestCase):
def testSimpleSplit(self): def testSimpleSplit(self):
""" testing splitter functionality """ """ testing splitter functionality """
for t,expected in self.testdata: for t,expected in self.testdata:
fields = list(UnicodeSplitter(t)) fields = list(UnicodeSplitter(t))
...@@ -38,7 +38,7 @@ class UnicodeSplitterTests(unittest.TestCase): ...@@ -38,7 +38,7 @@ class UnicodeSplitterTests(unittest.TestCase):
fields = list(splitter) fields = list(splitter)
self.assertEquals(fields, expected) self.assertEquals(fields, expected)
self.assertEquals(splitter.indexes('jumps'), [3]) self.assertEquals(splitter.indexes('jumps'), [3])
def test_suite(): def test_suite():
return unittest.makeSuite(UnicodeSplitterTests) return unittest.makeSuite(UnicodeSplitterTests)
...@@ -54,7 +54,7 @@ def main(): ...@@ -54,7 +54,7 @@ def main():
unittest.TextTestRunner().run( test_suite() ) unittest.TextTestRunner().run( test_suite() )
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1: if len(sys.argv) > 1:
globals()[sys.argv[1]]() globals()[sys.argv[1]]()
else: else:
main() main()
from ZopeSplitter import ZopeSplitter from ZopeSplitter import ZopeSplitter
def Splitter(txt,stopwords={},encoding="latin1"): def Splitter(txt,stopwords={},encoding="latin1"):
return ZopeSplitter(txt,stopwords) return ZopeSplitter(txt,stopwords)
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # This software is subject to the provisions of the Zope Public License,
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################# #############################################################################
import os,sys,exceptions import os,sys,exceptions
...@@ -26,11 +26,8 @@ def getSplitter(name=None): ...@@ -26,11 +26,8 @@ def getSplitter(name=None):
if not name in splitterNames and name: if not name in splitterNames and name:
raise exceptions.RuntimeError, "No such splitter '%s'" % name raise exceptions.RuntimeError, "No such splitter '%s'" % name
if not name: name = splitterNames[0] if not name: name = splitterNames[0]
if not vars().has_key(name): if not vars().has_key(name):
exec( "from %s.%s import %s" % (name,name,name)) exec( "from %s.%s import %s" % (name,name,name))
return vars()[name] return vars()[name]
#!/usr/bin/env python #!/usr/bin/env python
from distutils.core import setup,Extension from distutils.core import setup,Extension
import os,exceptions,commands,sys import os,exceptions,commands,sys
CFLAGS = [] CFLAGS = []
...@@ -14,7 +14,7 @@ setup (name = "Splitter", ...@@ -14,7 +14,7 @@ setup (name = "Splitter",
description = "Splitters for Zope 2.5", description = "Splitters for Zope 2.5",
author = "Andreas Jung", author = "Andreas Jung",
author_email = "andreas@zope.com", author_email = "andreas@zope.com",
url = "http://www.zope.org/...", url = "http://www.zope.org/...",
ext_modules=[ ext_modules=[
Extension("ZopeSplitter",['ZopeSplitter/src/ZopeSplitter.c']), \ Extension("ZopeSplitter",['ZopeSplitter/src/ZopeSplitter.c']), \
Extension("ISO_8859_1_Splitter",['ISO_8859_1_Splitter/src/ISO_8859_1_Splitter.c']), \ Extension("ISO_8859_1_Splitter",['ISO_8859_1_Splitter/src/ISO_8859_1_Splitter.c']), \
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""ZCatalog product""" """ZCatalog product"""
...@@ -50,7 +50,7 @@ class Vocabulary(Item, Persistent, Implicit, ...@@ -50,7 +50,7 @@ class Vocabulary(Item, Persistent, Implicit,
meta_type = "Vocabulary" meta_type = "Vocabulary"
_isAVocabulary = 1 _isAVocabulary = 1
manage_options=( manage_options=(
( (
{'label': 'Vocabulary', 'action': 'manage_main', {'label': 'Vocabulary', 'action': 'manage_main',
...@@ -65,15 +65,15 @@ class Vocabulary(Item, Persistent, Implicit, ...@@ -65,15 +65,15 @@ class Vocabulary(Item, Persistent, Implicit,
__ac_permissions__=( __ac_permissions__=(
('Manage Vocabulary', ('Manage Vocabulary',
['manage_main', 'manage_vocab', 'manage_query'], ['manage_main', 'manage_vocab', 'manage_query'],
['Manager']), ['Manager']),
('Query Vocabulary', ('Query Vocabulary',
['query',], ['query',],
['Anonymous', 'Manager']), ['Anonymous', 'Manager']),
) )
manage_main = DTMLFile('dtml/manage_vocab', globals()) manage_main = DTMLFile('dtml/manage_vocab', globals())
manage_query = DTMLFile('dtml/vocab_query', globals()) manage_query = DTMLFile('dtml/vocab_query', globals())
...@@ -84,7 +84,7 @@ class Vocabulary(Item, Persistent, Implicit, ...@@ -84,7 +84,7 @@ class Vocabulary(Item, Persistent, Implicit,
self.title = title self.title = title
self.globbing = not not globbing self.globbing = not not globbing
self.useSplitter = Splitter.splitterNames[0] self.useSplitter = Splitter.splitterNames[0]
if splitter: if splitter:
self.useSplitter = splitter self.useSplitter = splitter
...@@ -114,7 +114,7 @@ class Vocabulary(Item, Persistent, Implicit, ...@@ -114,7 +114,7 @@ class Vocabulary(Item, Persistent, Implicit,
result.append(pattern) result.append(pattern)
return str(result) return str(result)
def manage_insert(self, word='', URL1=None, RESPONSE=None): def manage_insert(self, word='', URL1=None, RESPONSE=None):
""" doc string """ """ doc string """
...@@ -131,4 +131,3 @@ class Vocabulary(Item, Persistent, Implicit, ...@@ -131,4 +131,3 @@ class Vocabulary(Item, Persistent, Implicit,
def words(self): def words(self):
return self.lexicon._lexicon.items() return self.lexicon._lexicon.items()
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import os,sys import os,sys
...@@ -29,7 +29,7 @@ class TestCase( unittest.TestCase ): ...@@ -29,7 +29,7 @@ class TestCase( unittest.TestCase ):
( 'fters sterreichische herber berfall da rger verrgert', ( 'fters sterreichische herber berfall da rger verrgert',
['fters','sterreichische','herber','berfall','da','rger','verrgert']) ['fters','sterreichische','herber','berfall','da','rger','verrgert'])
) )
pass pass
...@@ -37,22 +37,22 @@ class TestCase( unittest.TestCase ): ...@@ -37,22 +37,22 @@ class TestCase( unittest.TestCase ):
""" """
""" """
def testAvailableSplitters( self ): def testAvailableSplitters( self ):
"Test available splitters" "Test available splitters"
assert len(Splitter.availableSplitters) >0 assert len(Splitter.availableSplitters) >0
assert len(Splitter.splitterNames)>0 assert len(Splitter.splitterNames)>0
assert len(Splitter.availableSplitters)==len(Splitter.splitterNames) assert len(Splitter.availableSplitters)==len(Splitter.splitterNames)
def _test(self,sp_name,text,splitted): def _test(self,sp_name,text,splitted):
splitter = Splitter.getSplitter(sp_name) splitter = Splitter.getSplitter(sp_name)
result = list(splitter(text)) result = list(splitter(text))
assert result==splitted, "%s: %s vs %s" % (sp_name,result,splitted) assert result==splitted, "%s: %s vs %s" % (sp_name,result,splitted)
# def testZopeSplitter(self): # def testZopeSplitter(self):
...@@ -60,7 +60,7 @@ class TestCase( unittest.TestCase ): ...@@ -60,7 +60,7 @@ class TestCase( unittest.TestCase ):
# #
# for text,splitted in self.testdata: # for text,splitted in self.testdata:
# self._test("ZopeSplitter",text,splitted) # self._test("ZopeSplitter",text,splitted)
def testISOSplitter(self): def testISOSplitter(self):
"""test ISOSplitter""" """test ISOSplitter"""
for text,splitted in self.testdata: for text,splitted in self.testdata:
...@@ -82,7 +82,7 @@ def main(): ...@@ -82,7 +82,7 @@ def main():
unittest.TextTestRunner().run( test_suite() ) unittest.TextTestRunner().run( test_suite() )
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1: if len(sys.argv) > 1:
globals()[sys.argv[1]]() globals()[sys.argv[1]]()
else: else:
main() main()
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__version__ = '$Id: FilteredSet.py,v 1.3 2002/03/11 14:53:05 andreasjung Exp $' __version__ = '$Id: FilteredSet.py,v 1.4 2002/08/14 22:19:34 mj Exp $'
from BTrees.IIBTree import IISet from BTrees.IIBTree import IISet
from Persistence import Persistent from Persistence import Persistent
...@@ -27,7 +27,7 @@ class FilteredSetBase(Persistent): ...@@ -27,7 +27,7 @@ class FilteredSetBase(Persistent):
self.expr = expr self.expr = expr
self.clear() self.clear()
def clear(self): def clear(self):
self.ids = IISet() self.ids = IISet()
...@@ -47,10 +47,10 @@ class FilteredSetBase(Persistent): ...@@ -47,10 +47,10 @@ class FilteredSetBase(Persistent):
def getType(self): return self.meta_type def getType(self): return self.meta_type
def setExpression(self, expr): self.expr = expr def setExpression(self, expr): self.expr = expr
def __repr__(self): def __repr__(self):
return '%s: (%s) %s' % (self.id,self.expr,map(None,self.ids)) return '%s: (%s) %s' % (self.id,self.expr,map(None,self.ids))
__str__ = __repr__ __str__ = __repr__
...@@ -63,7 +63,7 @@ class PythonFilteredSet(FilteredSetBase): ...@@ -63,7 +63,7 @@ class PythonFilteredSet(FilteredSetBase):
try: try:
if eval(self.expr): self.ids.insert(documentId) if eval(self.expr): self.ids.insert(documentId)
except: except:
LOG('FilteredSet',WARNING,'eval() failed',\ LOG('FilteredSet',WARNING,'eval() failed',\
'Object: %s, expr: %s' % (o.getId(),self.expr),\ 'Object: %s, expr: %s' % (o.getId(),self.expr),\
sys.exc_info()) sys.exc_info())
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import common.PluggableIndex as PluggableIndex import common.PluggableIndex as PluggableIndex
import common.ResultList as ResultList import common.ResultList as ResultList
import common.UnIndex as UnIndex import common.UnIndex as UnIndex
import PathIndex.PathIndex import PathIndex.PathIndex
import TextIndex.TextIndex import TextIndex.TextIndex
import FieldIndex.FieldIndex import FieldIndex.FieldIndex
import KeywordIndex.KeywordIndex import KeywordIndex.KeywordIndex
import TopicIndex.TopicIndex import TopicIndex.TopicIndex
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # 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. # 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 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Pluggable Index Base Class """ """Pluggable Index Base Class """
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import Interface import Interface
...@@ -43,7 +43,7 @@ class PluggableIndexInterface(Interface.Base): ...@@ -43,7 +43,7 @@ class PluggableIndexInterface(Interface.Base):
If 'withLengths' is true, returns a sequence of tuples of If 'withLengths' is true, returns a sequence of tuples of
(value, length). (value, length).
""" """
def _apply_index(request, cid=''): def _apply_index(request, cid=''):
"""Apply the index to query parameters given in 'request'. """Apply the index to query parameters given in 'request'.
...@@ -67,4 +67,3 @@ class PluggableIndexInterface(Interface.Base): ...@@ -67,4 +67,3 @@ class PluggableIndexInterface(Interface.Base):
records. The second object is a tuple containing the names of records. The second object is a tuple containing the names of
all data fields used. all data fields used.
""" """
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,4 +14,3 @@ dbl_quoted_punc = punc_func("\"") ...@@ -14,4 +14,3 @@ dbl_quoted_punc = punc_func("\"")
strongem_punc = punc_func('*') strongem_punc = punc_func('*')
under_punc = punc_func('_<>') under_punc = punc_func('_<>')
phrase_delimiters = r'\s\.\,\?\/\!\&\(\)' phrase_delimiters = r'\s\.\,\?\/\!\&\(\)'
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment