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