Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
2639fcb7
Commit
2639fcb7
authored
Aug 14, 2002
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up indentation and trailing whitespace.
parent
bdb3057e
Changes
102
Hide whitespace changes
Inline
Side-by-side
Showing
102 changed files
with
1007 additions
and
1086 deletions
+1007
-1086
lib/python/DocumentTemplate/DT_HTML.py
lib/python/DocumentTemplate/DT_HTML.py
+9
-9
lib/python/DocumentTemplate/DT_If.py
lib/python/DocumentTemplate/DT_If.py
+13
-13
lib/python/DocumentTemplate/DT_In.py
lib/python/DocumentTemplate/DT_In.py
+78
-78
lib/python/DocumentTemplate/DT_InSV.py
lib/python/DocumentTemplate/DT_InSV.py
+27
-27
lib/python/DocumentTemplate/DT_Let.py
lib/python/DocumentTemplate/DT_Let.py
+7
-8
lib/python/DocumentTemplate/DT_Raise.py
lib/python/DocumentTemplate/DT_Raise.py
+8
-8
lib/python/DocumentTemplate/DT_Return.py
lib/python/DocumentTemplate/DT_Return.py
+4
-4
lib/python/DocumentTemplate/DT_String.py
lib/python/DocumentTemplate/DT_String.py
+16
-16
lib/python/DocumentTemplate/DT_Try.py
lib/python/DocumentTemplate/DT_Try.py
+21
-21
lib/python/DocumentTemplate/DT_UI.py
lib/python/DocumentTemplate/DT_UI.py
+10
-10
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+19
-19
lib/python/DocumentTemplate/DT_Var.py
lib/python/DocumentTemplate/DT_Var.py
+25
-25
lib/python/DocumentTemplate/DT_With.py
lib/python/DocumentTemplate/DT_With.py
+6
-6
lib/python/DocumentTemplate/DTtestExpr.py
lib/python/DocumentTemplate/DTtestExpr.py
+5
-5
lib/python/DocumentTemplate/DocumentTemplate.py
lib/python/DocumentTemplate/DocumentTemplate.py
+4
-4
lib/python/DocumentTemplate/VSEval.py
lib/python/DocumentTemplate/VSEval.py
+0
-1
lib/python/DocumentTemplate/__init__.py
lib/python/DocumentTemplate/__init__.py
+4
-4
lib/python/DocumentTemplate/html_quote.py
lib/python/DocumentTemplate/html_quote.py
+0
-1
lib/python/DocumentTemplate/pDocumentTemplate.py
lib/python/DocumentTemplate/pDocumentTemplate.py
+12
-12
lib/python/DocumentTemplate/sequence/SortEx.py
lib/python/DocumentTemplate/sequence/SortEx.py
+29
-31
lib/python/DocumentTemplate/sequence/__init__.py
lib/python/DocumentTemplate/sequence/__init__.py
+2
-2
lib/python/DocumentTemplate/sequence/tests/testSequence.py
lib/python/DocumentTemplate/sequence/tests/testSequence.py
+5
-5
lib/python/DocumentTemplate/sequence/tests/ztestlib.py
lib/python/DocumentTemplate/sequence/tests/ztestlib.py
+12
-14
lib/python/DocumentTemplate/tests/testDTML.py
lib/python/DocumentTemplate/tests/testDTML.py
+9
-9
lib/python/DocumentTemplate/tests/testDTMLUnicode.py
lib/python/DocumentTemplate/tests/testDTMLUnicode.py
+4
-4
lib/python/DocumentTemplate/tests/testustr.py
lib/python/DocumentTemplate/tests/testustr.py
+4
-4
lib/python/Products/PythonScripts/Extensions/RemotePS.py
lib/python/Products/PythonScripts/Extensions/RemotePS.py
+1
-1
lib/python/Products/PythonScripts/PythonScript.py
lib/python/Products/PythonScripts/PythonScript.py
+11
-11
lib/python/Products/PythonScripts/Utility.py
lib/python/Products/PythonScripts/Utility.py
+3
-3
lib/python/Products/PythonScripts/__init__.py
lib/python/Products/PythonScripts/__init__.py
+5
-5
lib/python/Products/PythonScripts/help/PythonScript.py
lib/python/Products/PythonScripts/help/PythonScript.py
+3
-8
lib/python/Products/PythonScripts/help/Script.py
lib/python/Products/PythonScripts/help/Script.py
+2
-2
lib/python/Products/PythonScripts/help/standard.py
lib/python/Products/PythonScripts/help/standard.py
+5
-5
lib/python/Products/PythonScripts/module_access_examples.py
lib/python/Products/PythonScripts/module_access_examples.py
+0
-5
lib/python/Products/PythonScripts/standard.py
lib/python/Products/PythonScripts/standard.py
+3
-4
lib/python/Products/PythonScripts/tests/testPythonScript.py
lib/python/Products/PythonScripts/tests/testPythonScript.py
+8
-9
lib/python/Products/Sessions/BrowserIdManager.py
lib/python/Products/Sessions/BrowserIdManager.py
+11
-11
lib/python/Products/Sessions/SessionDataManager.py
lib/python/Products/Sessions/SessionDataManager.py
+5
-5
lib/python/Products/Sessions/SessionInterfaces.py
lib/python/Products/Sessions/SessionInterfaces.py
+4
-4
lib/python/Products/Sessions/SessionPermissions.py
lib/python/Products/Sessions/SessionPermissions.py
+1
-1
lib/python/Products/Sessions/__init__.py
lib/python/Products/Sessions/__init__.py
+3
-3
lib/python/Products/Sessions/common.py
lib/python/Products/Sessions/common.py
+1
-1
lib/python/Products/Sessions/help/SessionInterfaces.py
lib/python/Products/Sessions/help/SessionInterfaces.py
+4
-4
lib/python/Products/Sessions/stresstests/stresstestMultiThread.py
...on/Products/Sessions/stresstests/stresstestMultiThread.py
+5
-6
lib/python/Products/Sessions/tests/testBrowserIdManager.py
lib/python/Products/Sessions/tests/testBrowserIdManager.py
+10
-10
lib/python/Products/Sessions/tests/testSessionDataManager.py
lib/python/Products/Sessions/tests/testSessionDataManager.py
+5
-6
lib/python/Products/SiteAccess/AccessRule.py
lib/python/Products/SiteAccess/AccessRule.py
+3
-3
lib/python/Products/SiteAccess/Extensions/updata.py
lib/python/Products/SiteAccess/Extensions/updata.py
+1
-1
lib/python/Products/SiteAccess/SiteRoot.py
lib/python/Products/SiteAccess/SiteRoot.py
+7
-7
lib/python/Products/SiteAccess/VirtualHostMonster.py
lib/python/Products/SiteAccess/VirtualHostMonster.py
+2
-2
lib/python/Products/SiteAccess/__init__.py
lib/python/Products/SiteAccess/__init__.py
+12
-12
lib/python/Products/SiteErrorLog/SiteErrorLog.py
lib/python/Products/SiteErrorLog/SiteErrorLog.py
+6
-7
lib/python/Products/SiteErrorLog/__init__.py
lib/python/Products/SiteErrorLog/__init__.py
+3
-4
lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
...ucts/StandardCacheManagers/AcceleratedHTTPCacheManager.py
+4
-4
lib/python/Products/StandardCacheManagers/RAMCacheManager.py
lib/python/Products/StandardCacheManagers/RAMCacheManager.py
+6
-6
lib/python/Products/StandardCacheManagers/__init__.py
lib/python/Products/StandardCacheManagers/__init__.py
+2
-2
lib/python/Products/TemporaryFolder/LowConflictConnection.py
lib/python/Products/TemporaryFolder/LowConflictConnection.py
+2
-4
lib/python/Products/TemporaryFolder/TemporaryFolder.py
lib/python/Products/TemporaryFolder/TemporaryFolder.py
+8
-8
lib/python/Products/TemporaryFolder/TemporaryStorage.py
lib/python/Products/TemporaryFolder/TemporaryStorage.py
+9
-15
lib/python/Products/TemporaryFolder/__init__.py
lib/python/Products/TemporaryFolder/__init__.py
+3
-3
lib/python/Products/TemporaryFolder/patchfs.py
lib/python/Products/TemporaryFolder/patchfs.py
+2
-2
lib/python/Products/TemporaryFolder/tests/testTemporaryStorage.py
...on/Products/TemporaryFolder/tests/testTemporaryStorage.py
+6
-7
lib/python/Products/Transience/Transience.py
lib/python/Products/Transience/Transience.py
+13
-13
lib/python/Products/Transience/TransienceInterfaces.py
lib/python/Products/Transience/TransienceInterfaces.py
+4
-4
lib/python/Products/Transience/TransientObject.py
lib/python/Products/Transience/TransientObject.py
+7
-7
lib/python/Products/Transience/__init__.py
lib/python/Products/Transience/__init__.py
+4
-5
lib/python/Products/Transience/help/TransienceInterfaces.py
lib/python/Products/Transience/help/TransienceInterfaces.py
+5
-7
lib/python/Products/Transience/tests/fauxtime.py
lib/python/Products/Transience/tests/fauxtime.py
+0
-1
lib/python/Products/Transience/tests/testTimeoutRelated.py
lib/python/Products/Transience/tests/testTimeoutRelated.py
+1
-1
lib/python/Products/Transience/tests/testTransientObject.py
lib/python/Products/Transience/tests/testTransientObject.py
+7
-8
lib/python/Products/Transience/tests/testTransientObjectContainer.py
...Products/Transience/tests/testTransientObjectContainer.py
+11
-12
lib/python/Products/ZCTextIndex/BaseIndex.py
lib/python/Products/ZCTextIndex/BaseIndex.py
+4
-4
lib/python/Products/ZCTextIndex/IIndex.py
lib/python/Products/ZCTextIndex/IIndex.py
+1
-1
lib/python/Products/ZCTextIndex/ZCTextIndex.py
lib/python/Products/ZCTextIndex/ZCTextIndex.py
+22
-22
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
+13
-13
lib/python/Products/ZCatalog/Catalog.py
lib/python/Products/ZCatalog/Catalog.py
+42
-43
lib/python/Products/ZCatalog/CatalogAwareness.py
lib/python/Products/ZCatalog/CatalogAwareness.py
+4
-13
lib/python/Products/ZCatalog/CatalogBrains.py
lib/python/Products/ZCatalog/CatalogBrains.py
+5
-5
lib/python/Products/ZCatalog/CatalogPathAwareness.py
lib/python/Products/ZCatalog/CatalogPathAwareness.py
+5
-13
lib/python/Products/ZCatalog/IZCatalog.py
lib/python/Products/ZCatalog/IZCatalog.py
+12
-12
lib/python/Products/ZCatalog/Lazy.py
lib/python/Products/ZCatalog/Lazy.py
+7
-7
lib/python/Products/ZCatalog/ZCatalog.py
lib/python/Products/ZCatalog/ZCatalog.py
+63
-63
lib/python/Products/ZCatalog/ZCatalogIndexes.py
lib/python/Products/ZCatalog/ZCatalogIndexes.py
+13
-15
lib/python/Products/ZCatalog/__init__.py
lib/python/Products/ZCatalog/__init__.py
+4
-5
lib/python/Products/ZCatalog/help/Vocabulary.py
lib/python/Products/ZCatalog/help/Vocabulary.py
+6
-8
lib/python/Products/ZCatalog/help/ZCatalog.py
lib/python/Products/ZCatalog/help/ZCatalog.py
+20
-21
lib/python/Products/ZCatalog/regressiontests/keywords.py
lib/python/Products/ZCatalog/regressiontests/keywords.py
+12
-14
lib/python/Products/ZCatalog/regressiontests/loadmail.py
lib/python/Products/ZCatalog/regressiontests/loadmail.py
+13
-13
lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py
...on/Products/ZCatalog/regressiontests/regressionCatalog.py
+93
-94
lib/python/Products/ZCatalog/regressiontests/regressionCatalogTiming.py
...ducts/ZCatalog/regressiontests/regressionCatalogTiming.py
+9
-10
lib/python/Products/ZCatalog/regressiontests/regressionUnicode.py
...on/Products/ZCatalog/regressiontests/regressionUnicode.py
+4
-4
lib/python/Products/ZCatalog/regressiontests/unittest_patched.py
...hon/Products/ZCatalog/regressiontests/unittest_patched.py
+18
-18
lib/python/Products/ZCatalog/tests/testCatalog.py
lib/python/Products/ZCatalog/tests/testCatalog.py
+15
-15
lib/python/Products/ZGadflyDA/DA.py
lib/python/Products/ZGadflyDA/DA.py
+10
-11
lib/python/Products/ZGadflyDA/DABase.py
lib/python/Products/ZGadflyDA/DABase.py
+8
-8
lib/python/Products/ZGadflyDA/__init__.py
lib/python/Products/ZGadflyDA/__init__.py
+5
-5
lib/python/Products/ZGadflyDA/db.py
lib/python/Products/ZGadflyDA/db.py
+8
-8
lib/python/Products/ZSQLMethods/SQL.py
lib/python/Products/ZSQLMethods/SQL.py
+7
-7
lib/python/Products/ZSQLMethods/__init__.py
lib/python/Products/ZSQLMethods/__init__.py
+4
-4
lib/python/Products/ZSQLMethods/help/ZSQLMethod.py
lib/python/Products/ZSQLMethods/help/ZSQLMethod.py
+5
-17
lib/python/Products/ZopeTutorial/TutorialTopic.py
lib/python/Products/ZopeTutorial/TutorialTopic.py
+15
-15
lib/python/Products/ZopeTutorial/__init__.py
lib/python/Products/ZopeTutorial/__init__.py
+9
-9
No files found.
lib/python/DocumentTemplate/DT_HTML.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""HTML formated DocumentTemplates
"""HTML formated DocumentTemplates
$Id: DT_HTML.py,v 1.3
1 2001/11/28 15:50:54 matt
Exp $"""
$Id: DT_HTML.py,v 1.3
2 2002/08/14 22:29:52 mj
Exp $"""
from
DT_String
import
String
,
FileMixin
from
DT_String
import
String
,
FileMixin
import
DT_String
,
re
import
DT_String
,
re
...
@@ -71,7 +71,7 @@ class dtml_re_class:
...
@@ -71,7 +71,7 @@ class dtml_re_class:
else
:
else
:
if
text
[
s
:
s
+
5
]
==
'&dtml'
and
text
[
s
+
5
]
in
'.-'
:
if
text
[
s
:
s
+
5
]
==
'&dtml'
and
text
[
s
+
5
]
in
'.-'
:
n
=
s
+
6
n
=
s
+
6
e
=
text
.
find
(
';'
,
n
)
e
=
text
.
find
(
';'
,
n
)
if
e
>=
0
:
if
e
>=
0
:
args
=
text
[
n
:
e
]
args
=
text
[
n
:
e
]
l
=
len
(
args
)
l
=
len
(
args
)
...
@@ -97,7 +97,7 @@ class dtml_re_class:
...
@@ -97,7 +97,7 @@ class dtml_re_class:
d
[
3
]
=
d
[
'args'
]
=
args
d
[
3
]
=
d
[
'args'
]
=
args
self
.
_start
=
s
self
.
_start
=
s
return
self
return
self
start
=
s
+
1
start
=
s
+
1
continue
continue
...
@@ -106,7 +106,7 @@ class dtml_re_class:
...
@@ -106,7 +106,7 @@ class dtml_re_class:
mo
=
name_match
(
text
,
n
)
mo
=
name_match
(
text
,
n
)
if
mo
is
None
:
return
None
if
mo
is
None
:
return
None
l
=
mo
.
end
(
0
)
-
mo
.
start
(
0
)
l
=
mo
.
end
(
0
)
-
mo
.
start
(
0
)
a
=
n
+
l
a
=
n
+
l
name
=
text
[
n
:
a
].
strip
()
name
=
text
[
n
:
a
].
strip
()
...
@@ -177,7 +177,7 @@ class HTML(DT_String.String):
...
@@ -177,7 +177,7 @@ class HTML(DT_String.String):
if
not
(
args
==
sargs
or
if
not
(
args
==
sargs
or
args
==
sargs
[:
l
]
and
sargs
[
l
:
l
+
1
]
in
'
\
t
\
n
'
):
args
==
sargs
[:
l
]
and
sargs
[
l
:
l
+
1
]
in
'
\
t
\
n
'
):
return
tag
,
args
,
self
.
commands
[
name
],
None
return
tag
,
args
,
self
.
commands
[
name
],
None
return
tag
,
args
,
None
,
name
return
tag
,
args
,
None
,
name
try
:
return
tag
,
args
,
self
.
commands
[
name
],
None
try
:
return
tag
,
args
,
self
.
commands
[
name
],
None
...
@@ -225,7 +225,7 @@ class HTML(DT_String.String):
...
@@ -225,7 +225,7 @@ class HTML(DT_String.String):
manage_editForm__roles__
=
()
manage_editForm__roles__
=
()
def
manage_editForm
(
self
,
URL1
,
REQUEST
):
def
manage_editForm
(
self
,
URL1
,
REQUEST
):
'''Display doc template editing form'''
#"
'''Display doc template editing form'''
#"
return
self
.
_manage_editForm
(
return
self
.
_manage_editForm
(
self
,
self
,
mapping
=
REQUEST
,
mapping
=
REQUEST
,
...
@@ -302,7 +302,7 @@ class HTMLFile(FileMixin, HTML):
...
@@ -302,7 +302,7 @@ class HTMLFile(FileMixin, HTML):
if
data
.
find
(
'
\
r
'
):
if
data
.
find
(
'
\
r
'
):
data
=
'
\
n
\
r
'
.
join
(
data
.
split
(
'
\
r
\
n
'
))
data
=
'
\
n
\
r
'
.
join
(
data
.
split
(
'
\
r
\
n
'
))
data
=
'
\
n
'
.
join
(
data
.
split
(
'
\
n
\
r
'
))
data
=
'
\
n
'
.
join
(
data
.
split
(
'
\
n
\
r
'
))
if
self
.
edited_source
:
if
self
.
edited_source
:
self
.
edited_source
=
data
self
.
edited_source
=
data
self
.
_v_cooked
=
self
.
cook
()
self
.
_v_cooked
=
self
.
cook
()
...
...
lib/python/DocumentTemplate/DT_If.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Conditional insertion
__doc__
=
'''Conditional insertion
...
@@ -19,14 +19,14 @@ __doc__='''Conditional insertion
...
@@ -19,14 +19,14 @@ __doc__='''Conditional insertion
format, use::
format, use::
%(if name)[
%(if name)[
text
text
%(if name)]
%(if name)]
To include text when an object is true using the HTML
To include text when an object is true using the HTML
format, use::
format, use::
<!--#if name-->
<!--#if name-->
text
text
<!--#/if name-->
<!--#/if name-->
where 'name' is the name bound to the object.
where 'name' is the name bound to the object.
...
@@ -35,14 +35,14 @@ __doc__='''Conditional insertion
...
@@ -35,14 +35,14 @@ __doc__='''Conditional insertion
format, use::
format, use::
%(else name)[
%(else name)[
text
text
%(else name)]
%(else name)]
To include text when an object is false using the HTML
To include text when an object is false using the HTML
format, use::
format, use::
<!--#else name-->
<!--#else name-->
text
text
<!--#/else name-->
<!--#/else name-->
Finally to include text when an object is true and to
Finally to include text when an object is true and to
...
@@ -50,10 +50,10 @@ __doc__='''Conditional insertion
...
@@ -50,10 +50,10 @@ __doc__='''Conditional insertion
EPFS format, use::
EPFS format, use::
%(if name)[
%(if name)[
true text
true text
%(if name)]
%(if name)]
%(else name)[
%(else name)[
false text
false text
%(else name)]
%(else name)]
and to include text when an object is true and to
and to include text when an object is true and to
...
@@ -61,9 +61,9 @@ __doc__='''Conditional insertion
...
@@ -61,9 +61,9 @@ __doc__='''Conditional insertion
HTML format, use::
HTML format, use::
<!--#if name-->
<!--#if name-->
true text
true text
<!--#else name-->
<!--#else name-->
false text
false text
<!--#/if name-->
<!--#/if name-->
Notes:
Notes:
...
@@ -74,9 +74,9 @@ __doc__='''Conditional insertion
...
@@ -74,9 +74,9 @@ __doc__='''Conditional insertion
is used inside the tag, including in enclosed tags, the
is used inside the tag, including in enclosed tags, the
variable is not reevaluated.
variable is not reevaluated.
'''
'''
__rcs_id__
=
'$Id: DT_If.py,v 1.1
8 2001/11/28 15:50:54 matt
Exp $'
__rcs_id__
=
'$Id: DT_If.py,v 1.1
9 2002/08/14 22:29:52 mj
Exp $'
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
9
$'
[
11
:
-
2
]
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
...
...
lib/python/DocumentTemplate/DT_In.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''Sequence insertion
'''Sequence insertion
A sequence may be inserted using an 'in' command. The 'in'
A sequence may be inserted using an 'in' command. The 'in'
command specifies the name of a sequence object and text to
command specifies the name of a sequence object and text to
be inserted for each element in the sequence.
be inserted for each element in the sequence.
The EPFS syntax for the in command is::
The EPFS syntax for the in command is::
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
The HTML syntax for the in command is::
The HTML syntax for the in command is::
<!--#in name-->
<!--#in name-->
text
text
<!--#/in name-->
<!--#/in name-->
See the example below that shows how 'if', 'else', and 'in' commands
See the example below that shows how 'if', 'else', and 'in' commands
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
sort_expr -- This allows an expression to control sort order.
sort_expr -- This allows an expression to control sort order.
reverse -- Reverse the sequence (may be combined with sort). Note
reverse -- Reverse the sequence (may be combined with sort). Note
that this can cause a huge memory use in lazy activation instances.
that this can cause a huge memory use in lazy activation instances.
reverse_expr -- This calculated parameter allows you to calculate the
reverse_expr -- This calculated parameter allows you to calculate the
need of reversing on the fly.
need of reversing on the fly.
...
@@ -160,7 +160,7 @@
...
@@ -160,7 +160,7 @@
parameter is 0.
parameter is 0.
'overlap' -- The desired overlap between batches. The
'overlap' -- The desired overlap between batches. The
default is no overlap.
default is no overlap.
Typically, only 'start' and 'size' will be specified.
Typically, only 'start' and 'size' will be specified.
...
@@ -331,8 +331,8 @@
...
@@ -331,8 +331,8 @@
'''
#'
'''
#'
__rcs_id__
=
'$Id: DT_In.py,v 1.
59 2002/05/07 17:55:37 htrd
Exp $'
__rcs_id__
=
'$Id: DT_In.py,v 1.
60 2002/08/14 22:29:52 mj
Exp $'
__version__
=
'$Revision: 1.
59
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
60
$'
[
11
:
-
2
]
import
sys
import
sys
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
,
join_unicode
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
,
join_unicode
...
@@ -360,7 +360,7 @@ class InClass:
...
@@ -360,7 +360,7 @@ class InClass:
start_name_re
=
None
start_name_re
=
None
reverse
=
None
reverse
=
None
sort_expr
=
reverse_expr
=
None
sort_expr
=
reverse_expr
=
None
def
__init__
(
self
,
blocks
):
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
,
start
=
'1'
,
end
=
'-1'
,
size
=
'10'
,
args
=
parse_params
(
args
,
name
=
''
,
start
=
'1'
,
end
=
'-1'
,
size
=
'10'
,
...
@@ -385,10 +385,10 @@ class InClass:
...
@@ -385,10 +385,10 @@ class InClass:
if
has_key
(
'reverse'
):
if
has_key
(
'reverse'
):
self
.
reverse
=
args
[
'reverse'
]
self
.
reverse
=
args
[
'reverse'
]
if
has_key
(
'no_push_item'
):
if
has_key
(
'no_push_item'
):
self
.
no_push_item
=
args
[
'no_push_item'
]
self
.
no_push_item
=
args
[
'no_push_item'
]
if
has_key
(
'mapping'
):
self
.
mapping
=
args
[
'mapping'
]
if
has_key
(
'mapping'
):
self
.
mapping
=
args
[
'mapping'
]
for
n
in
'start'
,
'size'
,
'end'
:
for
n
in
'start'
,
'size'
,
'end'
:
if
has_key
(
n
):
self
.
batch
=
1
if
has_key
(
n
):
self
.
batch
=
1
...
@@ -397,7 +397,7 @@ class InClass:
...
@@ -397,7 +397,7 @@ class InClass:
if
prefix
and
not
simple_name
(
prefix
):
if
prefix
and
not
simple_name
(
prefix
):
raise
ParseError
,
_tm
(
raise
ParseError
,
_tm
(
'prefix is not a simple name'
,
'in'
)
'prefix is not a simple name'
,
'in'
)
for
n
in
'orphan'
,
'overlap'
,
'previous'
,
'next'
:
for
n
in
'orphan'
,
'overlap'
,
'previous'
,
'next'
:
if
has_key
(
n
)
and
not
self
.
batch
:
if
has_key
(
n
)
and
not
self
.
batch
:
raise
ParseError
,
(
raise
ParseError
,
(
...
@@ -417,7 +417,7 @@ class InClass:
...
@@ -417,7 +417,7 @@ class InClass:
'&+'
+
'&+'
+
''
.
join
([
"[%s]"
%
c
for
c
in
v
])
+
''
.
join
([
"[%s]"
%
c
for
c
in
v
])
+
'=[0-9]+&+'
)
'=[0-9]+&+'
)
name
,
expr
=
name_param
(
args
,
'in'
,
1
)
name
,
expr
=
name_param
(
args
,
'in'
,
1
)
if
expr
is
not
None
:
expr
=
expr
.
eval
if
expr
is
not
None
:
expr
=
expr
.
eval
self
.
__name__
,
self
.
expr
=
name
,
expr
self
.
__name__
,
self
.
expr
=
name
,
expr
...
@@ -433,7 +433,7 @@ class InClass:
...
@@ -433,7 +433,7 @@ class InClass:
raise
ParseError
,
(
raise
ParseError
,
(
'name in else does not match in'
,
'in'
)
'name in else does not match in'
,
'in'
)
self
.
elses
=
section
.
blocks
self
.
elses
=
section
.
blocks
def
renderwb
(
self
,
md
):
def
renderwb
(
self
,
md
):
expr
=
self
.
expr
expr
=
self
.
expr
...
@@ -456,7 +456,7 @@ class InClass:
...
@@ -456,7 +456,7 @@ class InClass:
section
=
self
.
section
section
=
self
.
section
params
=
self
.
args
params
=
self
.
args
mapping
=
self
.
mapping
mapping
=
self
.
mapping
no_push_item
=
self
.
no_push_item
no_push_item
=
self
.
no_push_item
...
@@ -470,7 +470,7 @@ class InClass:
...
@@ -470,7 +470,7 @@ class InClass:
sequence
=
self
.
reverse_sequence
(
sequence
)
sequence
=
self
.
reverse_sequence
(
sequence
)
elif
self
.
reverse
is
not
None
:
elif
self
.
reverse
is
not
None
:
sequence
=
self
.
reverse_sequence
(
sequence
)
sequence
=
self
.
reverse_sequence
(
sequence
)
next
=
previous
=
0
next
=
previous
=
0
try
:
start
=
int_param
(
params
,
md
,
'start'
,
0
)
try
:
start
=
int_param
(
params
,
md
,
'start'
,
0
)
except
:
start
=
1
except
:
start
=
1
...
@@ -570,7 +570,7 @@ class InClass:
...
@@ -570,7 +570,7 @@ class InClass:
pkw
[
'next-sequence-end-index'
]
=
pend
-
1
pkw
[
'next-sequence-end-index'
]
=
pend
-
1
pkw
[
'next-sequence-size'
]
=
pend
+
1
-
pstart
pkw
[
'next-sequence-size'
]
=
pend
+
1
-
pstart
except
:
pass
except
:
pass
if
index
==
last
:
pkw
[
'sequence-end'
]
=
1
if
index
==
last
:
pkw
[
'sequence-end'
]
=
1
if
guarded_getitem
is
not
None
:
if
guarded_getitem
is
not
None
:
...
@@ -636,7 +636,7 @@ class InClass:
...
@@ -636,7 +636,7 @@ class InClass:
raise
'InError'
,
(
raise
'InError'
,
(
'Strings are not allowed as input to the in tag.'
)
'Strings are not allowed as input to the in tag.'
)
section
=
self
.
section
section
=
self
.
section
mapping
=
self
.
mapping
mapping
=
self
.
mapping
no_push_item
=
self
.
no_push_item
no_push_item
=
self
.
no_push_item
...
@@ -669,46 +669,46 @@ class InClass:
...
@@ -669,46 +669,46 @@ class InClass:
if
cache
:
push
(
cache
)
if
cache
:
push
(
cache
)
push
(
vars
)
push
(
vars
)
try
:
try
:
result
=
[]
result
=
[]
append
=
result
.
append
append
=
result
.
append
guarded_getitem
=
getattr
(
md
,
'guarded_getitem'
,
None
)
guarded_getitem
=
getattr
(
md
,
'guarded_getitem'
,
None
)
for
index
in
range
(
l
):
for
index
in
range
(
l
):
if
index
==
last
:
pkw
[
'sequence-end'
]
=
1
if
index
==
last
:
pkw
[
'sequence-end'
]
=
1
if
guarded_getitem
is
not
None
:
if
guarded_getitem
is
not
None
:
try
:
client
=
guarded_getitem
(
sequence
,
index
)
try
:
client
=
guarded_getitem
(
sequence
,
index
)
except
ValidationError
,
vv
:
except
ValidationError
,
vv
:
if
(
self
.
args
.
has_key
(
'skip_unauthorized'
)
and
if
(
self
.
args
.
has_key
(
'skip_unauthorized'
)
and
self
.
args
[
'skip_unauthorized'
]):
self
.
args
[
'skip_unauthorized'
]):
if
index
==
1
:
pkw
[
'sequence-start'
]
=
0
if
index
==
1
:
pkw
[
'sequence-start'
]
=
0
continue
continue
raise
ValidationError
,
'(item %s): %s'
%
(
raise
ValidationError
,
'(item %s): %s'
%
(
index
,
vv
),
sys
.
exc_info
()[
2
]
index
,
vv
),
sys
.
exc_info
()[
2
]
else
:
else
:
client
=
sequence
[
index
]
client
=
sequence
[
index
]
pkw
[
'sequence-index'
]
=
index
pkw
[
'sequence-index'
]
=
index
t
=
type
(
client
)
t
=
type
(
client
)
if
t
is
TupleType
and
len
(
client
)
==
2
:
if
t
is
TupleType
and
len
(
client
)
==
2
:
client
=
client
[
1
]
client
=
client
[
1
]
if
no_push_item
:
if
no_push_item
:
pushed
=
0
pushed
=
0
elif
mapping
:
elif
mapping
:
pushed
=
1
pushed
=
1
push
(
client
)
push
(
client
)
elif
t
in
StringTypes
:
elif
t
in
StringTypes
:
pushed
=
0
pushed
=
0
else
:
else
:
pushed
=
1
pushed
=
1
push
(
InstanceDict
(
client
,
md
))
push
(
InstanceDict
(
client
,
md
))
try
:
append
(
render
(
section
,
md
))
try
:
append
(
render
(
section
,
md
))
finally
:
finally
:
if
pushed
:
if
pushed
:
pop
()
pop
()
if
index
==
0
:
pkw
[
'sequence-start'
]
=
0
if
index
==
0
:
pkw
[
'sequence-start'
]
=
0
result
=
join_unicode
(
result
)
result
=
join_unicode
(
result
)
finally
:
finally
:
if
cache
:
pop
()
if
cache
:
pop
()
...
@@ -721,7 +721,7 @@ class InClass:
...
@@ -721,7 +721,7 @@ class InClass:
# Modified with multiple sort fields by Ross Lazarus
# Modified with multiple sort fields by Ross Lazarus
# April 7 2000 rossl@med.usyd.edu.au
# April 7 2000 rossl@med.usyd.edu.au
# eg <dtml-in "foo" sort="akey,anotherkey">
# eg <dtml-in "foo" sort="akey,anotherkey">
# Modified with advanced sort functions by
# Modified with advanced sort functions by
# Oleg Broytmann <phd@phd.pp.ru> 30 Mar 2001
# Oleg Broytmann <phd@phd.pp.ru> 30 Mar 2001
# eg <dtml-in "foo" sort="akey/nocase,anotherkey/cmp/desc">
# eg <dtml-in "foo" sort="akey/nocase,anotherkey/cmp/desc">
...
@@ -729,7 +729,7 @@ class InClass:
...
@@ -729,7 +729,7 @@ class InClass:
sort
=
self
.
sort
sort
=
self
.
sort
need_sortfunc
=
sort
.
find
(
'/'
)
>=
0
need_sortfunc
=
sort
.
find
(
'/'
)
>=
0
sortfields
=
sort
.
split
(
','
)
# multi sort = key1,key2
sortfields
=
sort
.
split
(
','
)
# multi sort = key1,key2
multsort
=
len
(
sortfields
)
>
1
# flag: is multiple sort
multsort
=
len
(
sortfields
)
>
1
# flag: is multiple sort
if
need_sortfunc
:
if
need_sortfunc
:
...
@@ -756,25 +756,25 @@ class InClass:
...
@@ -756,25 +756,25 @@ class InClass:
v
=
client
v
=
client
if
sort
:
if
sort
:
if
multsort
:
# More than one sort key.
if
multsort
:
# More than one sort key.
k
=
[]
k
=
[]
for
sk
in
sortfields
:
for
sk
in
sortfields
:
try
:
try
:
if
mapping
:
akey
=
v
[
sk
]
if
mapping
:
akey
=
v
[
sk
]
else
:
akey
=
getattr
(
v
,
sk
)
else
:
akey
=
getattr
(
v
,
sk
)
except
AttributeError
,
KeyError
:
akey
=
None
except
AttributeError
,
KeyError
:
akey
=
None
if
not
basic_type
(
akey
):
if
not
basic_type
(
akey
):
try
:
akey
=
akey
()
try
:
akey
=
akey
()
except
:
pass
except
:
pass
k
.
append
(
akey
)
k
.
append
(
akey
)
else
:
# One sort key.
else
:
# One sort key.
try
:
try
:
if
mapping
:
k
=
v
[
sort
]
if
mapping
:
k
=
v
[
sort
]
else
:
k
=
getattr
(
v
,
sort
)
else
:
k
=
getattr
(
v
,
sort
)
except
AttributeError
,
KeyError
:
k
=
None
except
AttributeError
,
KeyError
:
k
=
None
if
not
basic_type
(
type
(
k
)):
if
not
basic_type
(
type
(
k
)):
try
:
k
=
k
()
try
:
k
=
k
()
except
:
pass
except
:
pass
s
.
append
((
k
,
client
))
s
.
append
((
k
,
client
))
...
@@ -786,7 +786,7 @@ class InClass:
...
@@ -786,7 +786,7 @@ class InClass:
sequence
=
[]
sequence
=
[]
for
k
,
client
in
s
:
for
k
,
client
in
s
:
sequence
.
append
(
client
)
sequence
.
append
(
client
)
return
sequence
return
sequence
def
reverse_sequence
(
self
,
sequence
):
def
reverse_sequence
(
self
,
sequence
):
...
...
lib/python/DocumentTemplate/DT_InSV.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Sequence variables support
__doc__
=
'''Sequence variables support
$Id: DT_InSV.py,v 1.2
1 2001/11/28 15:50:54 matt
Exp $'''
$Id: DT_InSV.py,v 1.2
2 2002/08/14 22:29:52 mj
Exp $'''
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
from
math
import
sqrt
from
math
import
sqrt
import
re
import
re
...
@@ -28,10 +28,10 @@ except: mv=None
...
@@ -28,10 +28,10 @@ except: mv=None
class
sequence_variables
:
class
sequence_variables
:
alt_prefix
=
None
alt_prefix
=
None
def
__init__
(
self
,
items
=
None
,
query_string
=
''
,
start_name_re
=
None
,
def
__init__
(
self
,
items
=
None
,
query_string
=
''
,
start_name_re
=
None
,
alt_prefix
=
''
):
alt_prefix
=
''
):
self
.
items
=
items
self
.
items
=
items
self
.
query_string
=
query_string
self
.
query_string
=
query_string
self
.
start_name_re
=
start_name_re
self
.
start_name_re
=
start_name_re
...
@@ -68,35 +68,35 @@ class sequence_variables:
...
@@ -68,35 +68,35 @@ class sequence_variables:
roman
=
''
roman
=
''
while
num
>=
1000
:
while
num
>=
1000
:
num
=
num
-
1000
num
=
num
-
1000
roman
=
'%sM'
%
roman
roman
=
'%sM'
%
roman
while
num
>=
500
:
while
num
>=
500
:
num
=
num
-
500
num
=
num
-
500
roman
=
'%sD'
%
roman
roman
=
'%sD'
%
roman
while
num
>=
100
:
while
num
>=
100
:
num
=
num
-
100
num
=
num
-
100
roman
=
'%sC'
%
roman
roman
=
'%sC'
%
roman
while
num
>=
50
:
while
num
>=
50
:
num
=
num
-
50
num
=
num
-
50
roman
=
'%sL'
%
roman
roman
=
'%sL'
%
roman
while
num
>=
10
:
while
num
>=
10
:
num
=
num
-
10
num
=
num
-
10
roman
=
'%sX'
%
roman
roman
=
'%sX'
%
roman
while
num
>=
5
:
while
num
>=
5
:
num
=
num
-
5
num
=
num
-
5
roman
=
'%sV'
%
roman
roman
=
'%sV'
%
roman
while
num
<
5
and
num
>=
1
:
while
num
<
5
and
num
>=
1
:
num
=
num
-
1
num
=
num
-
1
roman
=
'%sI'
%
roman
roman
=
'%sI'
%
roman
# Replaces special cases in Roman Numerals
# Replaces special cases in Roman Numerals
roman
=
roman
.
replace
(
'DCCCC'
,
'CM'
)
roman
=
roman
.
replace
(
'DCCCC'
,
'CM'
)
roman
=
roman
.
replace
(
'CCCC'
,
'CD'
)
roman
=
roman
.
replace
(
'CCCC'
,
'CD'
)
roman
=
roman
.
replace
(
'LXXXX'
,
'XC'
)
roman
=
roman
.
replace
(
'LXXXX'
,
'XC'
)
...
@@ -132,7 +132,7 @@ class sequence_variables:
...
@@ -132,7 +132,7 @@ class sequence_variables:
return
l
return
l
def
query
(
self
,
*
ignored
):
def
query
(
self
,
*
ignored
):
if
self
.
start_name_re
is
None
:
raise
KeyError
,
'sequence-query'
if
self
.
start_name_re
is
None
:
raise
KeyError
,
'sequence-query'
query_string
=
self
.
query_string
query_string
=
self
.
query_string
while
query_string
and
query_string
[:
1
]
in
'?&'
:
while
query_string
and
query_string
[:
1
]
in
'?&'
:
...
@@ -140,7 +140,7 @@ class sequence_variables:
...
@@ -140,7 +140,7 @@ class sequence_variables:
while
query_string
[
-
1
:]
==
'&'
:
while
query_string
[
-
1
:]
==
'&'
:
query_string
=
query_string
[:
-
1
]
query_string
=
query_string
[:
-
1
]
if
query_string
:
if
query_string
:
query_string
=
'&%s&'
%
query_string
query_string
=
'&%s&'
%
query_string
reg
=
self
.
start_name_re
reg
=
self
.
start_name_re
if
type
(
reg
)
==
type
(
re
.
compile
(
r""
)):
if
type
(
reg
)
==
type
(
re
.
compile
(
r""
)):
...
@@ -160,9 +160,9 @@ class sequence_variables:
...
@@ -160,9 +160,9 @@ class sequence_variables:
query_string
=
'?'
+
query_string
[
1
:]
query_string
=
'?'
+
query_string
[
1
:]
else
:
query_string
=
'?'
else
:
query_string
=
'?'
self
[
'sequence-query'
]
=
query_string
self
[
'sequence-query'
]
=
query_string
return
query_string
return
query_string
statistic_names
=
(
statistic_names
=
(
'total'
,
'count'
,
'min'
,
'max'
,
'median'
,
'mean'
,
'total'
,
'count'
,
'min'
,
'max'
,
'median'
,
'mean'
,
...
@@ -225,7 +225,7 @@ class sequence_variables:
...
@@ -225,7 +225,7 @@ class sequence_variables:
if
count
>
1
:
if
count
>
1
:
sumsq
=
sumsq
*
n
/
(
n
-
1
)
sumsq
=
sumsq
*
n
/
(
n
-
1
)
data
[
'variance-%s'
%
name
]
=
sumsq
data
[
'variance-%s'
%
name
]
=
sumsq
data
[
'standard-deviation-%s'
%
name
]
=
sqrt
(
sumsq
)
data
[
'standard-deviation-%s'
%
name
]
=
sqrt
(
sumsq
)
else
:
else
:
data
[
'variance-%s'
%
name
]
=
''
data
[
'variance-%s'
%
name
]
=
''
data
[
'standard-deviation-%s'
%
name
]
=
''
data
[
'standard-deviation-%s'
%
name
]
=
''
...
@@ -368,7 +368,7 @@ class sequence_variables:
...
@@ -368,7 +368,7 @@ class sequence_variables:
except
:
pass
except
:
pass
if
key
==
'sequence-query'
:
return
self
.
query
()
if
key
==
'sequence-query'
:
return
self
.
query
()
raise
KeyError
,
key
raise
KeyError
,
key
...
...
lib/python/DocumentTemplate/DT_Let.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
''' The Let tag was contributed to Zope by and is copyright, 1999
''' The Let tag was contributed to Zope by and is copyright, 1999
Phillip J. Eby. Permission has been granted to release the Let tag
Phillip J. Eby. Permission has been granted to release the Let tag
under the Zope Public License.
under the Zope Public License.
Let name=value...
Let name=value...
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
Variables are processed in sequence, so later assignments can
Variables are processed in sequence, so later assignments can
reference and/or overwrite the results of previous assignments,
reference and/or overwrite the results of previous assignments,
as desired.
as desired.
'''
'''
from
DT_Util
import
render_blocks
,
Eval
,
ParseError
from
DT_Util
import
render_blocks
,
Eval
,
ParseError
from
DT_Util
import
str
# Probably needed due to hysterical pickles.
from
DT_Util
import
str
# Probably needed due to hysterical pickles.
...
@@ -48,7 +48,7 @@ import re
...
@@ -48,7 +48,7 @@ import re
class
Let
:
class
Let
:
blockContinuations
=
()
blockContinuations
=
()
name
=
'let'
name
=
'let'
def
__init__
(
self
,
blocks
):
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
tname
,
args
,
section
=
blocks
[
0
]
self
.
__name__
=
args
self
.
__name__
=
args
...
@@ -58,7 +58,7 @@ class Let:
...
@@ -58,7 +58,7 @@ class Let:
for
i
in
range
(
len
(
args
)):
for
i
in
range
(
len
(
args
)):
name
,
expr
=
args
[
i
]
name
,
expr
=
args
[
i
]
if
expr
[:
1
]
==
'"'
and
expr
[
-
1
:]
==
'"'
and
len
(
expr
)
>
1
:
if
expr
[:
1
]
==
'"'
and
expr
[
-
1
:]
==
'"'
and
len
(
expr
)
>
1
:
# expr shorthand
# expr shorthand
expr
=
expr
[
1
:
-
1
]
expr
=
expr
[
1
:
-
1
]
try
:
args
[
i
]
=
name
,
Eval
(
expr
).
eval
try
:
args
[
i
]
=
name
,
Eval
(
expr
).
eval
except
SyntaxError
,
v
:
except
SyntaxError
,
v
:
...
@@ -85,7 +85,7 @@ def parse_let_params(text,
...
@@ -85,7 +85,7 @@ def parse_let_params(text,
parmre
=
re
.
compile
(
'([
\
000
- ]*([^
\
000
- ="]+)=([^
\
000
- ="]+))'
),
parmre
=
re
.
compile
(
'([
\
000
- ]*([^
\
000
- ="]+)=([^
\
000
- ="]+))'
),
qparmre
=
re
.
compile
(
'([
\
000
- ]*([^
\
000
- ="]+)="([^"]*)")'
),
qparmre
=
re
.
compile
(
'([
\
000
- ]*([^
\
000
- ="]+)="([^"]*)")'
),
**
parms
):
**
parms
):
result
=
result
or
[]
result
=
result
or
[]
mo
=
parmre
.
match
(
text
)
mo
=
parmre
.
match
(
text
)
...
@@ -108,4 +108,3 @@ def parse_let_params(text,
...
@@ -108,4 +108,3 @@ def parse_let_params(text,
text
=
text
[
l
:].
strip
()
text
=
text
[
l
:].
strip
()
if
text
:
return
apply
(
parse_let_params
,(
text
,
result
,
tag
),
parms
)
if
text
:
return
apply
(
parse_let_params
,(
text
,
result
,
tag
),
parms
)
else
:
return
result
else
:
return
result
lib/python/DocumentTemplate/DT_Raise.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''Raising exceptions
'''Raising exceptions
...
@@ -22,9 +22,9 @@
...
@@ -22,9 +22,9 @@
<!--#/raise-->
<!--#/raise-->
<!--#/if-->
<!--#/if-->
'''
'''
__rcs_id__
=
'$Id: DT_Raise.py,v 1.1
2 2001/11/28 15:50:55 matt
Exp $'
__rcs_id__
=
'$Id: DT_Raise.py,v 1.1
3 2002/08/14 22:29:52 mj
Exp $'
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
render_blocks
,
str
from
DT_Util
import
parse_params
,
name_param
,
render_blocks
,
str
...
@@ -43,9 +43,9 @@ class Raise:
...
@@ -43,9 +43,9 @@ class Raise:
def
render
(
self
,
md
):
def
render
(
self
,
md
):
expr
=
self
.
expr
expr
=
self
.
expr
if
expr
is
None
:
if
expr
is
None
:
t
=
self
.
__name__
t
=
self
.
__name__
if
t
[
-
5
:]
==
'Error'
and
__builtins__
.
has_key
(
t
):
if
t
[
-
5
:]
==
'Error'
and
__builtins__
.
has_key
(
t
):
t
=
__builtins__
[
t
]
t
=
__builtins__
[
t
]
else
:
else
:
try
:
t
=
expr
.
eval
(
md
)
try
:
t
=
expr
.
eval
(
md
)
except
:
t
=
'Invalid Error Type Expression'
except
:
t
=
'Invalid Error Type Expression'
...
...
lib/python/DocumentTemplate/DT_Return.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
str
from
DT_Util
import
parse_params
,
name_param
,
str
import
sys
import
sys
class
ReturnTag
:
class
ReturnTag
:
name
=
'return'
name
=
'return'
expr
=
None
expr
=
None
...
...
lib/python/DocumentTemplate/DT_String.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"$Id: DT_String.py,v 1.5
0 2002/08/01 16:00:39
mj Exp $"
"$Id: DT_String.py,v 1.5
1 2002/08/14 22:29:52
mj Exp $"
import
thread
,
re
,
exceptions
,
os
import
thread
,
re
,
exceptions
,
os
...
@@ -36,7 +36,7 @@ class String:
...
@@ -36,7 +36,7 @@ class String:
%(name)s
%(name)s
%(in results)]
%(in results)]
"""
"""
isDocTemp
=
1
isDocTemp
=
1
...
@@ -46,7 +46,7 @@ class String:
...
@@ -46,7 +46,7 @@ class String:
func_code
.
co_varnames
=
'self'
,
'REQUEST'
func_code
.
co_varnames
=
'self'
,
'REQUEST'
func_code
.
co_argcount
=
2
func_code
.
co_argcount
=
2
func_code
.
__roles__
=
()
func_code
.
__roles__
=
()
func_defaults__roles__
=
()
func_defaults__roles__
=
()
func_defaults
=
()
func_defaults
=
()
...
@@ -186,7 +186,7 @@ class String:
...
@@ -186,7 +186,7 @@ class String:
def
skip_eol
(
self
,
text
,
start
,
eol
=
re
.
compile
(
'[
\
t
]*
\
n
'
)):
def
skip_eol
(
self
,
text
,
start
,
eol
=
re
.
compile
(
'[
\
t
]*
\
n
'
)):
# if block open is followed by newline, then skip past newline
# if block open is followed by newline, then skip past newline
mo
=
eol
.
match
(
text
,
start
)
mo
=
eol
.
match
(
text
,
start
)
if
mo
is
not
None
:
if
mo
is
not
None
:
start
=
start
+
mo
.
end
(
0
)
-
mo
.
start
(
0
)
start
=
start
+
mo
.
end
(
0
)
-
mo
.
start
(
0
)
return
start
return
start
...
@@ -210,7 +210,7 @@ class String:
...
@@ -210,7 +210,7 @@ class String:
try
:
tag
,
args
,
command
,
coname
=
self
.
_parseTag
(
mo
,
scommand
,
sa
)
try
:
tag
,
args
,
command
,
coname
=
self
.
_parseTag
(
mo
,
scommand
,
sa
)
except
ParseError
,
m
:
self
.
parse_error
(
m
[
0
],
m
[
1
],
text
,
l
)
except
ParseError
,
m
:
self
.
parse_error
(
m
[
0
],
m
[
1
],
text
,
l
)
if
command
:
if
command
:
start
=
l
+
len
(
tag
)
start
=
l
+
len
(
tag
)
if
hasattr
(
command
,
'blockContinuations'
):
if
hasattr
(
command
,
'blockContinuations'
):
...
@@ -223,7 +223,7 @@ class String:
...
@@ -223,7 +223,7 @@ class String:
section
.
_v_blocks
=
section
.
blocks
=
self
.
parse
(
text
[:
l
],
sstart
)
section
.
_v_blocks
=
section
.
blocks
=
self
.
parse
(
text
[:
l
],
sstart
)
section
.
_v_cooked
=
None
section
.
_v_cooked
=
None
blocks
.
append
((
tname
,
sargs
,
section
))
blocks
.
append
((
tname
,
sargs
,
section
))
start
=
self
.
skip_eol
(
text
,
l
+
len
(
tag
))
start
=
self
.
skip_eol
(
text
,
l
+
len
(
tag
))
if
coname
:
if
coname
:
...
@@ -315,7 +315,7 @@ class String:
...
@@ -315,7 +315,7 @@ class String:
"""
"""
if
mapping
is
not
None
or
vars
:
if
mapping
is
not
None
or
vars
:
self
.
initvars
(
mapping
,
vars
)
self
.
initvars
(
mapping
,
vars
)
if
source_string
is
not
None
:
if
source_string
is
not
None
:
self
.
raw
=
source_string
self
.
raw
=
source_string
self
.
cook
()
self
.
cook
()
...
@@ -371,13 +371,13 @@ class String:
...
@@ -371,13 +371,13 @@ class String:
containing values to be looked up. Values will be looked up
containing values to be looked up. Values will be looked up
using getattr, so inheritence of values is supported. Note
using getattr, so inheritence of values is supported. Note
that names beginning with '_' will not be looked up from the
that names beginning with '_' will not be looked up from the
client.
client.
The optional argument, 'mapping' is used to specify a mapping
The optional argument, 'mapping' is used to specify a mapping
object containing values to be inserted.
object containing values to be inserted.
Values to be inserted may also be specified using keyword
Values to be inserted may also be specified using keyword
arguments.
arguments.
Values will be inserted from one of several sources. The
Values will be inserted from one of several sources. The
sources, in the order in which they are consulted, are:
sources, in the order in which they are consulted, are:
...
@@ -392,7 +392,7 @@ class String:
...
@@ -392,7 +392,7 @@ class String:
created, and
created, and
o The 'mapping' argument provided when the template was
o The 'mapping' argument provided when the template was
created.
created.
'''
'''
# print '============================================================'
# print '============================================================'
...
@@ -459,8 +459,8 @@ class String:
...
@@ -459,8 +459,8 @@ class String:
# otherwise its just a normal client object.
# otherwise its just a normal client object.
push
(
InstanceDict
(
client
,
md
))
# Circ. Ref. 8-|
push
(
InstanceDict
(
client
,
md
))
# Circ. Ref. 8-|
pushed
=
pushed
+
1
pushed
=
pushed
+
1
if
self
.
_vars
:
if
self
.
_vars
:
push
(
self
.
_vars
)
push
(
self
.
_vars
)
pushed
=
pushed
+
1
pushed
=
pushed
+
1
...
@@ -498,7 +498,7 @@ class String:
...
@@ -498,7 +498,7 @@ class String:
class
FileMixin
:
class
FileMixin
:
# Mix-in class to abstract certain file-related attributes
# Mix-in class to abstract certain file-related attributes
edited_source
=
''
edited_source
=
''
def
__init__
(
self
,
file_name
=
''
,
mapping
=
None
,
__name__
=
''
,
**
vars
):
def
__init__
(
self
,
file_name
=
''
,
mapping
=
None
,
__name__
=
''
,
**
vars
):
"""
\
"""
\
Create a document template based on a named file.
Create a document template based on a named file.
...
@@ -515,7 +515,7 @@ class FileMixin:
...
@@ -515,7 +515,7 @@ class FileMixin:
if
self
.
edited_source
:
return
self
.
edited_source
if
self
.
edited_source
:
return
self
.
edited_source
if
not
os
.
path
.
exists
(
self
.
raw
):
if
not
os
.
path
.
exists
(
self
.
raw
):
print
'file not found: %s'
%
self
.
raw
print
'file not found: %s'
%
self
.
raw
if
self
.
raw
:
return
open
(
self
.
raw
,
'r'
).
read
()
if
self
.
raw
:
return
open
(
self
.
raw
,
'r'
).
read
()
return
''
return
''
...
...
lib/python/DocumentTemplate/DT_Try.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
traceback
import
sys
,
traceback
...
@@ -19,41 +19,41 @@ from DT_Return import DTReturn
...
@@ -19,41 +19,41 @@ from DT_Return import DTReturn
class
Try
:
class
Try
:
"""Zope DTML Exception handling
"""Zope DTML Exception handling
usage:
usage:
<!--#try-->
<!--#try-->
<!--#except SomeError AnotherError-->
<!--#except SomeError AnotherError-->
<!--#except YetAnotherError-->
<!--#except YetAnotherError-->
<!--#except-->
<!--#except-->
<!--#else-->
<!--#else-->
<!--#/try-->
<!--#/try-->
or:
or:
<!--#try-->
<!--#try-->
<!--#finally-->
<!--#finally-->
<!--#/try-->
<!--#/try-->
The DTML try tag functions quite like Python's try command.
The DTML try tag functions quite like Python's try command.
The contents of the try tag are rendered. If an exception is raised,
The contents of the try tag are rendered. If an exception is raised,
then control switches to the except blocks. The first except block to
then control switches to the except blocks. The first except block to
match the type of the error raised is rendered. If an except block has
match the type of the error raised is rendered. If an except block has
no name then it matches all raised errors.
no name then it matches all raised errors.
The try tag understands class-based exceptions, as well as string-based
The try tag understands class-based exceptions, as well as string-based
exceptions. Note: the 'raise' tag raises string-based exceptions.
exceptions. Note: the 'raise' tag raises string-based exceptions.
Inside the except blocks information about the error is available via
Inside the except blocks information about the error is available via
three variables.
three variables.
'error_type' -- This variable is the name of the exception caught.
'error_type' -- This variable is the name of the exception caught.
'error_value' -- This is the caught exception's value.
'error_value' -- This is the caught exception's value.
'error_tb' -- This is a traceback for the caught exception.
'error_tb' -- This is a traceback for the caught exception.
The optional else block is rendered when no exception occurs in the
The optional else block is rendered when no exception occurs in the
try block. Exceptions in the else block are not handled by the preceding
try block. Exceptions in the else block are not handled by the preceding
except blocks.
except blocks.
...
@@ -78,10 +78,10 @@ class Try:
...
@@ -78,10 +78,10 @@ class Try:
lost.
lost.
Original version by Jordan B. Baker.
Original version by Jordan B. Baker.
Try..finally and try..else implementation by Martijn Pieters.
Try..finally and try..else implementation by Martijn Pieters.
"""
"""
name
=
'try'
name
=
'try'
blockContinuations
=
'except'
,
'else'
,
'finally'
blockContinuations
=
'except'
,
'else'
,
'finally'
finallyBlock
=
None
finallyBlock
=
None
...
@@ -158,7 +158,7 @@ class Try:
...
@@ -158,7 +158,7 @@ class Try:
errname
=
t
.
__name__
errname
=
t
.
__name__
handler
=
self
.
find_handler
(
t
)
handler
=
self
.
find_handler
(
t
)
if
handler
is
None
:
if
handler
is
None
:
# we didn't find a handler, so reraise the error
# we didn't find a handler, so reraise the error
raise
raise
...
@@ -181,7 +181,7 @@ class Try:
...
@@ -181,7 +181,7 @@ class Try:
return
result
return
result
else
:
else
:
return
result
+
render_blocks
(
self
.
elseBlock
,
md
)
return
result
+
render_blocks
(
self
.
elseBlock
,
md
)
def
render_try_finally
(
self
,
md
):
def
render_try_finally
(
self
,
md
):
result
=
''
result
=
''
# first try to render the first block
# first try to render the first block
...
@@ -202,13 +202,13 @@ class Try:
...
@@ -202,13 +202,13 @@ class Try:
return
None
return
None
for
e
,
h
in
self
.
handlers
:
for
e
,
h
in
self
.
handlers
:
if
e
==
exception
.
__name__
or
e
==
''
or
self
.
match_base
(
exception
,
e
):
if
e
==
exception
.
__name__
or
e
==
''
or
self
.
match_base
(
exception
,
e
):
return
h
return
h
return
None
return
None
def
match_base
(
self
,
exception
,
name
):
def
match_base
(
self
,
exception
,
name
):
for
base
in
exception
.
__bases__
:
for
base
in
exception
.
__bases__
:
if
base
.
__name__
==
name
or
self
.
match_base
(
base
,
name
):
if
base
.
__name__
==
name
or
self
.
match_base
(
base
,
name
):
return
1
return
1
return
None
return
None
__call__
=
render
__call__
=
render
lib/python/DocumentTemplate/DT_UI.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Machinery to support through-the-web editing
__doc__
=
'''Machinery to support through-the-web editing
$Id: DT_UI.py,v 1.1
1 2001/11/28 15:50:55 matt Exp $'''
$Id: DT_UI.py,v 1.1
2 2002/08/14 22:29:52 mj Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
from
DT_HTML
import
HTML
from
DT_HTML
import
HTML
...
@@ -35,13 +35,13 @@ HTML._manage_editForm = HTML(
...
@@ -35,13 +35,13 @@ HTML._manage_editForm = HTML(
</HEAD>
</HEAD>
<BODY bgcolor="#FFFFFF">
<BODY bgcolor="#FFFFFF">
<!--#var document_template_edit_header-->
<!--#var document_template_edit_header-->
<FORM name="editform" ACTION="<!--#var URL1-->/manage_edit" METHOD="POST">
<FORM name="editform" ACTION="<!--#var URL1-->/manage_edit" METHOD="POST">
<!--#var document_template_form_header-->
<!--#var document_template_form_header-->
Document template source:
Document template source:
<center>
<center>
<br>
<br>
<TEXTAREA NAME="data:text" cols="<!--#var document_template_edit_width-->"
<TEXTAREA NAME="data:text" cols="<!--#var document_template_edit_width-->"
rows="20"><!--#var __str__--></TEXTAREA>
rows="20"><!--#var __str__--></TEXTAREA>
<br>
<br>
...
@@ -50,12 +50,12 @@ HTML._manage_editForm = HTML(
...
@@ -50,12 +50,12 @@ HTML._manage_editForm = HTML(
<INPUT NAME="dt_edit_name" TYPE="HIDDEN"
<INPUT NAME="dt_edit_name" TYPE="HIDDEN"
VALUE="<!--#var URL1-->">
VALUE="<!--#var URL1-->">
<!--#if FactoryDefaultString-->
<!--#if FactoryDefaultString-->
<INPUT NAME=SUBMIT TYPE="SUBMIT"
<INPUT NAME=SUBMIT TYPE="SUBMIT"
VALUE="<!--#var FactoryDefaultString-->">
VALUE="<!--#var FactoryDefaultString-->">
<!--#/if FactoryDefaultString-->
<!--#/if FactoryDefaultString-->
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Cancel">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Cancel">
<!--#if HTTP_REFERER-->
<!--#if HTTP_REFERER-->
<INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"
<INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"
VALUE="<!--#var HTTP_REFERER-->">
VALUE="<!--#var HTTP_REFERER-->">
<!--#else HTTP_REFERER-->
<!--#else HTTP_REFERER-->
<!--#if URL1-->
<!--#if URL1-->
...
@@ -65,10 +65,10 @@ HTML._manage_editForm = HTML(
...
@@ -65,10 +65,10 @@ HTML._manage_editForm = HTML(
<!--#/if HTTP_REFERER-->
<!--#/if HTTP_REFERER-->
</center>
</center>
</FORM>
</FORM>
<BR CLEAR="ALL">
<BR CLEAR="ALL">
<!--#var document_template_edit_footer-->
<!--#var document_template_edit_footer-->
</BODY>
</BODY>
</HTML>"""
,)
</HTML>"""
,)
...
...
lib/python/DocumentTemplate/DT_Util.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''$Id: DT_Util.py,v 1.8
7 2002/08/01 16:00:39 mj Exp $'''
'''$Id: DT_Util.py,v 1.8
8 2002/08/14 22:29:52 mj Exp $'''
__version__
=
'$Revision: 1.8
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.8
8
$'
[
11
:
-
2
]
import
re
,
os
import
re
,
os
from
html_quote
import
html_quote
,
ustr
# for import by other modules, dont remove!
from
html_quote
import
html_quote
,
ustr
# for import by other modules, dont remove!
...
@@ -234,7 +234,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -234,7 +234,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
# # Fix up something like: <!--#in expr="whatever" mapping-->
# # Fix up something like: <!--#in expr="whatever" mapping-->
# params[params['']]=default_unnamed
# params[params['']]=default_unnamed
# del params['']
# del params['']
if
used
(
''
):
if
used
(
''
):
v
=
params
[
''
]
v
=
params
[
''
]
...
@@ -257,7 +257,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -257,7 +257,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
'that doesn
\
'
t support expr attributes.'
,
'that doesn
\
'
t support expr attributes.'
,
tag
)
tag
)
else
:
# name shorthand
else
:
# name shorthand
if
used
(
attr
):
if
used
(
attr
):
raise
ParseError
,
(
'Two %s values were given'
%
attr
,
tag
)
raise
ParseError
,
(
'Two %s values were given'
%
attr
,
tag
)
if
expr
:
if
expr
:
...
@@ -277,7 +277,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -277,7 +277,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
name
=
params
[
'expr'
]
name
=
params
[
'expr'
]
expr
=
Eval
(
name
)
expr
=
Eval
(
name
)
return
name
,
expr
return
name
,
expr
raise
ParseError
,
(
'No %s given'
%
attr
,
tag
)
raise
ParseError
,
(
'No %s given'
%
attr
,
tag
)
Expr_doc
=
"""
Expr_doc
=
"""
...
@@ -308,20 +308,20 @@ Python expression support
...
@@ -308,20 +308,20 @@ Python expression support
mapping object. This variable can be useful for accessing objects
mapping object. This variable can be useful for accessing objects
in a document template namespace that have names that are not legal
in a document template namespace that have names that are not legal
Python variable names::
Python variable names::
<!--#var expr="_['sequence-number']*5"-->
<!--#var expr="_['sequence-number']*5"-->
This variable also has attributes that provide access to standard
This variable also has attributes that provide access to standard
utility objects. These attributes include:
utility objects. These attributes include:
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
'round', and 'str' from the standard Python builtin module.
'round', and 'str' from the standard Python builtin module.
- Special security-aware versions of 'getattr' and 'hasattr',
- Special security-aware versions of 'getattr' and 'hasattr',
- The Python 'string', 'math', and 'whrandom' modules, and
- The Python 'string', 'math', and 'whrandom' modules, and
- A special function, 'test', that supports if-then expressions.
- A special function, 'test', that supports if-then expressions.
The 'test' function accepts any number of arguments. If the
The 'test' function accepts any number of arguments. If the
first argument is true, then the second argument is returned,
first argument is true, then the second argument is returned,
...
@@ -329,10 +329,10 @@ Python expression support
...
@@ -329,10 +329,10 @@ Python expression support
argument is returned, and so on. If there is an odd number of
argument is returned, and so on. If there is an odd number of
arguments, then the last argument is returned in the case that
arguments, then the last argument is returned in the case that
none of the tested arguments is true, otherwise None is
none of the tested arguments is true, otherwise None is
returned.
returned.
For example, to convert a value to lower case::
For example, to convert a value to lower case::
<!--#var expr="_.string.lower(title)"-->
<!--#var expr="_.string.lower(title)"-->
"""
"""
...
@@ -370,7 +370,7 @@ def parse_params(text,
...
@@ -370,7 +370,7 @@ def parse_params(text,
result
=
result
or
{}
result
=
result
or
{}
# HACK - we precalculate all matches. Maybe we don't need them
# HACK - we precalculate all matches. Maybe we don't need them
# all. This should be fixed for performance issues
# all. This should be fixed for performance issues
mo_p
=
parmre
.
match
(
text
)
mo_p
=
parmre
.
match
(
text
)
...
@@ -393,7 +393,7 @@ def parse_params(text,
...
@@ -393,7 +393,7 @@ def parse_params(text,
if
parms
.
has_key
(
name
):
if
parms
.
has_key
(
name
):
if
parms
[
name
]
is
None
:
raise
ParseError
,
(
if
parms
[
name
]
is
None
:
raise
ParseError
,
(
'Attribute %s requires a value'
%
name
,
tag
)
'Attribute %s requires a value'
%
name
,
tag
)
result
[
name
]
=
parms
[
name
]
result
[
name
]
=
parms
[
name
]
else
:
raise
ParseError
,
(
else
:
raise
ParseError
,
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
...
@@ -410,7 +410,7 @@ def parse_params(text,
...
@@ -410,7 +410,7 @@ def parse_params(text,
else
:
else
:
if
not
text
or
not
text
.
strip
():
return
result
if
not
text
or
not
text
.
strip
():
return
result
raise
ParseError
,
(
'invalid parameter: "%s"'
%
text
,
tag
)
raise
ParseError
,
(
'invalid parameter: "%s"'
%
text
,
tag
)
if
not
parms
.
has_key
(
name
):
if
not
parms
.
has_key
(
name
):
raise
ParseError
,
(
raise
ParseError
,
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
...
@@ -420,7 +420,7 @@ def parse_params(text,
...
@@ -420,7 +420,7 @@ def parse_params(text,
if
type
(
p
)
is
not
ListType
or
p
:
if
type
(
p
)
is
not
ListType
or
p
:
raise
ParseError
,
(
raise
ParseError
,
(
'Duplicate values for attribute "%s"'
%
name
,
tag
)
'Duplicate values for attribute "%s"'
%
name
,
tag
)
result
[
name
]
=
value
result
[
name
]
=
value
text
=
text
[
l
:].
strip
()
text
=
text
[
l
:].
strip
()
...
...
lib/python/DocumentTemplate/DT_Var.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Variable insertion parameters
__doc__
=
'''Variable insertion parameters
...
@@ -58,7 +58,7 @@ __doc__='''Variable insertion parameters
...
@@ -58,7 +58,7 @@ __doc__='''Variable insertion parameters
- Cannot be formatted with the specified format, and
- Cannot be formatted with the specified format, and
- Are either the special Python value 'None' or
- Are either the special Python value 'None' or
are false and yield an empty string when converted to
are false and yield an empty string when converted to
a string.
a string.
...
@@ -89,12 +89,12 @@ __doc__='''Variable insertion parameters
...
@@ -89,12 +89,12 @@ __doc__='''Variable insertion parameters
value after formatting has been applied. These parameters
value after formatting has been applied. These parameters
are supplied without arguments.
are supplied without arguments.
'lower' -- cause all upper-case letters to be converted to lower case.
'lower' -- cause all upper-case letters to be converted to lower case.
'upper' -- cause all upper-case letters to be converted to lower case.
'upper' -- cause all upper-case letters to be converted to lower case.
'capitalize' -- cause the first character of the inserted value
'capitalize' -- cause the first character of the inserted value
to be converted to upper case.
to be converted to upper case.
'spacify' -- cause underscores in the inserted value to be
'spacify' -- cause underscores in the inserted value to be
converted to spaces.
converted to spaces.
...
@@ -140,7 +140,7 @@ __doc__='''Variable insertion parameters
...
@@ -140,7 +140,7 @@ __doc__='''Variable insertion parameters
truncation, the value given for the 'etc' attribute is added to
truncation, the value given for the 'etc' attribute is added to
the string. If the 'etc' attribute is not provided, then '...'
the string. If the 'etc' attribute is not provided, then '...'
is used. For example, if the value of spam is
is used. For example, if the value of spam is
'"blah blah blah blah"', then the tag
'"blah blah blah blah"', then the tag
'<dtml-var spam size=10>' inserts '"blah blah ..."'.
'<dtml-var spam size=10>' inserts '"blah blah ..."'.
...
@@ -148,11 +148,11 @@ Evaluating expressions without rendering results
...
@@ -148,11 +148,11 @@ Evaluating expressions without rendering results
A 'call' tag is provided for evaluating named objects or expressions
A 'call' tag is provided for evaluating named objects or expressions
without rendering the result.
without rendering the result.
'''
# '
'''
# '
__rcs_id__
=
'$Id: DT_Var.py,v 1.5
6 2002/08/14 16:34:20 rdmurray
Exp $'
__rcs_id__
=
'$Id: DT_Var.py,v 1.5
7 2002/08/14 22:29:52 mj
Exp $'
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
7
$'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
str
,
ustr
from
DT_Util
import
parse_params
,
name_param
,
str
,
ustr
import
os
,
string
,
re
,
sys
import
os
,
string
,
re
,
sys
...
@@ -163,7 +163,7 @@ from types import StringType
...
@@ -163,7 +163,7 @@ from types import StringType
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
ZPublisher.TaintedString
import
TaintedString
from
ZPublisher.TaintedString
import
TaintedString
class
Var
:
class
Var
:
name
=
'var'
name
=
'var'
expr
=
None
expr
=
None
...
@@ -177,7 +177,7 @@ class Var:
...
@@ -177,7 +177,7 @@ class Var:
url_unquote_plus
=
1
,
missing
=
''
,
url_unquote_plus
=
1
,
missing
=
''
,
newline_to_br
=
1
,
url
=
1
)
newline_to_br
=
1
,
url
=
1
)
self
.
args
=
args
self
.
args
=
args
self
.
modifiers
=
tuple
(
self
.
modifiers
=
tuple
(
map
(
lambda
t
:
t
[
1
],
map
(
lambda
t
:
t
[
1
],
filter
(
lambda
m
,
args
=
args
,
used
=
args
.
has_key
:
filter
(
lambda
m
,
args
=
args
,
used
=
args
.
has_key
:
...
@@ -226,7 +226,7 @@ class Var:
...
@@ -226,7 +226,7 @@ class Var:
if
have_arg
(
'null'
)
and
not
val
and
val
!=
0
:
if
have_arg
(
'null'
)
and
not
val
and
val
!=
0
:
# check for null (false but not zero, including None, [], '')
# check for null (false but not zero, including None, [], '')
return
args
[
'null'
]
return
args
[
'null'
]
# handle special formats defined using fmt= first
# handle special formats defined using fmt= first
if
have_arg
(
'fmt'
):
if
have_arg
(
'fmt'
):
...
@@ -248,7 +248,7 @@ class Var:
...
@@ -248,7 +248,7 @@ class Var:
else
:
else
:
val
=
special_formats
[
fmt
](
val
,
name
,
md
)
val
=
special_formats
[
fmt
](
val
,
name
,
md
)
elif
fmt
==
''
:
val
=
''
elif
fmt
==
''
:
val
=
''
else
:
else
:
if
isinstance
(
val
,
TaintedString
):
if
isinstance
(
val
,
TaintedString
):
val
=
TaintedString
(
fmt
%
val
)
val
=
TaintedString
(
fmt
%
val
)
else
:
else
:
...
@@ -317,12 +317,12 @@ class Var:
...
@@ -317,12 +317,12 @@ class Var:
if
isinstance
(
val
,
TaintedString
):
if
isinstance
(
val
,
TaintedString
):
val
=
val
.
quoted
()
val
=
val
.
quoted
()
return
val
return
val
__call__
=
render
__call__
=
render
class
Call
:
class
Call
:
name
=
'call'
name
=
'call'
expr
=
None
expr
=
None
...
@@ -379,7 +379,7 @@ def thousands_commas(v, name='(Unknown name)', md={},
...
@@ -379,7 +379,7 @@ def thousands_commas(v, name='(Unknown name)', md={},
v
=
v
[:
l
+
1
]
+
','
+
v
[
l
+
1
:]
v
=
v
[:
l
+
1
]
+
','
+
v
[
l
+
1
:]
mo
=
thou
(
v
)
mo
=
thou
(
v
)
return
v
+
s
return
v
+
s
def
whole_dollars_with_commas
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
whole_dollars_with_commas
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
try
:
v
=
"$%d"
%
v
try
:
v
=
"$%d"
%
v
except
:
v
=
''
except
:
v
=
''
...
@@ -399,7 +399,7 @@ def len_comma(v, name='(Unknown name)', md={}):
...
@@ -399,7 +399,7 @@ def len_comma(v, name='(Unknown name)', md={}):
StructuredText
=
None
StructuredText
=
None
def
structured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
structured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
global
StructuredText
global
StructuredText
if
StructuredText
is
None
:
if
StructuredText
is
None
:
from
StructuredText.StructuredText
import
HTML
from
StructuredText.StructuredText
import
HTML
if
isinstance
(
v
,
StringType
):
txt
=
v
if
isinstance
(
v
,
StringType
):
txt
=
v
...
@@ -408,11 +408,11 @@ def structured_text(v, name='(Unknown name)', md={}):
...
@@ -408,11 +408,11 @@ def structured_text(v, name='(Unknown name)', md={}):
txt
=
aq_base
(
v
).
read_raw
()
txt
=
aq_base
(
v
).
read_raw
()
else
:
txt
=
str
(
v
)
else
:
txt
=
str
(
v
)
return
HTML
(
txt
,
return
HTML
(
txt
,
level
=
int
(
os
.
environ
.
get
(
'STX_DEFAULT_LEVEL'
,
3
)),
level
=
int
(
os
.
environ
.
get
(
'STX_DEFAULT_LEVEL'
,
3
)),
header
=
0
)
header
=
0
)
def
sql_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
sql_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
"""Quote single quotes in a string by doubling them.
"""Quote single quotes in a string by doubling them.
...
@@ -457,15 +457,15 @@ class Comment:
...
@@ -457,15 +457,15 @@ class Comment:
The 'comment' tag can be used to simply include comments
The 'comment' tag can be used to simply include comments
in DTML source.
in DTML source.
For example::
For example::
<!--#comment-->
<!--#comment-->
This text is not rendered.
This text is not rendered.
<!--#/comment-->
<!--#/comment-->
'''
'''
name
=
'comment'
name
=
'comment'
blockContinuations
=
()
blockContinuations
=
()
...
...
lib/python/DocumentTemplate/DT_With.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''Nested namespace access
'''Nested namespace access
...
@@ -31,10 +31,10 @@
...
@@ -31,10 +31,10 @@
should be treated as mapping object, rather than as an object with
should be treated as mapping object, rather than as an object with
named attributes.
named attributes.
'''
'''
__rcs_id__
=
'$Id: DT_With.py,v 1.1
4 2001/11/28 15:50:55 matt
Exp $'
__rcs_id__
=
'$Id: DT_With.py,v 1.1
5 2002/08/14 22:29:52 mj
Exp $'
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
InstanceDict
,
render_blocks
,
str
from
DT_Util
import
parse_params
,
name_param
,
InstanceDict
,
render_blocks
,
str
from
DT_Util
import
TemplateDict
from
DT_Util
import
TemplateDict
...
@@ -43,7 +43,7 @@ class With:
...
@@ -43,7 +43,7 @@ class With:
name
=
'with'
name
=
'with'
mapping
=
None
mapping
=
None
only
=
0
only
=
0
def
__init__
(
self
,
blocks
):
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
,
expr
=
''
,
mapping
=
1
,
only
=
1
)
args
=
parse_params
(
args
,
name
=
''
,
expr
=
''
,
mapping
=
1
,
only
=
1
)
...
...
lib/python/DocumentTemplate/DTtestExpr.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''short description
__doc__
=
'''short description
$Id: DTtestExpr.py,v 1.
7 2001/11/28 15:50:55 matt
Exp $'''
$Id: DTtestExpr.py,v 1.
8 2002/08/14 22:29:52 mj
Exp $'''
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
from
DocumentTemplate
import
*
from
DocumentTemplate
import
*
import
sys
import
sys
...
@@ -47,7 +47,7 @@ def test4():
...
@@ -47,7 +47,7 @@ def test4():
print
'-'
*
77
print
'-'
*
77
print
i
,
h
(
level
=
i
)
print
i
,
h
(
level
=
i
)
print
'-'
*
77
print
'-'
*
77
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
try
:
command
=
sys
.
argv
[
1
]
try
:
command
=
sys
.
argv
[
1
]
...
...
lib/python/DocumentTemplate/DocumentTemplate.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''Document templates with fill-in fields
'''Document templates with fill-in fields
...
@@ -60,7 +60,7 @@ Two source formats are supported:
...
@@ -60,7 +60,7 @@ Two source formats are supported:
<!--#var total fmt=12.2f-->
<!--#var total fmt=12.2f-->
is used to insert the variable 'total' with the C format
is used to insert the variable 'total' with the C format
'12.2f'.
'12.2f'.
Document templates support conditional and sequence insertion
Document templates support conditional and sequence insertion
...
@@ -105,7 +105,7 @@ Document Templates may be created 4 ways:
...
@@ -105,7 +105,7 @@ Document Templates may be created 4 ways:
'''
'''
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
ParseError
=
'Document Template Parse Error'
ParseError
=
'Document Template Parse Error'
...
...
lib/python/DocumentTemplate/VSEval.py
View file @
2639fcb7
...
@@ -7,4 +7,3 @@ def careful_mul(env, *factors):
...
@@ -7,4 +7,3 @@ def careful_mul(env, *factors):
for
factor
in
factors
:
for
factor
in
factors
:
r
=
r
*
factor
r
=
r
*
factor
return
r
return
r
lib/python/DocumentTemplate/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Package wrapper for Document Template
__doc__
=
'''Package wrapper for Document Template
This wrapper allows the (now many) document template modules to be
This wrapper allows the (now many) document template modules to be
segregated in a separate package.
segregated in a separate package.
$Id: __init__.py,v 1.1
6 2001/11/28 15:50:55 matt
Exp $'''
$Id: __init__.py,v 1.1
7 2002/08/14 22:29:53 mj
Exp $'''
__version__
=
'$Revision: 1.1
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
7
$'
[
11
:
-
2
]
import
ExtensionClass
# work-around for import bug.
import
ExtensionClass
# work-around for import bug.
from
DocumentTemplate
import
String
,
File
,
HTML
,
HTMLDefault
,
HTMLFile
from
DocumentTemplate
import
String
,
File
,
HTML
,
HTMLDefault
,
HTMLFile
lib/python/DocumentTemplate/html_quote.py
View file @
2639fcb7
...
@@ -5,4 +5,3 @@ from ustr import ustr
...
@@ -5,4 +5,3 @@ from ustr import ustr
def
html_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
html_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
return
escape
(
ustr
(
v
),
1
)
return
escape
(
ustr
(
v
),
1
)
lib/python/DocumentTemplate/pDocumentTemplate.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Python implementations of document template some features
__doc__
=
'''Python implementations of document template some features
$Id: pDocumentTemplate.py,v 1.3
5 2002/03/27 10:14:02 htrd
Exp $'''
$Id: pDocumentTemplate.py,v 1.3
6 2002/08/14 22:29:53 mj
Exp $'''
__version__
=
'$Revision: 1.3
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
import
sys
,
types
import
sys
,
types
...
@@ -69,7 +69,7 @@ class InstanceDict:
...
@@ -69,7 +69,7 @@ class InstanceDict:
cache
=
self
.
cache
cache
=
self
.
cache
if
cache
.
has_key
(
key
):
return
cache
[
key
]
if
cache
.
has_key
(
key
):
return
cache
[
key
]
inst
=
self
.
self
inst
=
self
.
self
if
key
[:
1
]
==
'_'
:
if
key
[:
1
]
==
'_'
:
...
@@ -115,14 +115,14 @@ class MultiMapping:
...
@@ -115,14 +115,14 @@ class MultiMapping:
return
kz
return
kz
class
DictInstance
:
class
DictInstance
:
def
__init__
(
self
,
mapping
):
def
__init__
(
self
,
mapping
):
self
.
__d
=
mapping
self
.
__d
=
mapping
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
try
:
return
self
.
__d
[
name
]
try
:
return
self
.
__d
[
name
]
except
KeyError
:
raise
AttributeError
,
name
except
KeyError
:
raise
AttributeError
,
name
class
TemplateDict
:
class
TemplateDict
:
level
=
0
level
=
0
...
@@ -152,10 +152,10 @@ class TemplateDict:
...
@@ -152,10 +152,10 @@ class TemplateDict:
return
v
return
v
def
__len__
(
self
):
def
__len__
(
self
):
total
=
0
total
=
0
for
d
in
self
.
dicts
.
dicts
:
for
d
in
self
.
dicts
.
dicts
:
total
=
total
+
len
(
d
)
total
=
total
+
len
(
d
)
return
total
return
total
def
has_key
(
self
,
key
):
def
has_key
(
self
,
key
):
try
:
try
:
...
@@ -163,7 +163,7 @@ class TemplateDict:
...
@@ -163,7 +163,7 @@ class TemplateDict:
except
KeyError
:
except
KeyError
:
return
0
return
0
return
1
return
1
getitem
=
__getitem__
getitem
=
__getitem__
def
__call__
(
self
,
*
args
,
**
kw
):
def
__call__
(
self
,
*
args
,
**
kw
):
...
...
lib/python/DocumentTemplate/sequence/SortEx.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Advanced sort support by Oleg Broytmann <phd@@phd.pp.ru> 23 Apr 2001
Advanced sort support by Oleg Broytmann <phd@@phd.pp.ru> 23 Apr 2001
eg Sort(sequence, (("akey", "nocase"), ("anotherkey", "cmp", "desc")))
eg Sort(sequence, (("akey", "nocase"), ("anotherkey", "cmp", "desc")))
$Id: SortEx.py,v 1.
4 2002/02/07 17:47:42 andreasjung
Exp $
$Id: SortEx.py,v 1.
5 2002/08/14 22:29:53 mj
Exp $
"""
"""
...
@@ -36,19 +36,19 @@ def sort(sequence, sort=(), _=None, mapping=0):
...
@@ -36,19 +36,19 @@ def sort(sequence, sort=(), _=None, mapping=0):
allowed values:
allowed values:
- "cmp" -- the standard comparison function (default)
- "cmp" -- the standard comparison function (default)
- "nocase" -- case-insensitive comparison
- "nocase" -- case-insensitive comparison
- "strcoll" or "locale" -- locale-aware string comparison
- "strcoll" or "locale" -- locale-aware string comparison
- "strcoll_nocase" or "locale_nocase" -- locale-aware case-insensitive
- "strcoll_nocase" or "locale_nocase" -- locale-aware case-insensitive
string comparison
string comparison
- "xxx" -- a user-defined comparison function
- "xxx" -- a user-defined comparison function
- direction -- defines the sort direction for the key (optional).
- direction -- defines the sort direction for the key (optional).
(allowed values: "asc" (default) , "desc")
(allowed values: "asc" (default) , "desc")
"""
"""
...
@@ -60,7 +60,7 @@ def sort(sequence, sort=(), _=None, mapping=0):
...
@@ -60,7 +60,7 @@ def sort(sequence, sort=(), _=None, mapping=0):
need_sortfunc
=
1
need_sortfunc
=
1
break
break
sortfields
=
sort
# multi sort = key1,key2
sortfields
=
sort
# multi sort = key1,key2
multsort
=
len
(
sortfields
)
>
1
# flag: is multiple sort
multsort
=
len
(
sortfields
)
>
1
# flag: is multiple sort
if
need_sortfunc
:
if
need_sortfunc
:
...
@@ -92,25 +92,25 @@ def sort(sequence, sort=(), _=None, mapping=0):
...
@@ -92,25 +92,25 @@ def sort(sequence, sort=(), _=None, mapping=0):
v
=
client
v
=
client
if
sort
:
if
sort
:
if
multsort
:
# More than one sort key.
if
multsort
:
# More than one sort key.
k
=
[]
k
=
[]
for
sk
in
sortfields
:
for
sk
in
sortfields
:
try
:
try
:
if
mapping
:
akey
=
v
[
sk
]
if
mapping
:
akey
=
v
[
sk
]
else
:
akey
=
getattr
(
v
,
sk
)
else
:
akey
=
getattr
(
v
,
sk
)
except
AttributeError
,
KeyError
:
akey
=
None
except
AttributeError
,
KeyError
:
akey
=
None
if
not
basic_type
(
akey
):
if
not
basic_type
(
akey
):
try
:
akey
=
akey
()
try
:
akey
=
akey
()
except
:
pass
except
:
pass
k
.
append
(
akey
)
k
.
append
(
akey
)
else
:
# One sort key.
else
:
# One sort key.
try
:
try
:
if
mapping
:
k
=
v
[
sort
]
if
mapping
:
k
=
v
[
sort
]
else
:
k
=
getattr
(
v
,
sort
)
else
:
k
=
getattr
(
v
,
sort
)
except
AttributeError
,
KeyError
:
k
=
None
except
AttributeError
,
KeyError
:
k
=
None
if
not
basic_type
(
type
(
k
)):
if
not
basic_type
(
type
(
k
)):
try
:
k
=
k
()
try
:
k
=
k
()
except
:
pass
except
:
pass
s
.
append
((
k
,
client
))
s
.
append
((
k
,
client
))
...
@@ -122,7 +122,7 @@ def sort(sequence, sort=(), _=None, mapping=0):
...
@@ -122,7 +122,7 @@ def sort(sequence, sort=(), _=None, mapping=0):
sequence
=
[]
sequence
=
[]
for
k
,
client
in
s
:
for
k
,
client
in
s
:
sequence
.
append
(
client
)
sequence
.
append
(
client
)
return
sequence
return
sequence
...
@@ -219,5 +219,3 @@ class SortBy:
...
@@ -219,5 +219,3 @@ class SortBy:
# all functions returned 0 - identical sequences
# all functions returned 0 - identical sequences
return
0
return
0
lib/python/DocumentTemplate/sequence/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
...
...
lib/python/DocumentTemplate/sequence/tests/testSequence.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
os
,
sys
,
unittest
import
os
,
sys
,
unittest
...
@@ -30,7 +30,7 @@ class TestCase( unittest.TestCase ):
...
@@ -30,7 +30,7 @@ class TestCase( unittest.TestCase ):
def
tearDown
(
self
):
def
tearDown
(
self
):
"""
"""
"""
"""
def
test1
(
self
):
def
test1
(
self
):
"test1"
"test1"
assert
res1
==
SortEx
(
wordlist
)
assert
res1
==
SortEx
(
wordlist
)
...
@@ -42,7 +42,7 @@ class TestCase( unittest.TestCase ):
...
@@ -42,7 +42,7 @@ class TestCase( unittest.TestCase ):
def
test3
(
self
):
def
test3
(
self
):
"test3"
"test3"
assert
res3
==
SortEx
(
wordlist
,
((
"key"
,
"cmp"
),),
mapping
=
1
)
assert
res3
==
SortEx
(
wordlist
,
((
"key"
,
"cmp"
),),
mapping
=
1
)
def
test4
(
self
):
def
test4
(
self
):
"test4"
"test4"
assert
res4
==
SortEx
(
wordlist
,
((
"key"
,
"cmp"
,
"desc"
),),
mapping
=
1
)
assert
res4
==
SortEx
(
wordlist
,
((
"key"
,
"cmp"
,
"desc"
),),
mapping
=
1
)
...
@@ -60,7 +60,7 @@ class TestCase( unittest.TestCase ):
...
@@ -60,7 +60,7 @@ class TestCase( unittest.TestCase ):
"test7"
"test7"
def
myCmp
(
s1
,
s2
):
def
myCmp
(
s1
,
s2
):
return
-
cmp
(
s1
,
s2
)
return
-
cmp
(
s1
,
s2
)
# Create namespace...
# Create namespace...
from
DocumentTemplate.DT_Util
import
TemplateDict
from
DocumentTemplate.DT_Util
import
TemplateDict
...
...
lib/python/DocumentTemplate/sequence/tests/ztestlib.py
View file @
2639fcb7
class
standard_html
:
# Base class for using with ZTemplates
class
standard_html
:
# Base class for using with ZTemplates
def
__init__
(
self
,
title
):
def
__init__
(
self
,
title
):
self
.
standard_html_header
=
"""<HTML>
self
.
standard_html_header
=
"""<HTML>
<HEAD>
<HEAD>
<TITLE>
<TITLE>
%s
%s
...
@@ -11,25 +9,25 @@ class standard_html: # Base class for using with ZTemplates
...
@@ -11,25 +9,25 @@ class standard_html: # Base class for using with ZTemplates
<BODY>"""
%
title
<BODY>"""
%
title
self
.
standard_html_footer
=
"""</BODY>
self
.
standard_html_footer
=
"""</BODY>
</HTML>"""
</HTML>"""
self
.
title
=
title
self
.
title
=
title
def
test
(
s
):
def
test
(
s
):
outfile
=
open
(
"test.out"
,
'w'
)
outfile
=
open
(
"test.out"
,
'w'
)
outfile
.
write
(
s
)
outfile
.
write
(
s
)
outfile
.
close
()
outfile
.
close
()
def
exception
():
def
exception
():
import
sys
,
traceback
import
sys
,
traceback
exc_type
,
exc_value
,
exc_tb
=
sys
.
exc_info
()
exc_type
,
exc_value
,
exc_tb
=
sys
.
exc_info
()
outfile
=
open
(
"test.err"
,
'w'
)
outfile
=
open
(
"test.err"
,
'w'
)
traceback
.
print_exception
(
exc_type
,
exc_value
,
exc_tb
,
None
,
outfile
)
traceback
.
print_exception
(
exc_type
,
exc_value
,
exc_tb
,
None
,
outfile
)
outfile
.
close
()
outfile
.
close
()
wordlist
=
[
wordlist
=
[
...
...
lib/python/DocumentTemplate/tests/testDTML.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Document Template Tests
"""Document Template Tests
"""
"""
__rcs_id__
=
'$Id: testDTML.py,v 1.1
3 2002/08/14 15:46:58 chrism
Exp $'
__rcs_id__
=
'$Id: testDTML.py,v 1.1
4 2002/08/14 22:29:53 mj
Exp $'
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
import
sys
,
os
import
sys
,
os
import
unittest
import
unittest
...
@@ -259,7 +259,7 @@ class DTMLTests (unittest.TestCase):
...
@@ -259,7 +259,7 @@ class DTMLTests (unittest.TestCase):
<dtml-var expr="'http%3A%2F%2Fwww.zope.org%3Fa%3Db+123'" fmt=url-unquote-plus>
<dtml-var expr="'http%3A%2F%2Fwww.zope.org%3Fa%3Db+123'" fmt=url-unquote-plus>
"""
"""
)
)
expected
=
(
expected
=
(
"""
"""
http://www.zope.org?a=b 123
http://www.zope.org?a=b 123
...
@@ -277,7 +277,7 @@ class DTMLTests (unittest.TestCase):
...
@@ -277,7 +277,7 @@ class DTMLTests (unittest.TestCase):
<dtml-var expr="'http%3A%2F%2Fwww.zope.org%3Fa%3Db+123'" url_unquote_plus>
<dtml-var expr="'http%3A%2F%2Fwww.zope.org%3Fa%3Db+123'" url_unquote_plus>
"""
"""
)
)
expected
=
(
expected
=
(
"""
"""
http://www.zope.org?a=b 123
http://www.zope.org?a=b 123
...
@@ -285,7 +285,7 @@ class DTMLTests (unittest.TestCase):
...
@@ -285,7 +285,7 @@ class DTMLTests (unittest.TestCase):
)
)
self
.
assertEqual
(
html1
(),
expected
)
self
.
assertEqual
(
html1
(),
expected
)
self
.
assertEqual
(
html2
(),
expected
)
self
.
assertEqual
(
html2
(),
expected
)
def
test_fmt
(
self
):
def
test_fmt
(
self
):
html
=
self
.
doc_class
(
html
=
self
.
doc_class
(
...
@@ -499,7 +499,7 @@ foo bar
...
@@ -499,7 +499,7 @@ foo bar
"""
"""
result
=
self
.
doc_class
(
html
)(
xxx
=
xxx
,
data
=
{})
result
=
self
.
doc_class
(
html
)(
xxx
=
xxx
,
data
=
{})
assert
result
==
expected
,
result
assert
result
==
expected
,
result
def
testBasicStringIn
(
self
):
def
testBasicStringIn
(
self
):
data
=
(
data
=
(
d
(
name
=
'jim'
,
age
=
39
),
d
(
name
=
'jim'
,
age
=
39
),
...
@@ -522,7 +522,7 @@ foo bar
...
@@ -522,7 +522,7 @@ foo bar
"""
"""
result
=
String
(
s
)(
data
=
data
)
result
=
String
(
s
)(
data
=
data
)
assert
expected
==
result
,
result
assert
expected
==
result
,
result
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
DTMLTests
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
DTMLTests
)
)
...
...
lib/python/DocumentTemplate/tests/testDTMLUnicode.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Document Template Tests
"""Document Template Tests
"""
"""
__rcs_id__
=
'$Id: testDTMLUnicode.py,v 1.
2 2002/03/27 10:14:02 htrd
Exp $'
__rcs_id__
=
'$Id: testDTMLUnicode.py,v 1.
3 2002/08/14 22:29:53 mj
Exp $'
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
sys
,
os
import
sys
,
os
import
unittest
import
unittest
...
...
lib/python/DocumentTemplate/tests/testustr.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Document Template Tests
"""Document Template Tests
"""
"""
__rcs_id__
=
'$Id: testustr.py,v 1.
2 2002/03/27 10:14:02 htrd
Exp $'
__rcs_id__
=
'$Id: testustr.py,v 1.
3 2002/08/14 22:29:53 mj
Exp $'
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
sys
,
os
import
sys
,
os
import
unittest
import
unittest
...
...
lib/python/Products/PythonScripts/Extensions/RemotePS.py
View file @
2639fcb7
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
foobarsize = s.foo.bar.restricted_exec('len(context.objectIds())')
foobarsize = s.foo.bar.restricted_exec('len(context.objectIds())')
'''
'''
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.PythonScripts.PythonScript
import
PythonScript
from
string
import
join
from
string
import
join
...
...
lib/python/Products/PythonScripts/PythonScript.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python Scripts Product
"""Python Scripts Product
...
@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted
...
@@ -17,7 +17,7 @@ This product provides support for Script objects containing restricted
Python code.
Python code.
"""
"""
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
import
sys
,
os
,
traceback
,
re
,
marshal
import
sys
,
os
,
traceback
,
re
,
marshal
from
Globals
import
DTMLFile
,
MessageDialog
,
package_home
from
Globals
import
DTMLFile
,
MessageDialog
,
package_home
...
@@ -153,11 +153,11 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -153,11 +153,11 @@ class PythonScript(Script, Historical, Cacheable):
"""Replace the body of the script with the text in file."""
"""Replace the body of the script with the text in file."""
if
self
.
wl_isLocked
():
if
self
.
wl_isLocked
():
raise
ResourceLockedError
,
"The script is locked via WebDAV."
raise
ResourceLockedError
,
"The script is locked via WebDAV."
if
type
(
file
)
is
not
type
(
''
):
if
type
(
file
)
is
not
type
(
''
):
if
not
file
:
raise
ValueError
,
'File not specified'
if
not
file
:
raise
ValueError
,
'File not specified'
file
=
file
.
read
()
file
=
file
.
read
()
self
.
write
(
file
)
self
.
write
(
file
)
message
=
'Saved changes.'
message
=
'Saved changes.'
return
self
.
ZPythonScriptHTML_editForm
(
self
,
REQUEST
,
return
self
.
ZPythonScriptHTML_editForm
(
self
,
REQUEST
,
...
@@ -183,7 +183,7 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -183,7 +183,7 @@ class PythonScript(Script, Historical, Cacheable):
"""Parameters to test the script with."""
"""Parameters to test the script with."""
param_names
=
[]
param_names
=
[]
for
name
in
self
.
_params
.
split
(
','
):
for
name
in
self
.
_params
.
split
(
','
):
name
=
name
.
strip
()
name
=
name
.
strip
()
if
name
and
name
[
0
]
!=
'*'
and
re
.
match
(
'
\
w
'
,name):
if
name
and
name
[
0
]
!=
'*'
and
re
.
match
(
'
\
w
'
,name):
param_names.append(name.split('
=
', 1)[0])
param_names.append(name.split('
=
', 1)[0])
...
@@ -201,7 +201,7 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -201,7 +201,7 @@ class PythonScript(Script, Historical, Cacheable):
getattr(self, '
Script_magic
', None) != Script_magic):
getattr(self, '
Script_magic
', None) != Script_magic):
global _log_complaint
global _log_complaint
if _log_complaint:
if _log_complaint:
LOG(self.meta_type, INFO, _log_complaint)
LOG(self.meta_type, INFO, _log_complaint)
_log_complaint = 0
_log_complaint = 0
# Changes here won'
t
get
saved
,
unless
this
Script
is
edited
.
# Changes here won'
t
get
saved
,
unless
this
Script
is
edited
.
body
=
self
.
_body
.
rstrip
()
body
=
self
.
_body
.
rstrip
()
...
@@ -329,7 +329,7 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -329,7 +329,7 @@ class PythonScript(Script, Historical, Cacheable):
if
user
is
not
None
and
user
.
allowed
(
self
,
roles
):
if
user
is
not
None
and
user
.
allowed
(
self
,
roles
):
return
return
raise
'Forbidden'
,
(
'You are not authorized to change <em>%s</em> '
raise
'Forbidden'
,
(
'You are not authorized to change <em>%s</em> '
'because you do not have proxy roles.
\
n
<!--%s, %s-->'
'because you do not have proxy roles.
\
n
<!--%s, %s-->'
%
(
self
.
id
,
user
,
roles
))
%
(
self
.
id
,
user
,
roles
))
security
.
declareProtected
(
'Change proxy roles'
,
security
.
declareProtected
(
'Change proxy roles'
,
...
@@ -358,7 +358,7 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -358,7 +358,7 @@ class PythonScript(Script, Historical, Cacheable):
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
self
.
write
(
REQUEST
.
get
(
'BODY'
,
''
))
self
.
write
(
REQUEST
.
get
(
'BODY'
,
''
))
RESPONSE
.
setStatus
(
204
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
return
RESPONSE
manage_FTPput
=
PUT
manage_FTPput
=
PUT
...
@@ -449,7 +449,7 @@ class PythonScript(Script, Historical, Cacheable):
...
@@ -449,7 +449,7 @@ class PythonScript(Script, Historical, Cacheable):
hlines
=
[
'%s %s "%s"'
%
(
prefix
,
self
.
meta_type
,
self
.
id
)]
hlines
=
[
'%s %s "%s"'
%
(
prefix
,
self
.
meta_type
,
self
.
id
)]
mm
=
self
.
_metadata_map
().
items
()
mm
=
self
.
_metadata_map
().
items
()
mm
.
sort
()
mm
.
sort
()
for
kv
in
mm
:
for
kv
in
mm
:
hlines
.
append
(
'%s=%s'
%
kv
)
hlines
.
append
(
'%s=%s'
%
kv
)
if
self
.
errors
:
if
self
.
errors
:
hlines
.
append
(
''
)
hlines
.
append
(
''
)
...
...
lib/python/Products/PythonScripts/Utility.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Utility module for making simple security assertions for
"""Utility module for making simple security assertions for
Python scripts."""
Python scripts."""
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
# These have been relocated, and should be imported from AccessControl
# These have been relocated, and should be imported from AccessControl
...
...
lib/python/Products/PythonScripts/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Python Scripts Product Initialization
__doc__
=
'''Python Scripts Product Initialization
$Id: __init__.py,v 1.1
2 2002/06/20 14:48:38 Brian
Exp $'''
$Id: __init__.py,v 1.1
3 2002/08/14 22:25:08 mj
Exp $'''
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
PythonScript
import
PythonScript
try
:
try
:
...
@@ -43,7 +43,7 @@ def initialize(context):
...
@@ -43,7 +43,7 @@ def initialize(context):
global
_m
global
_m
_m
[
'recompile'
]
=
recompile
_m
[
'recompile'
]
=
recompile
_m
[
'recompile__roles__'
]
=
(
'Manager'
,)
_m
[
'recompile__roles__'
]
=
(
'Manager'
,)
# utility stuff
# utility stuff
def
recompile
(
self
):
def
recompile
(
self
):
...
...
lib/python/Products/PythonScripts/help/PythonScript.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
def
manage_addPythonScript
(
id
,
REQUEST
=
None
):
def
manage_addPythonScript
(
id
,
REQUEST
=
None
):
...
@@ -136,7 +136,7 @@ class PythonScript:
...
@@ -136,7 +136,7 @@ class PythonScript:
__extends__
=
(
__extends__
=
(
'PythonScripts.Script.Script'
,
'PythonScripts.Script.Script'
,
)
)
def
ZPythonScriptHTML_editAction
(
REQUEST
,
title
,
params
,
body
):
def
ZPythonScriptHTML_editAction
(
REQUEST
,
title
,
params
,
body
):
"""
"""
...
@@ -230,8 +230,3 @@ class PythonScript:
...
@@ -230,8 +230,3 @@ class PythonScript:
'text/plain' set on the RESPONSE.
'text/plain' set on the RESPONSE.
"""
"""
lib/python/Products/PythonScripts/help/Script.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
class
Script
:
class
Script
:
...
...
lib/python/Products/PythonScripts/help/standard.py
View file @
2639fcb7
...
@@ -3,7 +3,7 @@ Products.PythonScripts.standard: Utility functions and classes
...
@@ -3,7 +3,7 @@ Products.PythonScripts.standard: Utility functions and classes
The functions and classes in this module are available from
The functions and classes in this module are available from
Python-based scripts, DTML, and Page Templates.
Python-based scripts, DTML, and Page Templates.
"""
"""
def
whole_dollars
(
number
):
def
whole_dollars
(
number
):
...
@@ -23,7 +23,7 @@ def structured_text(s):
...
@@ -23,7 +23,7 @@ def structured_text(s):
See Also
See Also
"Structured-Text Rules":http://dev.zope.org/Members/jim/StructuredTextWiki/StructuredTextNGRules
"Structured-Text Rules":http://dev.zope.org/Members/jim/StructuredTextWiki/StructuredTextNGRules
"""
"""
def
sql_quote
(
s
):
def
sql_quote
(
s
):
...
@@ -41,7 +41,7 @@ def html_quote(s):
...
@@ -41,7 +41,7 @@ def html_quote(s):
"Python 'cgi' module":http://www.python.org/doc/current/lib/Functions_in_cgi_module.html
"Python 'cgi' module":http://www.python.org/doc/current/lib/Functions_in_cgi_module.html
'escape' function.
'escape' function.
"""
"""
def
url_quote
(
s
):
def
url_quote
(
s
):
...
@@ -123,7 +123,7 @@ class DTML:
...
@@ -123,7 +123,7 @@ class DTML:
def
call
(
client
=
None
,
REQUEST
=
{},
**
kw
):
def
call
(
client
=
None
,
REQUEST
=
{},
**
kw
):
"""
"""
Render the DTML.
Render the DTML.
To accomplish its task, DTML often needs to resolve various
To accomplish its task, DTML often needs to resolve various
names into objects. For example, when the code <dtml-var
names into objects. For example, when the code <dtml-var
spam> is executed, the DTML engine tries to resolve the
spam> is executed, the DTML engine tries to resolve the
...
@@ -148,5 +148,5 @@ class DTML:
...
@@ -148,5 +148,5 @@ class DTML:
three methods. You can pass any number of them or none at
three methods. You can pass any number of them or none at
all. Names will be looked up first in the keyword argument,
all. Names will be looked up first in the keyword argument,
next in the client and finally in the mapping.
next in the client and finally in the mapping.
"""
"""
lib/python/Products/PythonScripts/module_access_examples.py
View file @
2639fcb7
...
@@ -65,8 +65,3 @@ from Globals import InitializeClass
...
@@ -65,8 +65,3 @@ from Globals import InitializeClass
# 'error_reply', 'error_temp', 'error_perm', 'error_proto')
# 'error_reply', 'error_temp', 'error_perm', 'error_proto')
# from httplib import NNTP
# from httplib import NNTP
# allow_class(NNTP)
# allow_class(NNTP)
lib/python/Products/PythonScripts/standard.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python Scripts standard utility module
"""Python Scripts standard utility module
...
@@ -18,7 +18,7 @@ Scripts. It can be accessed from Python with the statement
...
@@ -18,7 +18,7 @@ Scripts. It can be accessed from Python with the statement
"import Products.PythonScripts.standard"
"import Products.PythonScripts.standard"
"""
"""
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
from
AccessControl
import
ModuleSecurityInfo
,
getSecurityManager
from
AccessControl
import
ModuleSecurityInfo
,
getSecurityManager
security
=
ModuleSecurityInfo
()
security
=
ModuleSecurityInfo
()
...
@@ -53,4 +53,3 @@ class DTML(RestrictedDTML, HTML):
...
@@ -53,4 +53,3 @@ class DTML(RestrictedDTML, HTML):
finally
:
security
.
removeContext
(
self
)
finally
:
security
.
removeContext
(
self
)
security
.
apply
(
globals
())
security
.
apply
(
globals
())
lib/python/Products/PythonScripts/tests/testPythonScript.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
os
,
sys
,
unittest
import
os
,
sys
,
unittest
...
@@ -74,9 +74,9 @@ class TestPythonScriptNoAq(unittest.TestCase):
...
@@ -74,9 +74,9 @@ class TestPythonScriptNoAq(unittest.TestCase):
assert
txt
==
'txt'
,
txt
assert
txt
==
'txt'
,
txt
def
testParam2
(
self
):
def
testParam2
(
self
):
one
,
two
=
self
.
_newPS
(
'##parameters=x,y
\
n
return x,y'
)(
'one'
,
'two'
)
one
,
two
=
self
.
_newPS
(
'##parameters=x,y
\
n
return x,y'
)(
'one'
,
'two'
)
assert
one
==
'one'
assert
one
==
'one'
assert
two
==
'two'
assert
two
==
'two'
def
testParam26
(
self
):
def
testParam26
(
self
):
import
string
import
string
...
@@ -85,7 +85,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
...
@@ -85,7 +85,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
tup
=
apply
(
self
.
_newPS
(
'##parameters=%s
\
n
return %s'
tup
=
apply
(
self
.
_newPS
(
'##parameters=%s
\
n
return %s'
%
(
sparams
,
sparams
)),
params
)
%
(
sparams
,
sparams
)),
params
)
assert
tup
==
tuple
(
params
),
(
tup
,
params
)
assert
tup
==
tuple
(
params
),
(
tup
,
params
)
def
testArithmetic
(
self
):
def
testArithmetic
(
self
):
one
=
self
.
_newPS
(
'return 1 * 5 + 4 / 2 - 6'
)()
one
=
self
.
_newPS
(
'return 1 * 5 + 4 / 2 - 6'
)()
assert
one
==
1
,
one
assert
one
==
1
,
one
...
@@ -103,7 +103,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
...
@@ -103,7 +103,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
def
testForLoop
(
self
):
def
testForLoop
(
self
):
ten
=
self
.
_newPS
(
readf
(
'for_loop'
))()
ten
=
self
.
_newPS
(
readf
(
'for_loop'
))()
assert
ten
==
10
assert
ten
==
10
def
testMutateLiterals
(
self
):
def
testMutateLiterals
(
self
):
l
,
d
=
self
.
_newPS
(
readf
(
'mutate_literals'
))()
l
,
d
=
self
.
_newPS
(
readf
(
'mutate_literals'
))()
assert
l
==
[
2
],
l
assert
l
==
[
2
],
l
...
@@ -122,7 +122,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
...
@@ -122,7 +122,7 @@ class TestPythonScriptNoAq(unittest.TestCase):
a
,
b
=
self
.
_newPS
(
readf
(
'try_except'
))()
a
,
b
=
self
.
_newPS
(
readf
(
'try_except'
))()
assert
a
==
1
assert
a
==
1
assert
b
==
1
assert
b
==
1
def
testBigBoolean
(
self
):
def
testBigBoolean
(
self
):
true
=
self
.
_newPS
(
readf
(
'big_boolean'
))()
true
=
self
.
_newPS
(
readf
(
'big_boolean'
))()
assert
true
,
true
assert
true
,
true
...
@@ -166,4 +166,3 @@ def main():
...
@@ -166,4 +166,3 @@ def main():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
lib/python/Products/Sessions/BrowserIdManager.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
############################################################################
############################################################################
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
import
Globals
import
Globals
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
ZODB
import
TimeStamp
from
ZODB
import
TimeStamp
...
@@ -53,9 +53,9 @@ def constructBrowserIdManager(
...
@@ -53,9 +53,9 @@ def constructBrowserIdManager(
ob = self._getOb(id)
ob = self._getOb(id)
if REQUEST is not None:
if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1)
return self.manage_main(self, REQUEST, update_menu=1)
class BrowserIdManagerErr(Exception): pass
class BrowserIdManagerErr(Exception): pass
class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
""" browser id management class """
""" browser id management class """
...
@@ -99,7 +99,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -99,7 +99,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
not create a browser id for the current request if one doesn'
t
not create a browser id for the current request if one doesn'
t
already
exist
"""
already
exist
"""
if self.getBrowserId(create=0): return 1
if self.getBrowserId(create=0): return 1
security.declareProtected(ACCESS_CONTENTS_PERM, 'getBrowserId')
security.declareProtected(ACCESS_CONTENTS_PERM, 'getBrowserId')
def getBrowserId(self, create=1):
def getBrowserId(self, create=1):
"""
"""
...
@@ -120,7 +120,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -120,7 +120,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
# somebody screwed with the REQUEST instance during
# somebody screwed with the REQUEST instance during
# this request.
# this request.
raise BrowserIdManagerErr, (
raise BrowserIdManagerErr, (
'Ill-formed browserid in REQUEST.browser_id_: %s' %
'Ill-formed browserid in REQUEST.browser_id_: %s' %
escape(bid)
escape(bid)
)
)
return bid
return bid
...
@@ -194,7 +194,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -194,7 +194,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
# ns will be None if new, negating None below returns 1, which
# ns will be None if new, negating None below returns 1, which
# would indicate that it'
s
new
on
this
request
# would indicate that it'
s
new
on
this
request
return
not
getattr
(
self
.
REQUEST
,
'browser_id_ns_'
)
return
not
getattr
(
self
.
REQUEST
,
'browser_id_ns_'
)
security
.
declareProtected
(
ACCESS_CONTENTS_PERM
,
'encodeUrl'
)
security
.
declareProtected
(
ACCESS_CONTENTS_PERM
,
'encodeUrl'
)
def
encodeUrl
(
self
,
url
,
create
=
1
):
def
encodeUrl
(
self
,
url
,
create
=
1
):
"""
"""
...
@@ -313,7 +313,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -313,7 +313,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
if
not
(
type
(
path
)
is
type
(
''
)
and
not
badcookiecharsin
(
path
)):
if
not
(
type
(
path
)
is
type
(
''
)
and
not
badcookiecharsin
(
path
)):
raise
BrowserIdManagerErr
,
'Bad cookie path %s'
%
escape
(
repr
(
path
))
raise
BrowserIdManagerErr
,
'Bad cookie path %s'
%
escape
(
repr
(
path
))
self
.
cookie_path
=
path
self
.
cookie_path
=
path
security
.
declareProtected
(
ACCESS_CONTENTS_PERM
,
'getCookiePath'
)
security
.
declareProtected
(
ACCESS_CONTENTS_PERM
,
'getCookiePath'
)
def
getCookiePath
(
self
):
def
getCookiePath
(
self
):
""" """
""" """
...
@@ -397,7 +397,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -397,7 +397,7 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
A == leading-0-padded 8-char string-rep'd random integer
A == leading-0-padded 8-char string-rep'd random integer
B == modified base64-encoded 11-char timestamp
B == modified base64-encoded 11-char timestamp
To be URL-compatible, base64 encoding is modified as follows:
To be URL-compatible, base64 encoding is modified as follows:
'=' end-padding is stripped off
'=' end-padding is stripped off
'+' is translated to '-'
'+' is translated to '-'
...
@@ -428,14 +428,14 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
...
@@ -428,14 +428,14 @@ class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
return
# should we raise an exception?
return
# should we raise an exception?
if
string
.
split
(
URL1
,
':'
)[
0
]
!=
'https'
:
if
string
.
split
(
URL1
,
':'
)[
0
]
!=
'https'
:
return
# should we raise an exception?
return
# should we raise an exception?
cookies
=
REQUEST
.
RESPONSE
.
cookies
cookies
=
REQUEST
.
RESPONSE
.
cookies
cookie
=
cookies
[
self
.
browserid_name
]
=
{}
cookie
=
cookies
[
self
.
browserid_name
]
=
{}
for
k
,
v
in
d
.
items
():
for
k
,
v
in
d
.
items
():
if
v
:
if
v
:
cookie
[
k
]
=
v
#only stuff things with true values
cookie
[
k
]
=
v
#only stuff things with true values
cookie
[
'value'
]
=
bid
cookie
[
'value'
]
=
bid
def
_getB64TStamp
(
def
_getB64TStamp
(
self
,
b2a
=
binascii
.
b2a_base64
,
gmtime
=
time
.
gmtime
,
time
=
time
.
time
,
self
,
b2a
=
binascii
.
b2a_base64
,
gmtime
=
time
.
gmtime
,
time
=
time
.
time
,
b64_trans
=
b64_trans
,
split
=
string
.
split
,
b64_trans
=
b64_trans
,
split
=
string
.
split
,
...
...
lib/python/Products/Sessions/SessionDataManager.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -103,7 +103,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
...
@@ -103,7 +103,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
security.declareProtected(ARBITRARY_SESSIONDATA_PERM,'
getSessionDataByKey
')
security.declareProtected(ARBITRARY_SESSIONDATA_PERM,'
getSessionDataByKey
')
def getSessionDataByKey(self, key):
def getSessionDataByKey(self, key):
return self._getSessionDataObjectByKey(key)
return self._getSessionDataObjectByKey(key)
security.declareProtected(ACCESS_CONTENTS_PERM, '
getBrowserIdManager
')
security.declareProtected(ACCESS_CONTENTS_PERM, '
getBrowserIdManager
')
def getBrowserIdManager(self):
def getBrowserIdManager(self):
""" """
""" """
...
@@ -115,7 +115,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
...
@@ -115,7 +115,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
return mgr
return mgr
# END INTERFACE METHODS
# END INTERFACE METHODS
def __init__(self, id, path=None, title='', requestName=None):
def __init__(self, id, path=None, title='', requestName=None):
self.id = id
self.id = id
self.setContainerPath(path)
self.setContainerPath(path)
...
@@ -160,14 +160,14 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
...
@@ -160,14 +160,14 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
self.obpath = list(path) # sequence
self.obpath = list(path) # sequence
else:
else:
raise SessionDataManagerErr, ('
Bad
path
value
%
s
' % path)
raise SessionDataManagerErr, ('
Bad
path
value
%
s
' % path)
security.declareProtected(MGMT_SCREEN_PERM, '
getContainerPath
')
security.declareProtected(MGMT_SCREEN_PERM, '
getContainerPath
')
def getContainerPath(self):
def getContainerPath(self):
""" """
""" """
if self.obpath is not None:
if self.obpath is not None:
return string.join(self.obpath, '
/
')
return string.join(self.obpath, '
/
')
return '' # blank string represents undefined state
return '' # blank string represents undefined state
def _hasSessionDataObject(self, key):
def _hasSessionDataObject(self, key):
""" """
""" """
c = self._getSessionDataContainer()
c = self._getSessionDataContainer()
...
...
lib/python/Products/Sessions/SessionInterfaces.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -81,7 +81,7 @@ class BrowserIdManagerInterface(
...
@@ -81,7 +81,7 @@ class BrowserIdManagerInterface(
"""
"""
Returns true if browser id is 'new'. A browser id is 'new'
Returns true if browser id is 'new'. A browser id is 'new'
when it is first created and the client has therefore not sent it
when it is first created and the client has therefore not sent it
back to the server in any request.
back to the server in any request.
Permission required: Access contents information
Permission required: Access contents information
...
@@ -111,7 +111,7 @@ class BrowserIdManagerInterface(
...
@@ -111,7 +111,7 @@ class BrowserIdManagerInterface(
"""
"""
Deletes the browser id cookie from the client browser, iff the
Deletes the browser id cookie from the client browser, iff the
'cookies' browser id namespace is being used.
'cookies' browser id namespace is being used.
Permission required: Access contents information
Permission required: Access contents information
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
...
@@ -123,7 +123,7 @@ class BrowserIdManagerInterface(
...
@@ -123,7 +123,7 @@ class BrowserIdManagerInterface(
Sets the browser id cookie to browser id 'bid' by force.
Sets the browser id cookie to browser id 'bid' by force.
Useful when you need to 'chain' browser id cookies across domains
Useful when you need to 'chain' browser id cookies across domains
for the same user (perhaps temporarily using query strings).
for the same user (perhaps temporarily using query strings).
Permission required: Access contents information
Permission required: Access contents information
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
...
...
lib/python/Products/Sessions/SessionPermissions.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
...
lib/python/Products/Sessions/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Session initialization routines
Session initialization routines
$Id: __init__.py,v 1.
6 2001/11/28 15:51:07 matt
Exp $
$Id: __init__.py,v 1.
7 2002/08/14 22:25:09 mj
Exp $
"""
"""
import
ZODB
# this is for testrunner to be happy
import
ZODB
# this is for testrunner to be happy
...
...
lib/python/Products/Sessions/common.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
...
lib/python/Products/Sessions/help/SessionInterfaces.py
View file @
2639fcb7
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -81,7 +81,7 @@ class BrowserIdManagerInterface(
...
@@ -81,7 +81,7 @@ class BrowserIdManagerInterface(
"""
"""
Returns true if browser id is 'new'. A browser id is 'new'
Returns true if browser id is 'new'. A browser id is 'new'
when it is first created and the client has therefore not sent it
when it is first created and the client has therefore not sent it
back to the server in any request.
back to the server in any request.
Permission required: Access contents information
Permission required: Access contents information
...
@@ -111,7 +111,7 @@ class BrowserIdManagerInterface(
...
@@ -111,7 +111,7 @@ class BrowserIdManagerInterface(
"""
"""
Deletes the browser id cookie from the client browser, iff the
Deletes the browser id cookie from the client browser, iff the
'cookies' browser id namespace is being used.
'cookies' browser id namespace is being used.
Permission required: Access contents information
Permission required: Access contents information
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
...
@@ -123,7 +123,7 @@ class BrowserIdManagerInterface(
...
@@ -123,7 +123,7 @@ class BrowserIdManagerInterface(
Sets the browser id cookie to browser id 'bid' by force.
Sets the browser id cookie to browser id 'bid' by force.
Useful when you need to 'chain' browser id cookies across domains
Useful when you need to 'chain' browser id cookies across domains
for the same user (perhaps temporarily using query strings).
for the same user (perhaps temporarily using query strings).
Permission required: Access contents information
Permission required: Access contents information
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
Raises: BrowserIdManagerErr. If the 'cookies' namespace isn't
...
...
lib/python/Products/Sessions/stresstests/stresstestMultiThread.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
os
,
time
import
sys
,
os
,
time
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
@@ -117,7 +117,7 @@ class TestMultiThread(TestCase):
...
@@ -117,7 +117,7 @@ class TestMultiThread(TestCase):
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
while
threading
.
activeCount
()
>
1
:
while
threading
.
activeCount
()
>
1
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
def
testNonOverlappingBrowserIds
(
self
):
def
testNonOverlappingBrowserIds
(
self
):
readers
=
[]
readers
=
[]
writers
=
[]
writers
=
[]
...
@@ -143,7 +143,7 @@ class TestMultiThread(TestCase):
...
@@ -143,7 +143,7 @@ class TestMultiThread(TestCase):
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
while
threading
.
activeCount
()
>
1
:
while
threading
.
activeCount
()
>
1
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
class
BaseReaderWriter
(
threading
.
Thread
):
class
BaseReaderWriter
(
threading
.
Thread
):
def
__init__
(
self
,
db
,
iters
,
sdm_name
):
def
__init__
(
self
,
db
,
iters
,
sdm_name
):
self
.
conn
=
db
.
open
()
self
.
conn
=
db
.
open
()
...
@@ -180,7 +180,7 @@ class BaseReaderWriter(threading.Thread):
...
@@ -180,7 +180,7 @@ class BaseReaderWriter(threading.Thread):
self
.
conn
.
close
()
self
.
conn
.
close
()
del
self
.
app
del
self
.
app
print
i
print
i
class
ReaderThread
(
BaseReaderWriter
):
class
ReaderThread
(
BaseReaderWriter
):
def
run1
(
self
):
def
run1
(
self
):
session_data_manager
=
getattr
(
self
.
app
,
self
.
sdm_name
)
session_data_manager
=
getattr
(
self
.
app
,
self
.
sdm_name
)
...
@@ -216,4 +216,3 @@ def test_suite():
...
@@ -216,4 +216,3 @@ def test_suite():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runner
=
TextTestRunner
(
verbosity
=
9
,
descriptions
=
9
)
runner
=
TextTestRunner
(
verbosity
=
9
,
descriptions
=
9
)
runner
.
run
(
test_suite
())
runner
.
run
(
test_suite
())
lib/python/Products/Sessions/tests/testBrowserIdManager.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Test suite for session id manager.
Test suite for session id manager.
$Id: testBrowserIdManager.py,v 1.1
0 2002/08/10 19:28:38 chrism
Exp $
$Id: testBrowserIdManager.py,v 1.1
1 2002/08/14 22:25:10 mj
Exp $
"""
"""
__version__
=
"$Revision: 1.1
0
$"
[
11
:
-
2
]
__version__
=
"$Revision: 1.1
1
$"
[
11
:
-
2
]
import
sys
import
sys
import
ZODB
import
ZODB
...
@@ -34,7 +34,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -34,7 +34,7 @@ class TestBrowserIdManager(TestCase):
environ
[
'SERVER_PORT'
]
=
'80'
environ
[
'SERVER_PORT'
]
=
'80'
req
=
HTTPRequest
(
stdin
,
environ
,
resp
)
req
=
HTTPRequest
(
stdin
,
environ
,
resp
)
self
.
m
.
REQUEST
=
req
self
.
m
.
REQUEST
=
req
def
tearDown
(
self
):
def
tearDown
(
self
):
del
self
.
m
del
self
.
m
...
@@ -114,7 +114,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -114,7 +114,7 @@ class TestBrowserIdManager(TestCase):
self
.
m
.
setCookieDomain
(
'.zope.org'
)
self
.
m
.
setCookieDomain
(
'.zope.org'
)
setdomain
=
self
.
m
.
getCookieDomain
()
setdomain
=
self
.
m
.
getCookieDomain
()
self
.
failUnless
(
setdomain
==
'.zope.org'
,
"%s"
%
setdomain
)
self
.
failUnless
(
setdomain
==
'.zope.org'
,
"%s"
%
setdomain
)
def
testSetCookieSecure
(
self
):
def
testSetCookieSecure
(
self
):
self
.
m
.
setCookieSecure
(
1
)
self
.
m
.
setCookieSecure
(
1
)
self
.
failUnless
(
self
.
m
.
getCookieSecure
()
==
1
)
self
.
failUnless
(
self
.
m
.
getCookieSecure
()
==
1
)
...
@@ -143,7 +143,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -143,7 +143,7 @@ class TestBrowserIdManager(TestCase):
self
.
failUnless
(
not
self
.
m
.
hasBrowserId
()
)
self
.
failUnless
(
not
self
.
m
.
hasBrowserId
()
)
a
=
self
.
m
.
getBrowserId
()
a
=
self
.
m
.
getBrowserId
()
self
.
failUnless
(
self
.
m
.
hasBrowserId
()
)
self
.
failUnless
(
self
.
m
.
hasBrowserId
()
)
def
testBrowserIdIsNew
(
self
):
def
testBrowserIdIsNew
(
self
):
a
=
self
.
m
.
getBrowserId
()
a
=
self
.
m
.
getBrowserId
()
self
.
failUnless
(
self
.
m
.
isBrowserIdNew
()
)
self
.
failUnless
(
self
.
m
.
isBrowserIdNew
()
)
...
@@ -178,7 +178,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -178,7 +178,7 @@ class TestBrowserIdManager(TestCase):
a
=
self
.
m
.
getBrowserId
()
a
=
self
.
m
.
getBrowserId
()
self
.
failUnless
(
self
.
m
.
isBrowserIdFromCookie
()
)
self
.
failUnless
(
self
.
m
.
isBrowserIdFromCookie
()
)
self
.
failUnless
(
not
self
.
m
.
isBrowserIdFromForm
()
)
self
.
failUnless
(
not
self
.
m
.
isBrowserIdFromForm
()
)
def
testIsBrowserIdFromFormOnly
(
self
):
def
testIsBrowserIdFromFormOnly
(
self
):
token
=
self
.
m
.
getBrowserId
()
token
=
self
.
m
.
getBrowserId
()
self
.
m
.
REQUEST
.
browser_id_
=
token
self
.
m
.
REQUEST
.
browser_id_
=
token
...
@@ -202,7 +202,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -202,7 +202,7 @@ class TestBrowserIdManager(TestCase):
self
.
m
.
flushBrowserIdCookie
()
self
.
m
.
flushBrowserIdCookie
()
c
=
self
.
m
.
REQUEST
.
RESPONSE
.
cookies
[
tokenkey
]
c
=
self
.
m
.
REQUEST
.
RESPONSE
.
cookies
[
tokenkey
]
self
.
failUnless
(
c
[
'value'
]
==
'deleted'
)
self
.
failUnless
(
c
[
'value'
]
==
'deleted'
)
def
testSetBrowserIdCookieByForce
(
self
):
def
testSetBrowserIdCookieByForce
(
self
):
token
=
self
.
m
.
getBrowserId
()
token
=
self
.
m
.
getBrowserId
()
self
.
m
.
REQUEST
.
browser_id_
=
token
self
.
m
.
REQUEST
.
browser_id_
=
token
...
@@ -238,7 +238,7 @@ class TestBrowserIdManager(TestCase):
...
@@ -238,7 +238,7 @@ class TestBrowserIdManager(TestCase):
def
test_suite
():
def
test_suite
():
testsuite
=
makeSuite
(
TestBrowserIdManager
,
'test'
)
testsuite
=
makeSuite
(
TestBrowserIdManager
,
'test'
)
return
testsuite
return
testsuite
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
.
run
(
test_suite
())
runner
.
run
(
test_suite
())
lib/python/Products/Sessions/tests/testSessionDataManager.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
os
,
time
import
sys
,
os
,
time
...
@@ -92,11 +92,11 @@ def _populate(app):
...
@@ -92,11 +92,11 @@ def _populate(app):
app
.
temp_folder
.
_setObject
(
toc_name
,
toc
)
app
.
temp_folder
.
_setObject
(
toc_name
,
toc
)
get_transaction
().
commit
()
get_transaction
().
commit
()
# index_html necessary for publishing emulation for testAutoReqPopulate
# index_html necessary for publishing emulation for testAutoReqPopulate
app
.
_setObject
(
'index_html'
,
DTMLMethod
(
''
,
__name__
=
'foo'
))
app
.
_setObject
(
'index_html'
,
DTMLMethod
(
''
,
__name__
=
'foo'
))
get_transaction
().
commit
()
get_transaction
().
commit
()
class
TestBase
(
TestCase
):
class
TestBase
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
db
=
_getDB
()
db
=
_getDB
()
...
@@ -137,7 +137,7 @@ class TestSessionManager(TestBase):
...
@@ -137,7 +137,7 @@ class TestSessionManager(TestBase):
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
1
)
sd
=
self
.
app
.
session_data_manager
.
getSessionData
(
1
)
sdm
=
aq_base
(
getattr
(
self
.
app
,
sdm_name
))
sdm
=
aq_base
(
getattr
(
self
.
app
,
sdm_name
))
toc
=
aq_base
(
getattr
(
self
.
app
.
temp_folder
,
toc_name
))
toc
=
aq_base
(
getattr
(
self
.
app
.
temp_folder
,
toc_name
))
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
)
is
sdm
)
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
self
.
failUnless
(
aq_base
(
sd
.
aq_parent
.
aq_parent
)
is
toc
)
...
@@ -229,4 +229,3 @@ def test_suite():
...
@@ -229,4 +229,3 @@ def test_suite():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runner
=
TextTestRunner
(
verbosity
=
9
,
descriptions
=
9
)
runner
=
TextTestRunner
(
verbosity
=
9
,
descriptions
=
9
)
runner
.
run
(
test_suite
())
runner
.
run
(
test_suite
())
lib/python/Products/SiteAccess/AccessRule.py
View file @
2639fcb7
...
@@ -34,7 +34,7 @@ def _swallow(request, prefix):
...
@@ -34,7 +34,7 @@ def _swallow(request, prefix):
def
manage_addAccessRule
(
self
,
method_id
=
None
,
REQUEST
=
None
,
**
ignored
):
def
manage_addAccessRule
(
self
,
method_id
=
None
,
REQUEST
=
None
,
**
ignored
):
"""Point a __before_traverse__ entry at the specified method"""
"""Point a __before_traverse__ entry at the specified method"""
# We want the original object, not stuff in between, and no acquisition
# We want the original object, not stuff in between, and no acquisition
self
=
self
.
this
()
self
=
self
.
this
()
self
=
getattr
(
self
,
'aq_base'
,
self
)
self
=
getattr
(
self
,
'aq_base'
,
self
)
priority
=
(
1
,
'AccessRule'
)
priority
=
(
1
,
'AccessRule'
)
...
@@ -54,7 +54,7 @@ def manage_addAccessRule(self, method_id=None, REQUEST=None, **ignored):
...
@@ -54,7 +54,7 @@ def manage_addAccessRule(self, method_id=None, REQUEST=None, **ignored):
except
:
pass
except
:
pass
hook
=
AccessRule
(
method_id
)
hook
=
AccessRule
(
method_id
)
registerBeforeTraverse
(
self
,
hook
,
'AccessRule'
,
1
)
registerBeforeTraverse
(
self
,
hook
,
'AccessRule'
,
1
)
try
:
try
:
getattr
(
self
,
method_id
).
icon
=
'misc_/SiteAccess/AccessRule.gif'
getattr
(
self
,
method_id
).
icon
=
'misc_/SiteAccess/AccessRule.gif'
except
:
pass
except
:
pass
if
REQUEST
:
if
REQUEST
:
...
@@ -70,7 +70,7 @@ def manage_addAccessRule(self, method_id=None, REQUEST=None, **ignored):
...
@@ -70,7 +70,7 @@ def manage_addAccessRule(self, method_id=None, REQUEST=None, **ignored):
def
getAccessRule
(
self
,
REQUEST
=
None
):
def
getAccessRule
(
self
,
REQUEST
=
None
):
"Return the name of the current AccessRule, if any"
"Return the name of the current AccessRule, if any"
self
=
self
.
this
()
self
=
self
.
this
()
rules
=
queryBeforeTraverse
(
self
,
'AccessRule'
)
rules
=
queryBeforeTraverse
(
self
,
'AccessRule'
)
if
rules
:
if
rules
:
return
rules
[
0
][
1
].
name
return
rules
[
0
][
1
].
name
...
...
lib/python/Products/SiteAccess/Extensions/updata.py
View file @
2639fcb7
...
@@ -28,7 +28,7 @@ def _cvt_btr(app):
...
@@ -28,7 +28,7 @@ def _cvt_btr(app):
btr
[
k
]
=
NameCaller
(
v
)
btr
[
k
]
=
NameCaller
(
v
)
if
touched
:
if
touched
:
rewriteBeforeTraverse
(
o
,
btr
)
rewriteBeforeTraverse
(
o
,
btr
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print
"Converting SiteAccess objects from 1.x to 2.x ..."
print
"Converting SiteAccess objects from 1.x to 2.x ..."
app
=
Zope
.
app
()
app
=
Zope
.
app
()
...
...
lib/python/Products/SiteAccess/SiteRoot.py
View file @
2639fcb7
...
@@ -36,9 +36,9 @@ class Traverser(Persistent, Item):
...
@@ -36,9 +36,9 @@ class Traverser(Persistent, Item):
message
=
'This object already contains a %s'
%
self
.
meta_type
,
message
=
'This object already contains a %s'
%
self
.
meta_type
,
action
=
nextURL
)
action
=
nextURL
)
self
.
addToContainer
(
container
)
self
.
addToContainer
(
container
)
if
nextURL
:
if
nextURL
:
return
MessageDialog
(
title
=
'Item Added'
,
return
MessageDialog
(
title
=
'Item Added'
,
message
=
'This object now has a %s'
%
self
.
meta_type
,
message
=
'This object now has a %s'
%
self
.
meta_type
,
action
=
nextURL
)
action
=
nextURL
)
def
manage_beforeDelete
(
self
,
item
,
container
):
def
manage_beforeDelete
(
self
,
item
,
container
):
...
@@ -96,11 +96,11 @@ class SiteRoot(Traverser, Implicit):
...
@@ -96,11 +96,11 @@ class SiteRoot(Traverser, Implicit):
'''Set the title, base, and path'''
'''Set the title, base, and path'''
self
.
__init__
(
title
,
base
,
path
)
self
.
__init__
(
title
,
base
,
path
)
if
REQUEST
:
if
REQUEST
:
return
MessageDialog
(
title
=
'SiteRoot changed.'
,
return
MessageDialog
(
title
=
'SiteRoot changed.'
,
message
=
'The title is now "%s"<br>'
message
=
'The title is now "%s"<br>'
'The base is now "%s"<br>'
'The base is now "%s"<br>'
'The path is now "%s"<br>'
%
(
title
,
base
,
path
),
'The path is now "%s"<br>'
%
(
title
,
base
,
path
),
action
=
'%s/manage_main'
%
REQUEST
[
'URL1'
])
action
=
'%s/manage_main'
%
REQUEST
[
'URL1'
])
def
__call__
(
self
,
client
,
request
,
response
=
None
):
def
__call__
(
self
,
client
,
request
,
response
=
None
):
'''Traversing'''
'''Traversing'''
...
...
lib/python/Products/SiteAccess/VirtualHostMonster.py
View file @
2639fcb7
...
@@ -97,9 +97,9 @@ class VirtualHostMonster(Persistent, Item, Implicit):
...
@@ -97,9 +97,9 @@ class VirtualHostMonster(Persistent, Item, Implicit):
def
manage_addToContainer
(
self
,
container
,
nextURL
=
''
):
def
manage_addToContainer
(
self
,
container
,
nextURL
=
''
):
self
.
addToContainer
(
container
)
self
.
addToContainer
(
container
)
if
nextURL
:
if
nextURL
:
return
MessageDialog
(
title
=
'Item Added'
,
return
MessageDialog
(
title
=
'Item Added'
,
message
=
'This object now has a %s'
%
self
.
meta_type
,
message
=
'This object now has a %s'
%
self
.
meta_type
,
action
=
nextURL
)
action
=
nextURL
)
def
manage_beforeDelete
(
self
,
item
,
container
):
def
manage_beforeDelete
(
self
,
item
,
container
):
...
...
lib/python/Products/SiteAccess/__init__.py
View file @
2639fcb7
...
@@ -3,15 +3,15 @@ __doc__="""SiteAccess product"""
...
@@ -3,15 +3,15 @@ __doc__="""SiteAccess product"""
import
SiteRoot
,
AccessRule
,
VirtualHostMonster
import
SiteRoot
,
AccessRule
,
VirtualHostMonster
def
initialize
(
context
):
def
initialize
(
context
):
context
.
registerClass
(
instance_class
=
SiteRoot
.
SiteRoot
,
context
.
registerClass
(
instance_class
=
SiteRoot
.
SiteRoot
,
permission
=
'Add Site Roots'
,
permission
=
'Add Site Roots'
,
constructors
=
SiteRoot
.
constructors
,
legacy
=
SiteRoot
.
constructors
,
constructors
=
SiteRoot
.
constructors
,
legacy
=
SiteRoot
.
constructors
,
icon
=
'www/SiteRoot.gif'
)
icon
=
'www/SiteRoot.gif'
)
context
.
registerClass
(
instance_class
=
AccessRule
.
AccessRule
,
context
.
registerClass
(
instance_class
=
AccessRule
.
AccessRule
,
permission
=
'Manage Access Rules'
,
constructors
=
AccessRule
.
constructors
,
permission
=
'Manage Access Rules'
,
constructors
=
AccessRule
.
constructors
,
icon
=
'www/AccessRule.gif'
)
icon
=
'www/AccessRule.gif'
)
context
.
registerClass
(
instance_class
=
VirtualHostMonster
.
VirtualHostMonster
,
context
.
registerClass
(
instance_class
=
VirtualHostMonster
.
VirtualHostMonster
,
permission
=
'Add Virtual Host Monsters'
,
permission
=
'Add Virtual Host Monsters'
,
constructors
=
VirtualHostMonster
.
constructors
,
constructors
=
VirtualHostMonster
.
constructors
,
icon
=
'www/VirtualHostMonster.gif'
)
icon
=
'www/VirtualHostMonster.gif'
)
context
.
registerHelp
()
context
.
registerHelp
()
lib/python/Products/SiteErrorLog/SiteErrorLog.py
View file @
2639fcb7
...
@@ -2,18 +2,18 @@
...
@@ -2,18 +2,18 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""Site error log module.
"""Site error log module.
$Id: SiteErrorLog.py,v 1.
9 2002/06/29 18:46:45 chrism
Exp $
$Id: SiteErrorLog.py,v 1.
10 2002/08/14 22:25:11 mj
Exp $
"""
"""
import
os
import
os
...
@@ -46,7 +46,7 @@ log_to_event_log = 'Log to the Event Log'
...
@@ -46,7 +46,7 @@ log_to_event_log = 'Log to the Event Log'
_rate_restrict_pool
=
{}
_rate_restrict_pool
=
{}
# The number of seconds that must elapse on average between sending two
# The number of seconds that must elapse on average between sending two
# exceptions of the same name into the the Event Log. one per minute.
# exceptions of the same name into the the Event Log. one per minute.
_rate_restrict_period
=
60
_rate_restrict_period
=
60
# The number of exceptions to allow in a burst before the above limit
# The number of exceptions to allow in a burst before the above limit
...
@@ -136,7 +136,7 @@ class SiteErrorLog (SimpleItem):
...
@@ -136,7 +136,7 @@ class SiteErrorLog (SimpleItem):
strtype
=
str
(
getattr
(
info
[
0
],
'__name__'
,
info
[
0
]))
strtype
=
str
(
getattr
(
info
[
0
],
'__name__'
,
info
[
0
]))
if
strtype
in
self
.
_ignored_exceptions
:
if
strtype
in
self
.
_ignored_exceptions
:
return
return
if
not
isinstance
(
info
[
2
],
StringType
)
and
not
isinstance
(
if
not
isinstance
(
info
[
2
],
StringType
)
and
not
isinstance
(
info
[
2
],
UnicodeType
):
info
[
2
],
UnicodeType
):
tb_text
=
''
.
join
(
tb_text
=
''
.
join
(
...
@@ -227,7 +227,7 @@ class SiteErrorLog (SimpleItem):
...
@@ -227,7 +227,7 @@ class SiteErrorLog (SimpleItem):
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
'%s/manage_main?manage_tabs_message=Changed+properties.'
%
'%s/manage_main?manage_tabs_message=Changed+properties.'
%
self
.
absolute_url
())
self
.
absolute_url
())
security
.
declareProtected
(
use_error_logging
,
'getLogEntries'
)
security
.
declareProtected
(
use_error_logging
,
'getLogEntries'
)
def
getLogEntries
(
self
):
def
getLogEntries
(
self
):
"""Returns the entries in the log.
"""Returns the entries in the log.
...
@@ -272,4 +272,3 @@ def manage_addErrorLog(dispatcher, RESPONSE=None):
...
@@ -272,4 +272,3 @@ def manage_addErrorLog(dispatcher, RESPONSE=None):
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
dispatcher
.
DestinationURL
()
+
dispatcher
.
DestinationURL
()
+
'/manage_main?manage_tabs_message=Error+Log+Added.'
)
'/manage_main?manage_tabs_message=Error+Log+Added.'
)
lib/python/Products/SiteErrorLog/__init__.py
View file @
2639fcb7
...
@@ -2,18 +2,18 @@
...
@@ -2,18 +2,18 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""Site error log product.
"""Site error log product.
$Id: __init__.py,v 1.
2 2002/04/03 20:43:55 shane
Exp $
$Id: __init__.py,v 1.
3 2002/08/14 22:25:11 mj
Exp $
"""
"""
import
SiteErrorLog
import
SiteErrorLog
...
@@ -23,4 +23,3 @@ def initialize(context):
...
@@ -23,4 +23,3 @@ def initialize(context):
constructors
=
(
SiteErrorLog
.
manage_addErrorLog
,),
constructors
=
(
SiteErrorLog
.
manage_addErrorLog
,),
permission
=
SiteErrorLog
.
use_error_logging
,
permission
=
SiteErrorLog
.
use_error_logging
,
icon
=
'www/error.gif'
)
icon
=
'www/error.gif'
)
lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''
'''
Accelerated HTTP cache manager --
Accelerated HTTP cache manager --
...
@@ -138,7 +138,7 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
...
@@ -138,7 +138,7 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
def
getId
(
self
):
def
getId
(
self
):
' '
' '
return
self
.
id
return
self
.
id
ZCacheManager_getCache__roles__
=
()
ZCacheManager_getCache__roles__
=
()
def
ZCacheManager_getCache
(
self
):
def
ZCacheManager_getCache
(
self
):
cacheid
=
self
.
__cacheid
cacheid
=
self
.
__cacheid
...
@@ -181,7 +181,7 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
...
@@ -181,7 +181,7 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
req
=
self
.
REQUEST
req
=
self
.
REQUEST
sort_by
=
req
.
get
(
'sort_by'
,
'anon'
)
sort_by
=
req
.
get
(
'sort_by'
,
'anon'
)
sort_reverse
=
int
(
req
.
get
(
'sort_reverse'
,
1
))
sort_reverse
=
int
(
req
.
get
(
'sort_reverse'
,
1
))
return
sort_by
,
sort_reverse
return
sort_by
,
sort_reverse
def
getCacheReport
(
self
):
def
getCacheReport
(
self
):
"""
"""
...
...
lib/python/Products/StandardCacheManagers/RAMCacheManager.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''
'''
RAM cache manager --
RAM cache manager --
...
@@ -145,7 +145,7 @@ class RAMCache (Cache):
...
@@ -145,7 +145,7 @@ class RAMCache (Cache):
else
:
else
:
return
None
return
None
return
oc
return
oc
def
countAllEntries
(
self
):
def
countAllEntries
(
self
):
'''
'''
Returns the count of all cache entries.
Returns the count of all cache entries.
...
@@ -296,7 +296,7 @@ class RAMCache (Cache):
...
@@ -296,7 +296,7 @@ class RAMCache (Cache):
oc
.
hits
=
oc
.
hits
+
1
oc
.
hits
=
oc
.
hits
+
1
entry
.
access_count
=
entry
.
access_count
+
1
entry
.
access_count
=
entry
.
access_count
+
1
return
entry
.
data
return
entry
.
data
def
ZCache_set
(
self
,
ob
,
data
,
view_name
=
''
,
keywords
=
None
,
def
ZCache_set
(
self
,
ob
,
data
,
view_name
=
''
,
keywords
=
None
,
mtime_func
=
None
):
mtime_func
=
None
):
'''
'''
...
@@ -356,7 +356,7 @@ class RAMCacheManager (CacheManager, SimpleItem):
...
@@ -356,7 +356,7 @@ class RAMCacheManager (CacheManager, SimpleItem):
def
getId
(
self
):
def
getId
(
self
):
' '
' '
return
self
.
id
return
self
.
id
ZCacheManager_getCache__roles__
=
()
ZCacheManager_getCache__roles__
=
()
def
ZCacheManager_getCache
(
self
):
def
ZCacheManager_getCache
(
self
):
cacheid
=
self
.
__cacheid
cacheid
=
self
.
__cacheid
...
@@ -406,7 +406,7 @@ class RAMCacheManager (CacheManager, SimpleItem):
...
@@ -406,7 +406,7 @@ class RAMCacheManager (CacheManager, SimpleItem):
req
=
self
.
REQUEST
req
=
self
.
REQUEST
sort_by
=
req
.
get
(
'sort_by'
,
'hits'
)
sort_by
=
req
.
get
(
'sort_by'
,
'hits'
)
sort_reverse
=
int
(
req
.
get
(
'sort_reverse'
,
1
))
sort_reverse
=
int
(
req
.
get
(
'sort_reverse'
,
1
))
return
sort_by
,
sort_reverse
return
sort_by
,
sort_reverse
def
getCacheReport
(
self
):
def
getCacheReport
(
self
):
"""
"""
...
...
lib/python/Products/StandardCacheManagers/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''
'''
Some standard Zope cache managers from Digital Creations.
Some standard Zope cache managers from Digital Creations.
...
...
lib/python/Products/TemporaryFolder/LowConflictConnection.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
from
ZODB.Connection
import
Connection
from
ZODB.Connection
import
Connection
...
@@ -43,5 +43,3 @@ class LowConflictConnection(Connection):
...
@@ -43,5 +43,3 @@ class LowConflictConnection(Connection):
d
=
object
.
__dict__
d
=
object
.
__dict__
for
k
,
v
in
state
.
items
():
d
[
k
]
=
v
for
k
,
v
in
state
.
items
():
d
[
k
]
=
v
object
.
_p_serial
=
serial
object
.
_p_serial
=
serial
lib/python/Products/TemporaryFolder/TemporaryFolder.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Mounted database support
Mounted database support
...
@@ -22,9 +22,9 @@ lives in another ZODB.
...
@@ -22,9 +22,9 @@ lives in another ZODB.
To understand this fully, you'll need to read the source of
To understand this fully, you'll need to read the source of
ZODB.Mount.MountPoint.
ZODB.Mount.MountPoint.
$Id: TemporaryFolder.py,v 1.
6 2002/08/12 21:14:15 chrism
Exp $
$Id: TemporaryFolder.py,v 1.
7 2002/08/14 22:25:13 mj
Exp $
"""
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
Globals
import
Globals
from
Globals
import
HTMLFile
from
Globals
import
HTMLFile
...
@@ -38,7 +38,7 @@ from LowConflictConnection import LowConflictConnection
...
@@ -38,7 +38,7 @@ from LowConflictConnection import LowConflictConnection
ADD_TEMPORARY_FOLDER_PERM
=
"Add Temporary Folder"
ADD_TEMPORARY_FOLDER_PERM
=
"Add Temporary Folder"
def
constructTemporaryFolder
(
self
,
id
,
title
=
None
,
REQUEST
=
None
):
def
constructTemporaryFolder
(
self
,
id
,
title
=
None
,
REQUEST
=
None
):
""" """
""" """
ms
=
MountedTemporaryFolder
(
id
,
title
)
ms
=
MountedTemporaryFolder
(
id
,
title
)
...
@@ -58,7 +58,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
...
@@ -58,7 +58,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
icon
=
'p_/broken'
icon
=
'p_/broken'
manage_options
=
({
'label'
:
'Traceback'
,
'action'
:
'manage_traceback'
},)
manage_options
=
({
'label'
:
'Traceback'
,
'action'
:
'manage_traceback'
},)
meta_type
=
'Broken Temporary Folder'
meta_type
=
'Broken Temporary Folder'
def
__init__
(
self
,
id
,
title
=
''
,
params
=
None
):
def
__init__
(
self
,
id
,
title
=
''
,
params
=
None
):
self
.
id
=
str
(
id
)
self
.
id
=
str
(
id
)
self
.
title
=
title
self
.
title
=
title
...
@@ -71,7 +71,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
...
@@ -71,7 +71,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
db
=
DB
(
TemporaryStorage
())
db
=
DB
(
TemporaryStorage
())
db
.
klass
=
LowConflictConnection
db
.
klass
=
LowConflictConnection
return
db
return
db
def
_getMountRoot
(
self
,
root
):
def
_getMountRoot
(
self
,
root
):
sdc
=
root
.
get
(
'folder'
,
None
)
sdc
=
root
.
get
(
'folder'
,
None
)
if
sdc
is
None
:
if
sdc
is
None
:
...
@@ -79,7 +79,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
...
@@ -79,7 +79,7 @@ class MountedTemporaryFolder(MountPoint, OFS.SimpleItem.Item):
self
.
_populate
(
sdc
,
root
)
self
.
_populate
(
sdc
,
root
)
return
sdc
return
sdc
def
mount_error_
(
self
):
def
mount_error_
(
self
):
return
self
.
_v_connect_error
return
self
.
_v_connect_error
...
...
lib/python/Products/TemporaryFolder/TemporaryStorage.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
...
@@ -17,10 +17,10 @@ MappingStorage. Unlike MappingStorage, it needs not be packed to get rid of
...
@@ -17,10 +17,10 @@ MappingStorage. Unlike MappingStorage, it needs not be packed to get rid of
non-cyclic garbage and it does rudimentary conflict resolution. This is a
non-cyclic garbage and it does rudimentary conflict resolution. This is a
ripoff of Jim's Packless bsddb3 storage.
ripoff of Jim's Packless bsddb3 storage.
$Id: TemporaryStorage.py,v 1.
9 2002/06/30 18:23:15 chrism
Exp $
$Id: TemporaryStorage.py,v 1.
10 2002/08/14 22:25:13 mj
Exp $
"""
"""
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
10
$'
[
11
:
-
2
]
from
zLOG
import
LOG
,
BLATHER
from
zLOG
import
LOG
,
BLATHER
from
ZODB.referencesf
import
referencesf
from
ZODB.referencesf
import
referencesf
...
@@ -82,12 +82,12 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
...
@@ -82,12 +82,12 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
del
self
.
_conflict_cache
[
k
]
del
self
.
_conflict_cache
[
k
]
self
.
_last_cache_gc
=
now
self
.
_last_cache_gc
=
now
self
.
_tmp
=
[]
self
.
_tmp
=
[]
def
close
(
self
):
def
close
(
self
):
"""
"""
Close the storage
Close the storage
"""
"""
def
load
(
self
,
oid
,
version
):
def
load
(
self
,
oid
,
version
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
...
@@ -112,7 +112,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
...
@@ -112,7 +112,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
return
data
[
0
]
# data here is actually (data, t)
return
data
[
0
]
# data here is actually (data, t)
finally
:
finally
:
self
.
_lock_release
()
self
.
_lock_release
()
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
if
transaction
is
not
self
.
_transaction
:
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
...
@@ -217,7 +217,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
...
@@ -217,7 +217,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
self
.
_takeOutGarbage
(
oid
)
self
.
_takeOutGarbage
(
oid
)
self
.
_tmp
=
[]
self
.
_tmp
=
[]
def
_takeOutGarbage
(
self
,
oid
):
def
_takeOutGarbage
(
self
,
oid
):
# take out the garbage.
# take out the garbage.
referenceCount
=
self
.
_referenceCount
referenceCount
=
self
.
_referenceCount
...
@@ -246,7 +246,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
...
@@ -246,7 +246,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
referenceCount
[
roid
]
=
rc
-
1
referenceCount
[
roid
]
=
rc
-
1
try
:
del
self
.
_oreferences
[
oid
]
try
:
del
self
.
_oreferences
[
oid
]
except
:
pass
except
:
pass
def
pack
(
self
,
t
,
referencesf
):
def
pack
(
self
,
t
,
referencesf
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
...
@@ -268,9 +268,3 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
...
@@ -268,9 +268,3 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
self
.
_takeOutGarbage
(
oid
)
self
.
_takeOutGarbage
(
oid
)
finally
:
finally
:
self
.
_lock_release
()
self
.
_lock_release
()
lib/python/Products/TemporaryFolder/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Temporary Folder initialization routines
Temporary Folder initialization routines
$Id: __init__.py,v 1.
5 2002/01/11 14:53:38 chrism
Exp $
$Id: __init__.py,v 1.
6 2002/08/14 22:25:13 mj
Exp $
"""
"""
import
ZODB
# for testrunner to be happy
import
ZODB
# for testrunner to be happy
...
...
lib/python/Products/TemporaryFolder/patchfs.py
View file @
2639fcb7
# Utility program to patch Data.fs.in to include a temporary folder, browser
# Utility program to patch Data.fs.in to include a temporary folder, browser
# id manager, and session data manager
# id manager, and session data manager
############################################################################
############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
...
@@ -18,7 +18,7 @@ import Globals
...
@@ -18,7 +18,7 @@ import Globals
from
ZODB
import
FileStorage
,
DB
from
ZODB
import
FileStorage
,
DB
import
Products.Sessions.BrowserIdManager
import
Products.Sessions.BrowserIdManager
import
Products.Sessions.SessionDataManager
import
Products.Sessions.SessionDataManager
import
Products.TemporaryFolder.TemporaryFolder
import
Products.TemporaryFolder.TemporaryFolder
import
os.path
import
os.path
import
sys
import
sys
...
...
lib/python/Products/TemporaryFolder/tests/testTemporaryStorage.py
View file @
2639fcb7
import
ZODB
import
ZODB
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.MinPO
import
MinPO
from
Products.TemporaryFolder
import
TemporaryStorage
from
Products.TemporaryFolder
import
TemporaryStorage
...
@@ -47,7 +46,7 @@ class TemporaryStorageTests(
...
@@ -47,7 +46,7 @@ class TemporaryStorageTests(
oid4
=
self
.
_storage
.
new_oid
()
oid4
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
1
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
1
finally
:
finally
:
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
old_gcevery
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
old_gcevery
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
old_maxage
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
old_maxage
...
@@ -64,14 +63,14 @@ def main():
...
@@ -64,14 +63,14 @@ def main():
runner
.
run
(
alltests
)
runner
.
run
(
alltests
)
def
debug
():
def
debug
():
test_suite
().
debug
()
test_suite
().
debug
()
def
pdebug
():
def
pdebug
():
import
pdb
import
pdb
pdb
.
run
(
'debug()'
)
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
globals
()[
sys
.
argv
[
1
]]()
else
:
else
:
main
()
main
()
lib/python/Products/Transience/Transience.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Transient Object Container Class ('timeslice'-based design).
Transient Object Container Class ('timeslice'-based design).
$Id: Transience.py,v 1.2
7 2002/08/07 14:48:48 chrism
Exp $
$Id: Transience.py,v 1.2
8 2002/08/14 22:25:13 mj
Exp $
"""
"""
__version__
=
'$Revision: 1.2
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
8
$'
[
11
:
-
2
]
import
Globals
import
Globals
from
Globals
import
HTMLFile
from
Globals
import
HTMLFile
...
@@ -127,7 +127,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -127,7 +127,7 @@ class TransientObjectContainer(SimpleItem):
{
'label'
:
'Manage'
,
{
'label'
:
'Manage'
,
'action'
:
'manage_container'
,
'action'
:
'manage_container'
,
'help'
:
(
'Transience'
,
'Transience.stx'
)
'help'
:
(
'Transience'
,
'Transience.stx'
)
},
},
{
'label'
:
'Security'
,
{
'label'
:
'Security'
,
'action'
:
'manage_access'
'action'
:
'manage_access'
},
},
...
@@ -229,7 +229,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -229,7 +229,7 @@ class TransientObjectContainer(SimpleItem):
def
setAddNotificationTarget
(
self
,
f
):
def
setAddNotificationTarget
(
self
,
f
):
# We should assert that the callback function 'f' implements
# We should assert that the callback function 'f' implements
# the TransientNotification interface
# the TransientNotification interface
self
.
_addCallback
=
f
self
.
_addCallback
=
f
security
.
declareProtected
(
MGMT_SCREEN_PERM
,
'getDelNotificationTarget'
)
security
.
declareProtected
(
MGMT_SCREEN_PERM
,
'getDelNotificationTarget'
)
def
getDelNotificationTarget
(
self
):
def
getDelNotificationTarget
(
self
):
...
@@ -252,7 +252,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -252,7 +252,7 @@ class TransientObjectContainer(SimpleItem):
def
_notify
(
self
,
items
,
kind
):
def
_notify
(
self
,
items
,
kind
):
if
not
type
(
items
)
in
[
type
([]),
type
(())]:
if
not
type
(
items
)
in
[
type
([]),
type
(())]:
items
=
[
items
]
items
=
[
items
]
if
kind
==
'add'
:
if
kind
==
'add'
:
name
=
'notifyAdd'
name
=
'notifyAdd'
callback
=
self
.
_addCallback
callback
=
self
.
_addCallback
...
@@ -437,7 +437,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -437,7 +437,7 @@ class TransientObjectContainer(SimpleItem):
self
.
_deindex_next
=
Increaser
(
self
.
_getCurrentTimeslice
())
self
.
_deindex_next
=
Increaser
(
self
.
_getCurrentTimeslice
())
finally
:
finally
:
self
.
lock
.
release
()
self
.
lock
.
release
()
def
_getCurrentBucket
(
self
):
def
_getCurrentBucket
(
self
):
"""
"""
Do housekeeping if necessary, then return the 'current' bucket.
Do housekeeping if necessary, then return the 'current' bucket.
...
@@ -673,7 +673,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -673,7 +673,7 @@ class TransientObjectContainer(SimpleItem):
data
[
i
]
=
OOBTree
()
data
[
i
]
=
OOBTree
()
except
Queue
.
Empty
:
except
Queue
.
Empty
:
DEBUG
and
TLOG
(
'replentish queue empty'
)
DEBUG
and
TLOG
(
'replentish queue empty'
)
# gc the stale buckets at the "beginning" of _data ("garbage collect")
# gc the stale buckets at the "beginning" of _data ("garbage collect")
# iterate over the keys in data that have no minimum value and
# iterate over the keys in data that have no minimum value and
# a maximum value of delete_end (note: ordered set)
# a maximum value of delete_end (note: ordered set)
...
@@ -741,7 +741,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -741,7 +741,7 @@ class TransientObjectContainer(SimpleItem):
finally
:
finally
:
self
.
lock
.
release
()
self
.
lock
.
release
()
def
__getitem__
(
self
,
k
):
def
__getitem__
(
self
,
k
):
self
.
lock
.
acquire
()
self
.
lock
.
acquire
()
try
:
try
:
...
@@ -803,7 +803,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -803,7 +803,7 @@ class TransientObjectContainer(SimpleItem):
# we accessed the object, so it becomes current
# we accessed the object, so it becomes current
# by moving it to the current bucket
# by moving it to the current bucket
del
self
.
_data
[
b
][
k
]
# delete the item from the old bucket.
del
self
.
_data
[
b
][
k
]
# delete the item from the old bucket.
self
.
_data
[
current
][
k
]
=
v
# add the value to the current
self
.
_data
[
current
][
k
]
=
v
# add the value to the current
self
.
_setLastAccessed
(
v
)
self
.
_setLastAccessed
(
v
)
index
[
k
]
=
current
# change the index to the current buck.
index
[
k
]
=
current
# change the index to the current buck.
...
@@ -812,7 +812,7 @@ class TransientObjectContainer(SimpleItem):
...
@@ -812,7 +812,7 @@ class TransientObjectContainer(SimpleItem):
return
v
return
v
finally
:
finally
:
self
.
lock
.
release
()
self
.
lock
.
release
()
def
_setLastAccessed
(
self
,
transientObject
):
def
_setLastAccessed
(
self
,
transientObject
):
self
.
lock
.
acquire
()
self
.
lock
.
acquire
()
try
:
try
:
...
@@ -860,7 +860,7 @@ class Increaser(Persistent):
...
@@ -860,7 +860,7 @@ class Increaser(Persistent):
def
set
(
self
,
v
):
def
set
(
self
,
v
):
self
.
value
=
v
self
.
value
=
v
def
__getstate__
(
self
):
def
__getstate__
(
self
):
return
self
.
value
return
self
.
value
...
...
lib/python/Products/Transience/TransienceInterfaces.py
View file @
2639fcb7
##########################################################################
##########################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##########################################################################
##########################################################################
"""
"""
Transient Objects
Transient Objects
...
@@ -66,7 +66,7 @@ Transient Objects
...
@@ -66,7 +66,7 @@ Transient Objects
class Foo(Persistence.Persistent):
class Foo(Persistence.Persistent):
pass
pass
transient_object = transient_data_container.new('t')
transient_object = transient_data_container.new('t')
foo = transient_object['foo'] = Foo()
foo = transient_object['foo'] = Foo()
foo.bar = 1
foo.bar = 1
...
@@ -270,7 +270,7 @@ class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
...
@@ -270,7 +270,7 @@ class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
Returned object is acquisition-wrapped in self.
Returned object is acquisition-wrapped in self.
"""
"""
class
TransientItemContainer
(
Interface
.
Base
):
class
TransientItemContainer
(
Interface
.
Base
):
def
setTimeoutMinutes
(
timeout_mins
):
def
setTimeoutMinutes
(
timeout_mins
):
"""
"""
...
...
lib/python/Products/Transience/TransientObject.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Simple ZODB-based transient object implementation.
Simple ZODB-based transient object implementation.
$Id: TransientObject.py,v 1.
8 2002/06/24 19:31:16 chrism
Exp $
$Id: TransientObject.py,v 1.
9 2002/08/14 22:25:13 mj
Exp $
"""
"""
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
Acquisition
import
Implicit
from
Acquisition
import
Implicit
...
@@ -114,7 +114,7 @@ class TransientObject(Persistent, Implicit):
...
@@ -114,7 +114,7 @@ class TransientObject(Persistent, Implicit):
def
getContainerKey
(
self
):
def
getContainerKey
(
self
):
return
self
.
token
return
self
.
token
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# DictionaryLike
# DictionaryLike
#
#
...
@@ -132,7 +132,7 @@ class TransientObject(Persistent, Implicit):
...
@@ -132,7 +132,7 @@ class TransientObject(Persistent, Implicit):
v
=
self
.
_container
.
get
(
k
,
default
)
v
=
self
.
_container
.
get
(
k
,
default
)
if
v
is
_notfound
:
return
None
if
v
is
_notfound
:
return
None
return
v
return
v
def
has_key
(
self
,
k
):
def
has_key
(
self
,
k
):
if
self
.
_container
.
get
(
k
,
_notfound
)
is
not
_notfound
:
return
1
if
self
.
_container
.
get
(
k
,
_notfound
)
is
not
_notfound
:
return
1
return
0
return
0
...
@@ -243,7 +243,7 @@ class TransientObject(Persistent, Implicit):
...
@@ -243,7 +243,7 @@ class TransientObject(Persistent, Implicit):
'Conflict resolution error in TransientObject'
,
''
,
'Conflict resolution error in TransientObject'
,
''
,
sys
.
exc_info
()
sys
.
exc_info
()
)
)
getName
=
getId
# this is for SQLSession compatibility
getName
=
getId
# this is for SQLSession compatibility
def
_generateUniqueId
(
self
):
def
_generateUniqueId
(
self
):
...
...
lib/python/Products/Transience/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Transience initialization routines
Transience initialization routines
$Id: __init__.py,v 1.
6 2001/11/28 15:51:09 matt
Exp $
$Id: __init__.py,v 1.
7 2002/08/14 22:25:13 mj
Exp $
"""
"""
import
ZODB
# this is to help out testrunner, don't remove.
import
ZODB
# this is to help out testrunner, don't remove.
...
@@ -21,7 +21,7 @@ import Transience
...
@@ -21,7 +21,7 @@ import Transience
# import of MaxTransientObjectsExceeded for easy import from scripts,
# import of MaxTransientObjectsExceeded for easy import from scripts,
# this is protected by a module security info declaration in the
# this is protected by a module security info declaration in the
# Sessions package.
# Sessions package.
from
Transience
import
MaxTransientObjectsExceeded
from
Transience
import
MaxTransientObjectsExceeded
def
initialize
(
context
):
def
initialize
(
context
):
context
.
registerClass
(
context
.
registerClass
(
...
@@ -33,4 +33,3 @@ def initialize(context):
...
@@ -33,4 +33,3 @@ def initialize(context):
)
)
context
.
registerHelp
()
context
.
registerHelp
()
context
.
registerHelpTitle
(
'Zope Help'
)
context
.
registerHelpTitle
(
'Zope Help'
)
lib/python/Products/Transience/help/TransienceInterfaces.py
View file @
2639fcb7
##########################################################################
##########################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##########################################################################
##########################################################################
"""
"""
Transient Objects
Transient Objects
...
@@ -24,7 +24,7 @@ class TransientObjectContainer:
...
@@ -24,7 +24,7 @@ class TransientObjectContainer:
container. You'll almost always deal with a TransientObject
container. You'll almost always deal with a TransientObject
itself which you'll usually get as 'REQUEST.SESSION'.
itself which you'll usually get as 'REQUEST.SESSION'.
"""
"""
def
getId
(
self
):
def
getId
(
self
):
"""
"""
Returns a meaningful unique id for the object.
Returns a meaningful unique id for the object.
...
@@ -79,7 +79,7 @@ class TransientObjectContainer:
...
@@ -79,7 +79,7 @@ class TransientObjectContainer:
Permission -- 'Create Transient Objects'
Permission -- 'Create Transient Objects'
"""
"""
def
setTimeoutMinutes
(
self
,
timeout_mins
):
def
setTimeoutMinutes
(
self
,
timeout_mins
):
"""
"""
Set the number of minutes of inactivity allowable for subobjects
Set the number of minutes of inactivity allowable for subobjects
...
@@ -182,7 +182,7 @@ class TransientObject:
...
@@ -182,7 +182,7 @@ class TransientObject:
Permission -- Always available
Permission -- Always available
"""
"""
def
invalidate
(
self
):
def
invalidate
(
self
):
"""
"""
Invalidate (expire) the transient object.
Invalidate (expire) the transient object.
...
@@ -291,5 +291,3 @@ class MaxTransientObjectsExceeded:
...
@@ -291,5 +291,3 @@ class MaxTransientObjectsExceeded:
from Products.Transience import MaxTransientObjectsExceeded
from Products.Transience import MaxTransientObjectsExceeded
"""
"""
lib/python/Products/Transience/tests/fauxtime.py
View file @
2639fcb7
...
@@ -9,4 +9,3 @@ def time():
...
@@ -9,4 +9,3 @@ def time():
def
sleep
(
duration
):
def
sleep
(
duration
):
""" False sleep -- sleep for 1/10 the time specifed """
""" False sleep -- sleep for 1/10 the time specifed """
origtime
.
sleep
(
duration
/
10.0
)
origtime
.
sleep
(
duration
/
10.0
)
lib/python/Products/Transience/tests/testTimeoutRelated.py
View file @
2639fcb7
...
@@ -72,7 +72,7 @@ class TestBase(TestCase):
...
@@ -72,7 +72,7 @@ class TestBase(TestCase):
del
self
.
app
del
self
.
app
Products
.
Transience
.
Transience
.
time
=
oldtime
Products
.
Transience
.
Transience
.
time
=
oldtime
Products
.
Transience
.
TransientObject
.
time
=
oldtime
Products
.
Transience
.
TransientObject
.
time
=
oldtime
class
TestLastAccessed
(
TestBase
):
class
TestLastAccessed
(
TestBase
):
def
testLastAccessed
(
self
):
def
testLastAccessed
(
self
):
sdo
=
self
.
app
.
sm
.
new_or_existing
(
'TempObject'
)
sdo
=
self
.
app
.
sm
.
new_or_existing
(
'TempObject'
)
...
...
lib/python/Products/Transience/tests/testTransientObject.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
os
,
unittest
import
sys
,
os
,
unittest
...
@@ -34,7 +34,7 @@ class TestTransientObject(TestCase):
...
@@ -34,7 +34,7 @@ class TestTransientObject(TestCase):
Products
.
Transience
.
TransientObject
.
time
=
oldtime
Products
.
Transience
.
TransientObject
.
time
=
oldtime
self
.
t
=
None
self
.
t
=
None
del
self
.
t
del
self
.
t
def
test_id
(
self
):
def
test_id
(
self
):
t
=
self
.
t
.
new
(
'xyzzy'
)
t
=
self
.
t
.
new
(
'xyzzy'
)
assert
t
.
getId
()
!=
'xyzzy'
assert
t
.
getId
()
!=
'xyzzy'
...
@@ -99,10 +99,10 @@ class TestTransientObject(TestCase):
...
@@ -99,10 +99,10 @@ class TestTransientObject(TestCase):
assert
t
.
get
(
'foobie'
)
is
None
assert
t
.
get
(
'foobie'
)
is
None
self
.
assertRaises
(
AttributeError
,
self
.
_genLenError
,
t
)
self
.
assertRaises
(
AttributeError
,
self
.
_genLenError
,
t
)
assert
t
.
get
(
'foobie'
,
None
)
is
None
assert
t
.
get
(
'foobie'
,
None
)
is
None
assert
t
.
has_key
(
'a'
)
assert
t
.
has_key
(
'a'
)
assert
not
t
.
has_key
(
'foobie'
)
assert
not
t
.
has_key
(
'foobie'
)
t
.
clear
()
t
.
clear
()
assert
not
len
(
t
.
keys
())
assert
not
len
(
t
.
keys
())
def
test_TTWDictionary
(
self
):
def
test_TTWDictionary
(
self
):
t
=
self
.
t
.
new
(
'mouthfultest'
)
t
=
self
.
t
.
new
(
'mouthfultest'
)
...
@@ -111,7 +111,7 @@ class TestTransientObject(TestCase):
...
@@ -111,7 +111,7 @@ class TestTransientObject(TestCase):
assert
t
.
get
(
'foo'
)
==
'bar'
assert
t
.
get
(
'foo'
)
==
'bar'
t
.
set
(
'foobie'
,
'blech'
)
t
.
set
(
'foobie'
,
'blech'
)
t
.
delete
(
'foobie'
)
t
.
delete
(
'foobie'
)
assert
t
.
get
(
'foobie'
)
is
None
assert
t
.
get
(
'foobie'
)
is
None
def
test_suite
():
def
test_suite
():
...
@@ -130,4 +130,3 @@ data = {
...
@@ -130,4 +130,3 @@ data = {
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
.
run
(
test_suite
())
runner
.
run
(
test_suite
())
lib/python/Products/Transience/tests/testTransientObjectContainer.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
os
,
time
,
random
,
unittest
import
sys
,
os
,
time
,
random
,
unittest
...
@@ -75,7 +75,7 @@ class TestTransientObjectContainer(TestBase):
...
@@ -75,7 +75,7 @@ class TestTransientObjectContainer(TestBase):
for
x
in
v
:
for
x
in
v
:
assert
x
==
i
assert
x
==
i
i
=
i
+
1
i
=
i
+
1
def
testKeysWorks
(
self
):
def
testKeysWorks
(
self
):
for
x
in
range
(
10
,
110
):
for
x
in
range
(
10
,
110
):
self
.
t
[
x
]
=
x
self
.
t
[
x
]
=
x
...
@@ -137,7 +137,7 @@ class TestTransientObjectContainer(TestBase):
...
@@ -137,7 +137,7 @@ class TestTransientObjectContainer(TestBase):
self
.
t
[
4
]
=
99
self
.
t
[
4
]
=
99
del
self
.
t
[
2
]
del
self
.
t
[
2
]
assert
lsubtract
(
self
.
t
.
keys
(),[
1
,
3
,
4
,
5
,
6
,
10
])
==
[],
`self.t.keys()`
assert
lsubtract
(
self
.
t
.
keys
(),[
1
,
3
,
4
,
5
,
6
,
10
])
==
[],
`self.t.keys()`
def
donttestDeleteTwoChildrenInorderSuccessorWorks
(
self
):
def
donttestDeleteTwoChildrenInorderSuccessorWorks
(
self
):
self
.
t
[
5
]
=
6
self
.
t
[
5
]
=
6
self
.
t
[
2
]
=
10
self
.
t
[
2
]
=
10
...
@@ -325,7 +325,7 @@ class TestTransientObjectContainer(TestBase):
...
@@ -325,7 +325,7 @@ class TestTransientObjectContainer(TestBase):
# we should still have 100 - 199
# we should still have 100 - 199
for
x
in
range
(
110
,
210
):
for
x
in
range
(
110
,
210
):
assert
self
.
t
[
x
]
==
x
assert
self
.
t
[
x
]
==
x
# but we shouldn't have 0 - 100
# but we shouldn't have 0 - 100
for
x
in
range
(
10
,
110
):
for
x
in
range
(
10
,
110
):
try
:
self
.
t
[
x
]
try
:
self
.
t
[
x
]
except
KeyError
:
pass
except
KeyError
:
pass
...
@@ -439,13 +439,13 @@ class TestTransientObjectContainer(TestBase):
...
@@ -439,13 +439,13 @@ class TestTransientObjectContainer(TestBase):
for
x
in
range
(
11
):
for
x
in
range
(
11
):
self
.
t
.
new
(
str
(
x
))
self
.
t
.
new
(
str
(
x
))
def
lsubtract
(
l1
,
l2
):
def
lsubtract
(
l1
,
l2
):
l1
=
list
(
l1
)
l1
=
list
(
l1
)
l2
=
list
(
l2
)
l2
=
list
(
l2
)
l
=
filter
(
lambda
x
,
l1
=
l1
:
x
not
in
l1
,
l2
)
l
=
filter
(
lambda
x
,
l1
=
l1
:
x
not
in
l1
,
l2
)
l
=
l
+
filter
(
lambda
x
,
l2
=
l2
:
x
not
in
l2
,
l1
)
l
=
l
+
filter
(
lambda
x
,
l2
=
l2
:
x
not
in
l2
,
l1
)
return
l
return
l
def
test_suite
():
def
test_suite
():
testsuite
=
makeSuite
(
TestTransientObjectContainer
,
'test'
)
testsuite
=
makeSuite
(
TestTransientObjectContainer
,
'test'
)
...
@@ -456,4 +456,3 @@ def test_suite():
...
@@ -456,4 +456,3 @@ def test_suite():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
=
TextTestRunner
(
verbosity
=
9
)
runner
.
run
(
test_suite
())
runner
.
run
(
test_suite
())
lib/python/Products/ZCTextIndex/BaseIndex.py
View file @
2639fcb7
...
@@ -81,10 +81,10 @@ class BaseIndex(Persistent):
...
@@ -81,10 +81,10 @@ class BaseIndex(Persistent):
# docid -> WidCode'd list of wids
# docid -> WidCode'd list of wids
# Used for un-indexing, and for phrase search.
# Used for un-indexing, and for phrase search.
self
.
_docwords
=
IOBTree
()
self
.
_docwords
=
IOBTree
()
# Use a BTree length for efficient length computation w/o conflicts
# Use a BTree length for efficient length computation w/o conflicts
self
.
length
=
BTrees
.
Length
.
Length
()
self
.
length
=
BTrees
.
Length
.
Length
()
def
length
(
self
):
def
length
(
self
):
"""Return the number of words in the index."""
"""Return the number of words in the index."""
# This is overridden per instance
# This is overridden per instance
...
@@ -155,7 +155,7 @@ class BaseIndex(Persistent):
...
@@ -155,7 +155,7 @@ class BaseIndex(Persistent):
# The wid->weight mappings are fed into _add_wordinfo, and docweight
# The wid->weight mappings are fed into _add_wordinfo, and docweight
# becomes the value of _docweight[docid].
# becomes the value of _docweight[docid].
raise
NotImplementedError
raise
NotImplementedError
def
has_doc
(
self
,
docid
):
def
has_doc
(
self
,
docid
):
return
self
.
_docwords
.
has_key
(
docid
)
return
self
.
_docwords
.
has_key
(
docid
)
...
@@ -281,7 +281,7 @@ class BaseIndex(Persistent):
...
@@ -281,7 +281,7 @@ class BaseIndex(Persistent):
doc2score
[
docid
]
=
weight
doc2score
[
docid
]
=
weight
self
.
_wordinfo
[
wid
]
=
doc2score
# not redundant: Persistency!
self
.
_wordinfo
[
wid
]
=
doc2score
# not redundant: Persistency!
self
.
length
.
change
(
new_word_count
)
self
.
length
.
change
(
new_word_count
)
def
_del_wordinfo
(
self
,
wid
,
docid
):
def
_del_wordinfo
(
self
,
wid
,
docid
):
doc2score
=
self
.
_wordinfo
[
wid
]
doc2score
=
self
.
_wordinfo
[
wid
]
...
...
lib/python/Products/ZCTextIndex/IIndex.py
View file @
2639fcb7
...
@@ -66,6 +66,6 @@ class IIndex(Interface.Base):
...
@@ -66,6 +66,6 @@ class IIndex(Interface.Base):
def
unindex_doc
(
docid
):
def
unindex_doc
(
docid
):
"XXX"
"XXX"
def
has_doc
(
docid
):
def
has_doc
(
docid
):
"""Returns true if docid is an id of a document in the index"""
"""Returns true if docid is an id of a document in the index"""
lib/python/Products/ZCTextIndex/ZCTextIndex.py
View file @
2639fcb7
...
@@ -56,7 +56,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -56,7 +56,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
)
)
query_options
=
[
'query'
]
query_options
=
[
'query'
]
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
manage_zcatalog_indexes
)
security
.
declareObjectProtected
(
manage_zcatalog_indexes
)
...
@@ -65,11 +65,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -65,11 +65,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
def
__init__
(
self
,
id
,
extra
=
None
,
caller
=
None
,
index_factory
=
None
,
def
__init__
(
self
,
id
,
extra
=
None
,
caller
=
None
,
index_factory
=
None
,
field_name
=
None
,
lexicon_id
=
None
):
field_name
=
None
,
lexicon_id
=
None
):
self
.
id
=
id
self
.
id
=
id
# Arguments can be passed directly to the constructor or
# Arguments can be passed directly to the constructor or
# via the silly "extra" record.
# via the silly "extra" record.
self
.
_fieldname
=
field_name
or
getattr
(
extra
,
'doc_attr'
,
''
)
or
id
self
.
_fieldname
=
field_name
or
getattr
(
extra
,
'doc_attr'
,
''
)
or
id
lexicon_id
=
lexicon_id
or
extra
.
lexicon_idp
lexicon_id
=
lexicon_id
or
extra
.
lexicon_idp
lexicon
=
getattr
(
caller
,
lexicon_id
,
None
)
lexicon
=
getattr
(
caller
,
lexicon_id
,
None
)
...
@@ -94,11 +94,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -94,11 +94,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
self
.
_index_factory
=
index_factory
self
.
_index_factory
=
index_factory
self
.
index
=
self
.
_index_factory
(
self
.
getLexicon
())
self
.
index
=
self
.
_index_factory
(
self
.
getLexicon
())
## Private Methods ##
## Private Methods ##
security
.
declarePrivate
(
'getLexicon'
)
security
.
declarePrivate
(
'getLexicon'
)
def
getLexicon
(
self
):
def
getLexicon
(
self
):
"""Get the lexicon for this index
"""Get the lexicon for this index
"""
"""
...
@@ -108,7 +108,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -108,7 +108,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
lexicon
=
getattr
(
self
.
aq_parent
,
self
.
lexicon
.
getId
())
lexicon
=
getattr
(
self
.
aq_parent
,
self
.
lexicon
.
getId
())
self
.
lexicon_path
=
lexicon
.
getPhysicalPath
()
self
.
lexicon_path
=
lexicon
.
getPhysicalPath
()
del
self
.
lexicon
del
self
.
lexicon
try
:
try
:
return
self
.
_v_lexicon
return
self
.
_v_lexicon
except
AttributeError
:
except
AttributeError
:
...
@@ -122,7 +122,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -122,7 +122,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
## External methods not in the Pluggable Index API ##
## External methods not in the Pluggable Index API ##
security
.
declareProtected
(
'query'
,
search_zcatalog
)
security
.
declareProtected
(
'query'
,
search_zcatalog
)
def
query
(
self
,
query
,
nbest
=
10
):
def
query
(
self
,
query
,
nbest
=
10
):
"""Return pair (mapping from docids to scores, num results).
"""Return pair (mapping from docids to scores, num results).
...
@@ -196,8 +196,8 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -196,8 +196,8 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
"""reinitialize the index (but not the lexicon)"""
"""reinitialize the index (but not the lexicon)"""
try
:
try
:
# Remove the cached reference to the lexicon
# Remove the cached reference to the lexicon
# So that it is refreshed
# So that it is refreshed
del
self
.
_v_lexicon
del
self
.
_v_lexicon
except
(
AttributeError
,
KeyError
):
except
(
AttributeError
,
KeyError
):
pass
pass
self
.
index
=
self
.
_index_factory
(
self
.
getLexicon
())
self
.
index
=
self
.
_index_factory
(
self
.
getLexicon
())
...
@@ -209,11 +209,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
...
@@ -209,11 +209,11 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
def
getIndexType
(
self
):
def
getIndexType
(
self
):
"""Return index type string"""
"""Return index type string"""
return
getattr
(
self
,
'_index_type'
,
self
.
_index_factory
.
__name__
)
return
getattr
(
self
,
'_index_type'
,
self
.
_index_factory
.
__name__
)
def
getFieldName
(
self
):
def
getFieldName
(
self
):
"""Return indexed attribute name"""
"""Return indexed attribute name"""
return
self
.
_fieldname
return
self
.
_fieldname
def
getLexiconPath
(
self
):
def
getLexiconPath
(
self
):
"""Return the path of the lexicon used by the index"""
"""Return the path of the lexicon used by the index"""
try
:
try
:
...
@@ -268,7 +268,7 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
...
@@ -268,7 +268,7 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
manage_options
=
({
'label'
:
'Overview'
,
'action'
:
'manage_main'
},
manage_options
=
({
'label'
:
'Overview'
,
'action'
:
'manage_main'
},
{
'label'
:
'Query'
,
'action'
:
'queryLexicon'
},
{
'label'
:
'Query'
,
'action'
:
'queryLexicon'
},
)
+
SimpleItem
.
manage_options
)
+
SimpleItem
.
manage_options
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
LexiconQueryPerm
)
security
.
declareObjectProtected
(
LexiconQueryPerm
)
...
@@ -282,11 +282,11 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
...
@@ -282,11 +282,11 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
def
getPipelineNames
(
self
):
def
getPipelineNames
(
self
):
"""Return list of names of pipeline element classes"""
"""Return list of names of pipeline element classes"""
return
[
element
.
__class__
.
__name__
for
element
in
self
.
_pipeline
]
return
[
element
.
__class__
.
__name__
for
element
in
self
.
_pipeline
]
_queryLexicon
=
DTMLFile
(
'dtml/queryLexicon'
,
globals
())
_queryLexicon
=
DTMLFile
(
'dtml/queryLexicon'
,
globals
())
security
.
declareProtected
(
LexiconQueryPerm
,
'queryLexicon'
)
security
.
declareProtected
(
LexiconQueryPerm
,
'queryLexicon'
)
def
queryLexicon
(
self
,
REQUEST
,
words
=
None
,
page
=
0
,
rows
=
20
,
cols
=
4
):
def
queryLexicon
(
self
,
REQUEST
,
words
=
None
,
page
=
0
,
rows
=
20
,
cols
=
4
):
"""Lexicon browser/query user interface
"""Lexicon browser/query user interface
"""
"""
...
@@ -297,7 +297,7 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
...
@@ -297,7 +297,7 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
words
=
[
self
.
get_word
(
wid
)
for
wid
in
wids
]
words
=
[
self
.
get_word
(
wid
)
for
wid
in
wids
]
else
:
else
:
words
=
self
.
words
()
words
=
self
.
words
()
word_count
=
len
(
words
)
word_count
=
len
(
words
)
rows
=
max
(
min
(
rows
,
500
),
1
)
rows
=
max
(
min
(
rows
,
500
),
1
)
cols
=
max
(
min
(
cols
,
12
),
1
)
cols
=
max
(
min
(
cols
,
12
),
1
)
...
@@ -306,18 +306,18 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
...
@@ -306,18 +306,18 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
page
=
max
(
min
(
page
,
page_count
-
1
),
0
)
page
=
max
(
min
(
page
,
page_count
-
1
),
0
)
start
=
rows
*
cols
*
page
start
=
rows
*
cols
*
page
end
=
min
(
rows
*
cols
*
(
page
+
1
),
word_count
)
end
=
min
(
rows
*
cols
*
(
page
+
1
),
word_count
)
if
word_count
:
if
word_count
:
words
=
list
(
words
[
start
:
end
])
words
=
list
(
words
[
start
:
end
])
else
:
else
:
words
=
[]
words
=
[]
columns
=
[]
columns
=
[]
i
=
0
i
=
0
while
i
<
len
(
words
):
while
i
<
len
(
words
):
columns
.
append
(
words
[
i
:
i
+
rows
])
columns
.
append
(
words
[
i
:
i
+
rows
])
i
+=
rows
i
+=
rows
return
self
.
_queryLexicon
(
self
,
REQUEST
,
return
self
.
_queryLexicon
(
self
,
REQUEST
,
page
=
page
,
page
=
page
,
rows
=
rows
,
rows
=
rows
,
...
@@ -328,8 +328,8 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
...
@@ -328,8 +328,8 @@ class PLexicon(Lexicon, Acquisition.Implicit, SimpleItem):
page_count
=
page_count
,
page_count
=
page_count
,
page_range
=
xrange
(
page_count
),
page_range
=
xrange
(
page_count
),
page_columns
=
columns
)
page_columns
=
columns
)
security
.
declareProtected
(
LexiconMgmtPerm
,
'manage_main'
)
security
.
declareProtected
(
LexiconMgmtPerm
,
'manage_main'
)
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
manage_main
=
DTMLFile
(
'dtml/manageLexicon'
,
globals
())
InitializeClass
(
PLexicon
)
InitializeClass
(
PLexicon
)
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
View file @
2639fcb7
...
@@ -41,10 +41,10 @@ class Indexable:
...
@@ -41,10 +41,10 @@ class Indexable:
class
LexiconHolder
(
Acquisition
.
Implicit
):
class
LexiconHolder
(
Acquisition
.
Implicit
):
def
__init__
(
self
,
lexicon
):
def
__init__
(
self
,
lexicon
):
self
.
lexicon
=
lexicon
self
.
lexicon
=
lexicon
def
getPhysicalPath
(
self
):
def
getPhysicalPath
(
self
):
return
(
''
,)
# Pretend to be the root
return
(
''
,)
# Pretend to be the root
def
dummyUnrestrictedTraverse
(
self
,
path
):
def
dummyUnrestrictedTraverse
(
self
,
path
):
if
path
==
(
''
,
'lexicon'
,):
if
path
==
(
''
,
'lexicon'
,):
return
self
.
lexicon
return
self
.
lexicon
...
@@ -102,13 +102,13 @@ class ZCIndexTestsBase:
...
@@ -102,13 +102,13 @@ class ZCIndexTestsBase:
def
setUp
(
self
):
def
setUp
(
self
):
self
.
lexicon
=
PLexicon
(
'lexicon'
,
''
,
self
.
lexicon
=
PLexicon
(
'lexicon'
,
''
,
Splitter
(),
Splitter
(),
CaseNormalizer
(),
CaseNormalizer
(),
StopWordRemover
())
StopWordRemover
())
caller
=
LexiconHolder
(
self
.
lexicon
)
caller
=
LexiconHolder
(
self
.
lexicon
)
self
.
zc_index
=
ZCTextIndex
(
'name'
,
self
.
zc_index
=
ZCTextIndex
(
'name'
,
None
,
None
,
caller
,
caller
,
self
.
IndexFactory
,
self
.
IndexFactory
,
'text'
,
'text'
,
'lexicon'
)
'lexicon'
)
...
@@ -466,14 +466,14 @@ class QueryTestsBase(testQueryEngine.TestQueryEngine,
...
@@ -466,14 +466,14 @@ class QueryTestsBase(testQueryEngine.TestQueryEngine,
def setUp(self):
def setUp(self):
self.lexicon = PLexicon('lexicon', '',
self.lexicon = PLexicon('lexicon', '',
Splitter(),
Splitter(),
CaseNormalizer(),
CaseNormalizer(),
StopWordRemover())
StopWordRemover())
caller = LexiconHolder(self.lexicon)
caller = LexiconHolder(self.lexicon)
self.zc_index = ZCTextIndex('name',
self.zc_index = ZCTextIndex('name',
None,
None,
caller,
caller,
self.IndexFactory,
self.IndexFactory,
'text',
'text',
'lexicon')
'lexicon')
...
...
lib/python/Products/ZCatalog/Catalog.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
from
Persistence
import
Persistent
from
Persistence
import
Persistent
...
@@ -67,12 +67,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -67,12 +67,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
if
brains
is
not
None
:
if
brains
is
not
None
:
self
.
_v_brains
=
brains
self
.
_v_brains
=
brains
self
.
updateBrains
()
self
.
updateBrains
()
def
clear
(
self
):
def
clear
(
self
):
""" clear catalog """
""" clear catalog """
self
.
data
=
IOBTree
()
# mapping of rid to meta_data
self
.
data
=
IOBTree
()
# mapping of rid to meta_data
self
.
uids
=
OIBTree
()
# mapping of uid to rid
self
.
uids
=
OIBTree
()
# mapping of uid to rid
self
.
paths
=
IOBTree
()
# mapping of rid to uid
self
.
paths
=
IOBTree
()
# mapping of rid to uid
...
@@ -118,7 +118,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -118,7 +118,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
def
__getitem__
(
self
,
index
,
ttype
=
type
(())):
def
__getitem__
(
self
,
index
,
ttype
=
type
(())):
"""
"""
Returns instances of self._v_brains, or whatever is passed
Returns instances of self._v_brains, or whatever is passed
into self.useBrains.
into self.useBrains.
"""
"""
if
type
(
index
)
is
ttype
:
if
type
(
index
)
is
ttype
:
...
@@ -150,7 +150,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -150,7 +150,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
class
mybrains
(
AbstractCatalogBrain
,
brains
):
class
mybrains
(
AbstractCatalogBrain
,
brains
):
pass
pass
scopy
=
self
.
schema
.
copy
()
scopy
=
self
.
schema
.
copy
()
scopy
[
'data_record_id_'
]
=
len
(
self
.
schema
.
keys
())
scopy
[
'data_record_id_'
]
=
len
(
self
.
schema
.
keys
())
...
@@ -166,7 +166,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -166,7 +166,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
"""
"""
adds a row to the meta data schema
adds a row to the meta data schema
"""
"""
schema
=
self
.
schema
schema
=
self
.
schema
names
=
list
(
self
.
names
)
names
=
list
(
self
.
names
)
...
@@ -176,7 +176,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -176,7 +176,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
if
name
[
0
]
==
'_'
:
if
name
[
0
]
==
'_'
:
raise
'Invalid Meta-Data Name'
,
\
raise
'Invalid Meta-Data Name'
,
\
'Cannot cache fields beginning with "_"'
'Cannot cache fields beginning with "_"'
if
not
schema
.
has_key
(
name
):
if
not
schema
.
has_key
(
name
):
if
schema
.
values
():
if
schema
.
values
():
schema
[
name
]
=
max
(
schema
.
values
())
+
1
schema
[
name
]
=
max
(
schema
.
values
())
+
1
...
@@ -197,9 +197,9 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -197,9 +197,9 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# new column? update the brain
# new column? update the brain
self
.
updateBrains
()
self
.
updateBrains
()
self
.
__changed__
(
1
)
#why?
self
.
__changed__
(
1
)
#why?
def
delColumn
(
self
,
name
):
def
delColumn
(
self
,
name
):
"""
"""
deletes a row from the meta data schema
deletes a row from the meta data schema
...
@@ -233,7 +233,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -233,7 +233,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
self
.
data
[
key
]
=
tuple
(
rec
)
self
.
data
[
key
]
=
tuple
(
rec
)
def
addIndex
(
self
,
name
,
index_type
):
def
addIndex
(
self
,
name
,
index_type
):
"""Create a new index, given a name and a index_type.
"""Create a new index, given a name and a index_type.
Old format: index_type was a string, 'FieldIndex' 'TextIndex' or
Old format: index_type was a string, 'FieldIndex' 'TextIndex' or
'KeywordIndex' is no longer valid; the actual index must be instantiated
'KeywordIndex' is no longer valid; the actual index must be instantiated
...
@@ -248,7 +248,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -248,7 +248,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
if
name
.
startswith
(
'_'
):
if
name
.
startswith
(
'_'
):
raise
'Invalid Index Name'
,
'Cannot index fields beginning with "_"'
raise
'Invalid Index Name'
,
'Cannot index fields beginning with "_"'
if
not
name
:
if
not
name
:
raise
'Invalid Index Name'
,
'Name of index is empty'
raise
'Invalid Index Name'
,
'Name of index is empty'
...
@@ -271,15 +271,15 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -271,15 +271,15 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
indexes
=
self
.
indexes
indexes
=
self
.
indexes
del
indexes
[
name
]
del
indexes
[
name
]
self
.
indexes
=
indexes
self
.
indexes
=
indexes
def
getIndex
(
self
,
name
):
def
getIndex
(
self
,
name
):
""" get an index wrapped in the catalog """
""" get an index wrapped in the catalog """
return
self
.
indexes
[
name
].
__of__
(
self
)
return
self
.
indexes
[
name
].
__of__
(
self
)
# the cataloging API
# the cataloging API
def
catalogObject
(
self
,
object
,
uid
,
threshold
=
None
,
idxs
=
[]):
def
catalogObject
(
self
,
object
,
uid
,
threshold
=
None
,
idxs
=
[]):
"""
"""
Adds an object to the Catalog by iteratively applying it
Adds an object to the Catalog by iteratively applying it
all indexes.
all indexes.
...
@@ -288,7 +288,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -288,7 +288,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
'uid' is the unique Catalog identifier for this object
'uid' is the unique Catalog identifier for this object
"""
"""
data
=
self
.
data
data
=
self
.
data
# meta_data is stored as a tuple for efficiency
# meta_data is stored as a tuple for efficiency
...
@@ -297,17 +297,17 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -297,17 +297,17 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
index
=
self
.
uids
.
get
(
uid
,
None
)
index
=
self
.
uids
.
get
(
uid
,
None
)
if
index
is
not
None
:
if
index
is
not
None
:
# old data
# old data
if
data
.
get
(
index
,
0
)
!=
newDataRecord
:
if
data
.
get
(
index
,
0
)
!=
newDataRecord
:
# Update the meta-data, if necessary
# Update the meta-data, if necessary
data
[
index
]
=
newDataRecord
data
[
index
]
=
newDataRecord
else
:
else
:
# new data
# new data
if
type
(
data
)
is
IOBTree
:
if
type
(
data
)
is
IOBTree
:
# New style, get radom id
# New style, get radom id
index
=
getattr
(
self
,
'_v_nextid'
,
0
)
index
=
getattr
(
self
,
'_v_nextid'
,
0
)
if
index
%
4000
==
0
:
index
=
randid
()
if
index
%
4000
==
0
:
index
=
randid
()
while
not
data
.
insert
(
index
,
newDataRecord
):
while
not
data
.
insert
(
index
,
newDataRecord
):
...
@@ -332,10 +332,10 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -332,10 +332,10 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
try
:
self
.
__len__
.
change
(
1
)
try
:
self
.
__len__
.
change
(
1
)
except
AttributeError
:
pass
# No managed length (old-style)
except
AttributeError
:
pass
# No managed length (old-style)
self
.
uids
[
uid
]
=
index
self
.
uids
[
uid
]
=
index
self
.
paths
[
index
]
=
uid
self
.
paths
[
index
]
=
uid
total
=
0
total
=
0
if
idxs
==
[]:
use_indexes
=
self
.
indexes
.
keys
()
if
idxs
==
[]:
use_indexes
=
self
.
indexes
.
keys
()
...
@@ -353,7 +353,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -353,7 +353,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
return
total
return
total
def
uncatalogObject
(
self
,
uid
):
def
uncatalogObject
(
self
,
uid
):
"""
"""
Uncatalog and object from the Catalog. and 'uid' is a unique
Uncatalog and object from the Catalog. and 'uid' is a unique
Catalog identifier
Catalog identifier
...
@@ -384,7 +384,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -384,7 +384,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
LOG
(
'Catalog'
,
ERROR
,
(
'uncatalogObject unsuccessfully '
LOG
(
'Catalog'
,
ERROR
,
(
'uncatalogObject unsuccessfully '
'attempted to uncatalog an object '
'attempted to uncatalog an object '
'with a uid of %s. '
%
uid
))
'with a uid of %s. '
%
uid
))
def
uniqueValuesFor
(
self
,
name
):
def
uniqueValuesFor
(
self
,
name
):
""" return unique values for FieldIndex name """
""" return unique values for FieldIndex name """
...
@@ -422,7 +422,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -422,7 +422,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
for
name
in
self
.
indexes
.
keys
():
for
name
in
self
.
indexes
.
keys
():
result
[
name
]
=
self
.
getIndex
(
name
).
getEntryForObject
(
rid
,
""
)
result
[
name
]
=
self
.
getIndex
(
name
).
getEntryForObject
(
rid
,
""
)
return
result
return
result
## This is the Catalog search engine. Most of the heavy lifting happens below
## This is the Catalog search engine. Most of the heavy lifting happens below
def
_indexedSearch
(
self
,
request
,
sort_index
,
append
,
used
):
def
_indexedSearch
(
self
,
request
,
sort_index
,
append
,
used
):
...
@@ -433,19 +433,19 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -433,19 +433,19 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
data
=
self
.
data
data
=
self
.
data
# Indexes fulfill a fairly large contract here. We hand each
# Indexes fulfill a fairly large contract here. We hand each
# index the request mapping we are given (which may be composed
# index the request mapping we are given (which may be composed
# of some combination of web request, kw mappings or plain old dicts)
# of some combination of web request, kw mappings or plain old dicts)
# and the index decides what to do with it. If the index finds work
# and the index decides what to do with it. If the index finds work
# for itself in the request, it returns the results and a tuple of
# for itself in the request, it returns the results and a tuple of
# the attributes that were used. If the index finds nothing for it
# the attributes that were used. If the index finds nothing for it
# to do then it returns None.
# to do then it returns None.
# For hysterical reasons, if all indexes return None for a given
# For hysterical reasons, if all indexes return None for a given
# request (and no attributes were used) then we append all results
# request (and no attributes were used) then we append all results
# in the Catalog. This generally happens when the search values
# in the Catalog. This generally happens when the search values
# in request are all empty strings or do not coorespond to any of
# in request are all empty strings or do not coorespond to any of
# the indexes.
# the indexes.
# Note that if the indexes find query arguments, but the end result
# Note that if the indexes find query arguments, but the end result
# is an empty sequence, we do nothing
# is an empty sequence, we do nothing
...
@@ -490,13 +490,13 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -490,13 +490,13 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# it, compute the normalized score, and Lazify it.
# it, compute the normalized score, and Lazify it.
rset
=
rs
.
byValue
(
0
)
# sort it by score
rset
=
rs
.
byValue
(
0
)
# sort it by score
max
=
float
(
rset
[
0
][
0
])
max
=
float
(
rset
[
0
][
0
])
# Here we define our getter function inline so that
# Here we define our getter function inline so that
# we can conveniently store the max value as a default arg
# we can conveniently store the max value as a default arg
# and make the normalized score computation lazy
# and make the normalized score computation lazy
def
getScoredResult
(
item
,
max
=
max
,
self
=
self
):
def
getScoredResult
(
item
,
max
=
max
,
self
=
self
):
"""
"""
Returns instances of self._v_brains, or whatever is passed
Returns instances of self._v_brains, or whatever is passed
into self.useBrains.
into self.useBrains.
"""
"""
score
,
key
=
item
score
,
key
=
item
...
@@ -506,14 +506,14 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -506,14 +506,14 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
r
.
data_record_score_
=
score
r
.
data_record_score_
=
score
r
.
data_record_normalized_score_
=
int
(
100.
*
score
/
max
)
r
.
data_record_normalized_score_
=
int
(
100.
*
score
/
max
)
return
r
return
r
# Lazify the results
# Lazify the results
append
(
LazyMap
(
getScoredResult
,
rset
))
append
(
LazyMap
(
getScoredResult
,
rset
))
elif
sort_index
is
None
and
not
hasattr
(
rs
,
'values'
):
elif
sort_index
is
None
and
not
hasattr
(
rs
,
'values'
):
# no scores? Just Lazify.
# no scores? Just Lazify.
if
hasattr
(
rs
,
'keys'
):
if
hasattr
(
rs
,
'keys'
):
rs
=
rs
.
keys
()
rs
=
rs
.
keys
()
append
(
LazyMap
(
self
.
__getitem__
,
rs
))
append
(
LazyMap
(
self
.
__getitem__
,
rs
))
else
:
else
:
# sort. If there are scores, then this block is not
# sort. If there are scores, then this block is not
...
@@ -658,18 +658,18 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -658,18 +658,18 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
class
CatalogError
(
Exception
):
pass
class
CatalogError
(
Exception
):
pass
class
CatalogSearchArgumentsMap
:
class
CatalogSearchArgumentsMap
:
"""Multimap catalog arguments coming simultaneously from keywords
"""Multimap catalog arguments coming simultaneously from keywords
and request.
and request.
Values that are empty strings are treated as non-existent. This is
Values that are empty strings are treated as non-existent. This is
to ignore empty values, thereby ignoring empty form fields to be
to ignore empty values, thereby ignoring empty form fields to be
consistent with hysterical behavior.
consistent with hysterical behavior.
"""
"""
def
__init__
(
self
,
request
,
keywords
):
def
__init__
(
self
,
request
,
keywords
):
self
.
request
=
request
or
{}
self
.
request
=
request
or
{}
self
.
keywords
=
keywords
or
{}
self
.
keywords
=
keywords
or
{}
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
marker
=
[]
marker
=
[]
v
=
self
.
keywords
.
get
(
key
,
marker
)
v
=
self
.
keywords
.
get
(
key
,
marker
)
...
@@ -678,7 +678,7 @@ class CatalogSearchArgumentsMap:
...
@@ -678,7 +678,7 @@ class CatalogSearchArgumentsMap:
if
v
==
''
:
if
v
==
''
:
raise
KeyError
(
key
)
raise
KeyError
(
key
)
return
v
return
v
def
get
(
self
,
key
,
default
=
None
):
def
get
(
self
,
key
,
default
=
None
):
try
:
try
:
v
=
self
[
key
]
v
=
self
[
key
]
...
@@ -686,7 +686,7 @@ class CatalogSearchArgumentsMap:
...
@@ -686,7 +686,7 @@ class CatalogSearchArgumentsMap:
return
default
return
default
else
:
else
:
return
v
return
v
def
has_key
(
self
,
key
):
def
has_key
(
self
,
key
):
try
:
try
:
self
[
key
]
self
[
key
]
...
@@ -694,8 +694,8 @@ class CatalogSearchArgumentsMap:
...
@@ -694,8 +694,8 @@ class CatalogSearchArgumentsMap:
return
0
return
0
else
:
else
:
return
1
return
1
def
mergeResults
(
r
,
has_sort_keys
,
reverse
):
def
mergeResults
(
r
,
has_sort_keys
,
reverse
):
"""Sort/merge sub-results, generating a flat sequence.
"""Sort/merge sub-results, generating a flat sequence.
...
@@ -728,4 +728,3 @@ def mergeResults(r, has_sort_keys, reverse):
...
@@ -728,4 +728,3 @@ def mergeResults(r, has_sort_keys, reverse):
tmp
.
append
(
elt
)
tmp
.
append
(
elt
)
size
+=
len
(
elt
)
size
+=
len
(
elt
)
return
LazyCat
(
tmp
,
size
)
return
LazyCat
(
tmp
,
size
)
lib/python/Products/ZCatalog/CatalogAwareness.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""ZCatalog Findable class
"""ZCatalog Findable class
...
@@ -28,7 +28,7 @@ class CatalogAware:
...
@@ -28,7 +28,7 @@ class CatalogAware:
it is added or copied in Zope. If you make changes to your own
it is added or copied in Zope. If you make changes to your own
object, you are responsible for calling your object's index_object
object, you are responsible for calling your object's index_object
method. """
method. """
meta_type
=
'CatalogAware'
meta_type
=
'CatalogAware'
default_catalog
=
'Catalog'
default_catalog
=
'Catalog'
...
@@ -40,7 +40,7 @@ class CatalogAware:
...
@@ -40,7 +40,7 @@ class CatalogAware:
message
=
"Your changes have been saved"
message
=
"Your changes have been saved"
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
def
manage_afterAdd
(
self
,
item
,
container
):
def
manage_afterAdd
(
self
,
item
,
container
):
self
.
index_object
()
self
.
index_object
()
...
@@ -135,12 +135,3 @@ class CatalogAware:
...
@@ -135,12 +135,3 @@ class CatalogAware:
for
item
in
obj
.
objectValues
():
for
item
in
obj
.
objectValues
():
self
.
reindex_all
(
self
,
item
)
self
.
reindex_all
(
self
,
item
)
return
'done!'
return
'done!'
lib/python/Products/ZCatalog/CatalogBrains.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__version__
=
"$Revision$"
[
11
:
-
2
]
__version__
=
"$Revision$"
[
11
:
-
2
]
...
@@ -28,7 +28,7 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
...
@@ -28,7 +28,7 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
def
getPath
(
self
):
def
getPath
(
self
):
"""Get the physical path for this record"""
"""Get the physical path for this record"""
return
self
.
aq_parent
.
getpath
(
self
.
data_record_id_
)
return
self
.
aq_parent
.
getpath
(
self
.
data_record_id_
)
def
getURL
(
self
):
def
getURL
(
self
):
"""Try to generate a URL for this record"""
"""Try to generate a URL for this record"""
try
:
try
:
...
@@ -49,11 +49,11 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
...
@@ -49,11 +49,11 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
zLOG
.
LOG
(
'CatalogBrains'
,
zLOG
.
INFO
,
'getObject raised an error'
,
zLOG
.
LOG
(
'CatalogBrains'
,
zLOG
.
INFO
,
'getObject raised an error'
,
error
=
sys
.
exc_info
())
error
=
sys
.
exc_info
())
pass
pass
def
getRID
(
self
):
def
getRID
(
self
):
"""Return the record ID for this object."""
"""Return the record ID for this object."""
return
self
.
data_record_id_
return
self
.
data_record_id_
class
NoBrainer
:
class
NoBrainer
:
""" This is an empty class to use when no brain is specified. """
""" This is an empty class to use when no brain is specified. """
pass
pass
lib/python/Products/ZCatalog/CatalogPathAwareness.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""ZCatalog Findable class"""
"""ZCatalog Findable class"""
...
@@ -25,7 +25,7 @@ class CatalogAware:
...
@@ -25,7 +25,7 @@ class CatalogAware:
it is added or copied in Zope. If you make changes to your own
it is added or copied in Zope. If you make changes to your own
object, you are responsible for calling your object's index_object
object, you are responsible for calling your object's index_object
method. """
method. """
meta_type
=
'CatalogAware'
meta_type
=
'CatalogAware'
default_catalog
=
'Catalog'
default_catalog
=
'Catalog'
...
@@ -37,7 +37,7 @@ class CatalogAware:
...
@@ -37,7 +37,7 @@ class CatalogAware:
message
=
"Your changes have been saved"
message
=
"Your changes have been saved"
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
def
manage_afterAdd
(
self
,
item
,
container
):
def
manage_afterAdd
(
self
,
item
,
container
):
self
.
index_object
()
self
.
index_object
()
...
@@ -81,7 +81,7 @@ class CatalogAware:
...
@@ -81,7 +81,7 @@ class CatalogAware:
def
getPath
(
self
):
def
getPath
(
self
):
"""Return the physical path for an object."""
"""Return the physical path for an object."""
return
'/'
.
join
(
self
.
getPhysicalPath
())
return
'/'
.
join
(
self
.
getPhysicalPath
())
def
summary
(
self
,
num
=
200
):
def
summary
(
self
,
num
=
200
):
"""Return a summary of the text content of the object."""
"""Return a summary of the text content of the object."""
if
not
hasattr
(
self
,
'text_content'
):
if
not
hasattr
(
self
,
'text_content'
):
...
@@ -133,11 +133,3 @@ class CatalogPathAware(CatalogAware):
...
@@ -133,11 +133,3 @@ class CatalogPathAware(CatalogAware):
nontrivial, we don't want to spend a lot of time on ZClasses, and
nontrivial, we don't want to spend a lot of time on ZClasses, and
this works.
this works.
"""
"""
lib/python/Products/ZCatalog/IZCatalog.py
View file @
2639fcb7
...
@@ -2,17 +2,17 @@
...
@@ -2,17 +2,17 @@
#
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
"""
"""
$Id: IZCatalog.py,v 1.
2 2002/08/14 19:10:14 caseman
Exp $
$Id: IZCatalog.py,v 1.
3 2002/08/14 22:25:15 mj
Exp $
"""
"""
from
Interface
import
Interface
from
Interface
import
Interface
...
@@ -35,20 +35,20 @@ class IZCatalog(Interface):
...
@@ -35,20 +35,20 @@ class IZCatalog(Interface):
Keyword -- Keyword indexes index sequences of values. The index
Keyword -- Keyword indexes index sequences of values. The index
can be used to search for objects that match one or more of the
can be used to search for objects that match one or more of the
search terms.
search terms.
Path -- Path indexes index URI paths. They allow you to find objects
Path -- Path indexes index URI paths. They allow you to find objects
based on their placement in a hierarchy.
based on their placement in a hierarchy.
Date -- Date indexes index date and type data. They are a type of field
Date -- Date indexes index date and type data. They are a type of field
index specifically optimized for indexing dates.
index specifically optimized for indexing dates.
Date Range -- Date range indexes index time intervals. They are designed
Date Range -- Date range indexes index time intervals. They are designed
for efficient searching of dates falling between two boundaries
for efficient searching of dates falling between two boundaries
(such as effective / expiration dates).
(such as effective / expiration dates).
Topic -- Topic indexes store prefiltered sets of documents. They are used
Topic -- Topic indexes store prefiltered sets of documents. They are used
to optimize complex queries into a single fast query by prefiltering
to optimize complex queries into a single fast query by prefiltering
documents by an expression
documents by an expression
The ZCatalog can maintain a table of extra data about cataloged
The ZCatalog can maintain a table of extra data about cataloged
objects. This information can be used on search result pages to
objects. This information can be used on search result pages to
...
@@ -61,7 +61,7 @@ class IZCatalog(Interface):
...
@@ -61,7 +61,7 @@ class IZCatalog(Interface):
ZCatalog does not store references to the objects themselves, but
ZCatalog does not store references to the objects themselves, but
rather to a unique identifier that defines how to get to the
rather to a unique identifier that defines how to get to the
object. In Zope, this unique identifier is the object's relative
object. In Zope, this unique identifier is the object's relative
path to the ZCatalog (since two Zope objects cannot have the same
path to the ZCatalog (since two Zope objects cannot have the same
URL, this is an excellent unique qualifier in Zope).
URL, this is an excellent unique qualifier in Zope).
"""
"""
...
@@ -108,11 +108,11 @@ class IZCatalog(Interface):
...
@@ -108,11 +108,11 @@ class IZCatalog(Interface):
def
index_objects
():
def
index_objects
():
"""Returns a sequence of actual index objects.
"""Returns a sequence of actual index objects.
NOTE: This returns unwrapped indexes! You should probably use
NOTE: This returns unwrapped indexes! You should probably use
getIndexObjects instead. Some indexes expect to be wrapped.
getIndexObjects instead. Some indexes expect to be wrapped.
"""
"""
def
getIndexObjects
():
def
getIndexObjects
():
"""Returns a list of acquisition wrapped index objects
"""Returns a list of acquisition wrapped index objects
"""
"""
...
@@ -184,7 +184,7 @@ class IZCatalog(Interface):
...
@@ -184,7 +184,7 @@ class IZCatalog(Interface):
documented in The Zope Book.
documented in The Zope Book.
"""
"""
def
__call__
(
REQUEST
=
None
,
**
kw
):
def
__call__
(
REQUEST
=
None
,
**
kw
):
"""Search the catalog, the same way as 'searchResults'.
"""Search the catalog, the same way as 'searchResults'.
"""
"""
...
...
lib/python/Products/ZCatalog/Lazy.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''$Id: Lazy.py,v 1.
6 2001/11/28 15:51:09 matt
Exp $'''
__doc__
=
'''$Id: Lazy.py,v 1.
7 2002/08/14 22:25:15 mj
Exp $'''
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
class
Lazy
:
class
Lazy
:
...
@@ -20,7 +20,7 @@ class Lazy:
...
@@ -20,7 +20,7 @@ class Lazy:
__allow_access_to_unprotected_subobjects__
=
1
__allow_access_to_unprotected_subobjects__
=
1
def
__repr__
(
self
):
return
`list(self)`
def
__repr__
(
self
):
return
`list(self)`
def
__len__
(
self
):
def
__len__
(
self
):
try
:
return
self
.
_len
try
:
return
self
.
_len
...
@@ -62,7 +62,7 @@ class Lazy:
...
@@ -62,7 +62,7 @@ class Lazy:
seq
.
append
(
other
)
seq
.
append
(
other
)
return
LazyCat
(
seq
)
return
LazyCat
(
seq
)
def
__getslice__
(
self
,
i1
,
i2
):
def
__getslice__
(
self
,
i1
,
i2
):
r
=
[]
r
=
[]
for
i
in
xrange
(
i1
,
i2
):
for
i
in
xrange
(
i1
,
i2
):
...
@@ -75,7 +75,7 @@ class Lazy:
...
@@ -75,7 +75,7 @@ class Lazy:
class
LazyCat
(
Lazy
):
class
LazyCat
(
Lazy
):
# Lazy concatenation of one or more sequences. Should be handy
# Lazy concatenation of one or more sequences. Should be handy
# for accessing small parts of big searches.
# for accessing small parts of big searches.
def
__init__
(
self
,
sequences
,
length
=
None
):
def
__init__
(
self
,
sequences
,
length
=
None
):
self
.
_seq
=
sequences
self
.
_seq
=
sequences
self
.
_data
=
[]
self
.
_data
=
[]
...
...
lib/python/Products/ZCatalog/ZCatalog.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""ZCatalog product"""
"""ZCatalog product"""
...
@@ -46,7 +46,7 @@ def manage_addZCatalog(self, id, title,
...
@@ -46,7 +46,7 @@ def manage_addZCatalog(self, id, title,
"""Add a ZCatalog object
"""Add a ZCatalog object
"""
"""
id
=
str
(
id
)
id
=
str
(
id
)
title
=
str
(
title
)
title
=
str
(
title
)
c
=
ZCatalog
(
id
,
title
,
vocab_id
,
self
)
c
=
ZCatalog
(
id
,
title
,
vocab_id
,
self
)
self
.
_setObject
(
id
,
c
)
self
.
_setObject
(
id
,
c
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
...
@@ -59,13 +59,13 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -59,13 +59,13 @@ class ZCatalog(Folder, Persistent, Implicit):
"""ZCatalog object
"""ZCatalog object
A ZCatalog contains arbirary index like references to Zope
A ZCatalog contains arbirary index like references to Zope
objects. ZCatalog's can index either 'Field' values of object, or
objects. ZCatalog's can index either 'Field' values of object, or
'Text' values.
'Text' values.
ZCatalog does not store references to the objects themselves, but
ZCatalog does not store references to the objects themselves, but
rather to a unique identifier that defines how to get to the
rather to a unique identifier that defines how to get to the
object. In Zope, this unique idenfier is the object's relative
object. In Zope, this unique idenfier is the object's relative
path to the ZCatalog (since two Zope object's cannot have the same
path to the ZCatalog (since two Zope object's cannot have the same
URL, this is an excellent unique qualifier in Zope).
URL, this is an excellent unique qualifier in Zope).
Most of the dirty work is done in the _catalog object, which is an
Most of the dirty work is done in the _catalog object, which is an
...
@@ -92,13 +92,13 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -92,13 +92,13 @@ class ZCatalog(Folder, Persistent, Implicit):
'action'
:
'manage_catalogIndexes'
,
'action'
:
'manage_catalogIndexes'
,
'help'
:
(
'ZCatalog'
,
'ZCatalog_Indexes.stx'
)},
'help'
:
(
'ZCatalog'
,
'ZCatalog_Indexes.stx'
)},
{
'label'
:
'Metadata'
,
# TAB: Metadata
{
'label'
:
'Metadata'
,
# TAB: Metadata
'action'
:
'manage_catalogSchema'
,
'action'
:
'manage_catalogSchema'
,
'help'
:(
'ZCatalog'
,
'ZCatalog_MetaData-Table.stx'
)},
'help'
:(
'ZCatalog'
,
'ZCatalog_MetaData-Table.stx'
)},
{
'label'
:
'Find Objects'
,
# TAB: Find Objects
{
'label'
:
'Find Objects'
,
# TAB: Find Objects
'action'
:
'manage_catalogFind'
,
'action'
:
'manage_catalogFind'
,
'help'
:(
'ZCatalog'
,
'ZCatalog_Find-Items-to-ZCatalog.stx'
)},
'help'
:(
'ZCatalog'
,
'ZCatalog_Find-Items-to-ZCatalog.stx'
)},
{
'label'
:
'Advanced'
,
# TAB: Advanced
{
'label'
:
'Advanced'
,
# TAB: Advanced
'action'
:
'manage_catalogAdvanced'
,
'action'
:
'manage_catalogAdvanced'
,
'help'
:(
'ZCatalog'
,
'ZCatalog_Advanced.stx'
)},
'help'
:(
'ZCatalog'
,
'ZCatalog_Advanced.stx'
)},
{
'label'
:
'Undo'
,
# TAB: Undo
{
'label'
:
'Undo'
,
# TAB: Undo
'action'
:
'manage_UndoForm'
,
'action'
:
'manage_UndoForm'
,
...
@@ -116,19 +116,19 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -116,19 +116,19 @@ class ZCatalog(Folder, Persistent, Implicit):
(
'Manage ZCatalog Entries'
,
(
'Manage ZCatalog Entries'
,
[
'manage_catalogObject'
,
'manage_uncatalogObject'
,
[
'manage_catalogObject'
,
'manage_uncatalogObject'
,
'catalog_object'
,
'uncatalog_object'
,
'refreshCatalog'
,
'catalog_object'
,
'uncatalog_object'
,
'refreshCatalog'
,
'manage_catalogView'
,
'manage_catalogFind'
,
'manage_catalogView'
,
'manage_catalogFind'
,
'manage_catalogSchema'
,
'manage_catalogIndexes'
,
'manage_catalogSchema'
,
'manage_catalogIndexes'
,
'manage_catalogAdvanced'
,
'manage_objectInformation'
,
'manage_catalogAdvanced'
,
'manage_objectInformation'
,
'manage_catalogReindex'
,
'manage_catalogFoundItems'
,
'manage_catalogReindex'
,
'manage_catalogFoundItems'
,
'manage_catalogClear'
,
'manage_addColumn'
,
'manage_delColumn'
,
'manage_catalogClear'
,
'manage_addColumn'
,
'manage_delColumn'
,
'manage_addIndex'
,
'manage_delIndex'
,
'manage_clearIndex'
,
'manage_addIndex'
,
'manage_delIndex'
,
'manage_clearIndex'
,
'manage_reindexIndex'
,
'manage_main'
,
'availableSplitters'
,
'manage_reindexIndex'
,
'manage_main'
,
'availableSplitters'
,
# these two are deprecated:
# these two are deprecated:
'manage_delColumns'
,
'manage_deleteIndex'
'manage_delColumns'
,
'manage_deleteIndex'
],
],
[
'Manager'
]),
[
'Manager'
]),
(
'Search ZCatalog'
,
(
'Search ZCatalog'
,
...
@@ -136,7 +136,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -136,7 +136,7 @@ class ZCatalog(Folder, Persistent, Implicit):
'getpath'
,
'schema'
,
'indexes'
,
'index_objects'
,
'getIndexObjects'
'getpath'
,
'schema'
,
'indexes'
,
'index_objects'
,
'getIndexObjects'
'all_meta_types'
,
'valid_roles'
,
'resolve_url'
,
'all_meta_types'
,
'valid_roles'
,
'resolve_url'
,
'getobject'
],
'getobject'
],
[
'Anonymous'
,
'Manager'
]),
[
'Anonymous'
,
'Manager'
]),
)
)
...
@@ -154,21 +154,21 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -154,21 +154,21 @@ class ZCatalog(Folder, Persistent, Implicit):
threshold
=
10000
threshold
=
10000
_v_total
=
0
_v_total
=
0
_v_transaction
=
None
_v_transaction
=
None
def
__init__
(
self
,
id
,
title
=
''
,
vocab_id
=
None
,
container
=
None
):
def
__init__
(
self
,
id
,
title
=
''
,
vocab_id
=
None
,
container
=
None
):
# ZCatalog no longer cares about vocabularies
# ZCatalog no longer cares about vocabularies
# so the vocab_id argument is ignored (Casey)
# so the vocab_id argument is ignored (Casey)
if
container
is
not
None
:
if
container
is
not
None
:
self
=
self
.
__of__
(
container
)
self
=
self
.
__of__
(
container
)
self
.
id
=
id
self
.
id
=
id
self
.
title
=
title
self
.
title
=
title
# vocabulary and vocab_id are left for backwards
# vocabulary and vocab_id are left for backwards
# compatibility only, they are not used anymore
# compatibility only, they are not used anymore
self
.
vocabulary
=
None
self
.
vocabulary
=
None
self
.
vocab_id
=
''
self
.
vocab_id
=
''
self
.
threshold
=
10000
self
.
threshold
=
10000
self
.
_v_total
=
0
self
.
_v_total
=
0
...
@@ -176,8 +176,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -176,8 +176,8 @@ class ZCatalog(Folder, Persistent, Implicit):
def
__len__
(
self
):
def
__len__
(
self
):
return
len
(
self
.
_catalog
)
return
len
(
self
.
_catalog
)
# getVocabulary method is no longer supported
# getVocabulary method is no longer supported
# def getVocabulary(self):
# def getVocabulary(self):
# """ more ack! """
# """ more ack! """
...
@@ -200,7 +200,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -200,7 +200,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self
.
threshold
=
None
self
.
threshold
=
None
else
:
else
:
self
.
threshold
=
10000
self
.
threshold
=
10000
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
'/manage_catalogAdvanced?manage_tabs_message=Catalog%20Changed'
)
'/manage_catalogAdvanced?manage_tabs_message=Catalog%20Changed'
)
...
@@ -210,12 +210,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -210,12 +210,12 @@ class ZCatalog(Folder, Persistent, Implicit):
if
urls
:
if
urls
:
if
isinstance
(
urls
,
types
.
StringType
):
if
isinstance
(
urls
,
types
.
StringType
):
urls
=
(
urls
,)
urls
=
(
urls
,)
for
url
in
urls
:
for
url
in
urls
:
obj
=
self
.
resolve_path
(
url
)
obj
=
self
.
resolve_path
(
url
)
if
not
obj
:
if
not
obj
:
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
if
obj
is
not
None
:
if
obj
is
not
None
:
self
.
catalog_object
(
obj
,
url
)
self
.
catalog_object
(
obj
,
url
)
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
...
@@ -248,14 +248,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -248,14 +248,14 @@ class ZCatalog(Folder, Persistent, Implicit):
elapse
=
time
.
time
()
-
elapse
elapse
=
time
.
time
()
-
elapse
c_elapse
=
time
.
clock
()
-
c_elapse
c_elapse
=
time
.
clock
()
-
c_elapse
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
'/manage_catalogAdvanced?manage_tabs_message='
+
'/manage_catalogAdvanced?manage_tabs_message='
+
urllib
.
quote
(
'Catalog Updated
\
n
'
urllib
.
quote
(
'Catalog Updated
\
n
'
'Total time: %s
\
n
'
'Total time: %s
\
n
'
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
def
refreshCatalog
(
self
,
clear
=
0
):
def
refreshCatalog
(
self
,
clear
=
0
):
""" re-index everything we can find """
""" re-index everything we can find """
...
@@ -289,18 +289,18 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -289,18 +289,18 @@ class ZCatalog(Folder, Persistent, Implicit):
obj_expr
=
None
,
obj_mtime
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
obj_roles
=
None
,
obj_mspec
=
None
,
obj_roles
=
None
,
obj_permission
=
None
):
obj_permission
=
None
):
""" Find object according to search criteria and Catalog them
""" Find object according to search criteria and Catalog them
"""
"""
elapse
=
time
.
time
()
elapse
=
time
.
time
()
c_elapse
=
time
.
clock
()
c_elapse
=
time
.
clock
()
words
=
0
words
=
0
obj
=
REQUEST
.
PARENTS
[
1
]
obj
=
REQUEST
.
PARENTS
[
1
]
path
=
'/'
.
join
(
obj
.
getPhysicalPath
())
path
=
'/'
.
join
(
obj
.
getPhysicalPath
())
results
=
self
.
ZopeFindAndApply
(
obj
,
results
=
self
.
ZopeFindAndApply
(
obj
,
obj_metatypes
=
obj_metatypes
,
obj_metatypes
=
obj_metatypes
,
obj_ids
=
obj_ids
,
obj_ids
=
obj_ids
,
...
@@ -317,16 +317,16 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -317,16 +317,16 @@ class ZCatalog(Folder, Persistent, Implicit):
elapse
=
time
.
time
()
-
elapse
elapse
=
time
.
time
()
-
elapse
c_elapse
=
time
.
clock
()
-
c_elapse
c_elapse
=
time
.
clock
()
-
c_elapse
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
'/manage_catalogView?manage_tabs_message='
+
'/manage_catalogView?manage_tabs_message='
+
urllib
.
quote
(
'Catalog Updated
\
n
'
urllib
.
quote
(
'Catalog Updated
\
n
'
'Total time: %s
\
n
'
'Total time: %s
\
n
'
'Total CPU time: %s'
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
))
%
(
`elapse`
,
`c_elapse`
))
)
)
def
manage_addColumn
(
self
,
name
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_addColumn
(
self
,
name
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
""" add a column """
""" add a column """
...
@@ -351,7 +351,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -351,7 +351,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"
\
n
"
"
\
n
"
"Please use instead the manage_delColumn method.
\
n
"
"Please use instead the manage_delColumn method.
\
n
"
,
DeprecationWarning
)
,
DeprecationWarning
)
self
.
manage_delColumn
(
names
,
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
self
.
manage_delColumn
(
names
,
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
URL1
=
URL1
)
...
@@ -360,7 +360,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -360,7 +360,7 @@ class ZCatalog(Folder, Persistent, Implicit):
""" delete a column or some columns """
""" delete a column or some columns """
if
isinstance
(
names
,
types
.
StringType
):
if
isinstance
(
names
,
types
.
StringType
):
names
=
(
names
,)
names
=
(
names
,)
for
name
in
names
:
for
name
in
names
:
self
.
delColumn
(
name
)
self
.
delColumn
(
name
)
...
@@ -379,7 +379,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -379,7 +379,7 @@ class ZCatalog(Folder, Persistent, Implicit):
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
'/manage_catalogIndexes?manage_tabs_message=Index%20Added'
)
'/manage_catalogIndexes?manage_tabs_message=Index%20Added'
)
def
manage_deleteIndex
(
self
,
ids
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
def
manage_deleteIndex
(
self
,
ids
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
URL1
=
None
):
...
@@ -395,7 +395,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -395,7 +395,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"
\
n
"
"
\
n
"
"Please use instead the manage_delIndex method.
\
n
"
"Please use instead the manage_delIndex method.
\
n
"
,
DeprecationWarning
)
,
DeprecationWarning
)
self
.
manage_delIndex
(
ids
=
ids
,
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
self
.
manage_delIndex
(
ids
=
ids
,
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
URL1
=
URL1
)
...
@@ -413,7 +413,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -413,7 +413,7 @@ class ZCatalog(Folder, Persistent, Implicit):
for
name
in
ids
:
for
name
in
ids
:
self
.
delIndex
(
name
)
self
.
delIndex
(
name
)
if
REQUEST
and
RESPONSE
:
if
REQUEST
and
RESPONSE
:
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
...
@@ -433,7 +433,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -433,7 +433,7 @@ class ZCatalog(Folder, Persistent, Implicit):
for
name
in
ids
:
for
name
in
ids
:
self
.
clearIndex
(
name
)
self
.
clearIndex
(
name
)
if
REQUEST
and
RESPONSE
:
if
REQUEST
and
RESPONSE
:
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
URL1
+
...
@@ -441,7 +441,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -441,7 +441,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
reindexIndex
(
self
,
name
,
REQUEST
):
def
reindexIndex
(
self
,
name
,
REQUEST
):
paths
=
tuple
(
self
.
_catalog
.
paths
.
values
())
paths
=
tuple
(
self
.
_catalog
.
paths
.
values
())
for
p
in
paths
:
for
p
in
paths
:
...
@@ -449,7 +449,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -449,7 +449,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
not
obj
:
if
not
obj
:
obj
=
self
.
resolve_url
(
p
,
REQUEST
)
obj
=
self
.
resolve_url
(
p
,
REQUEST
)
if
obj
is
not
None
:
if
obj
is
not
None
:
self
.
catalog_object
(
obj
,
p
,
idxs
=
[
name
])
self
.
catalog_object
(
obj
,
p
,
idxs
=
[
name
])
def
manage_reindexIndex
(
self
,
ids
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
def
manage_reindexIndex
(
self
,
ids
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
...
@@ -459,7 +459,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -459,7 +459,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
MessageDialog
(
title
=
'No items specified'
,
return
MessageDialog
(
title
=
'No items specified'
,
message
=
'No items were specified!'
,
message
=
'No items were specified!'
,
action
=
"./manage_catalogIndexes"
,)
action
=
"./manage_catalogIndexes"
,)
if
isinstance
(
ids
,
types
.
StringType
):
if
isinstance
(
ids
,
types
.
StringType
):
ids
=
(
ids
,)
ids
=
(
ids
,)
...
@@ -498,7 +498,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -498,7 +498,7 @@ class ZCatalog(Folder, Persistent, Implicit):
# indexing code. We throw away the result of the call to
# indexing code. We throw away the result of the call to
# catalogObject (which is a word count), because it's
# catalogObject (which is a word count), because it's
# worthless to us here.
# worthless to us here.
if
self
.
threshold
is
not
None
:
if
self
.
threshold
is
not
None
:
# figure out whether or not to commit a subtransaction.
# figure out whether or not to commit a subtransaction.
t
=
id
(
get_transaction
())
t
=
id
(
get_transaction
())
...
@@ -555,7 +555,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -555,7 +555,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
getIndexDataForRID
(
self
,
rid
):
def
getIndexDataForRID
(
self
,
rid
):
"""return the current index contents for the specific rid"""
"""return the current index contents for the specific rid"""
return
self
.
_catalog
.
getIndexDataForRID
(
rid
)
return
self
.
_catalog
.
getIndexDataForRID
(
rid
)
def
schema
(
self
):
def
schema
(
self
):
return
self
.
_catalog
.
schema
.
keys
()
return
self
.
_catalog
.
schema
.
keys
()
...
@@ -566,7 +566,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -566,7 +566,7 @@ class ZCatalog(Folder, Persistent, Implicit):
# This method returns unwrapped indexes!
# This method returns unwrapped indexes!
# You should probably use getIndexObjects instead
# You should probably use getIndexObjects instead
return
self
.
_catalog
.
indexes
.
values
()
return
self
.
_catalog
.
indexes
.
values
()
def
getIndexObjects
(
self
):
def
getIndexObjects
(
self
):
# Return a list of wrapped(!) indexes
# Return a list of wrapped(!) indexes
catalog
=
self
.
_catalog
catalog
=
self
.
_catalog
...
@@ -596,9 +596,9 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -596,9 +596,9 @@ class ZCatalog(Folder, Persistent, Implicit):
def
searchResults
(
self
,
REQUEST
=
None
,
used
=
None
,
**
kw
):
def
searchResults
(
self
,
REQUEST
=
None
,
used
=
None
,
**
kw
):
"""Search the catalog according to the ZTables search interface.
"""Search the catalog according to the ZTables search interface.
Search terms can be passed in the REQUEST or as keyword
Search terms can be passed in the REQUEST or as keyword
arguments.
arguments.
"""
"""
return
self
.
_catalog
.
searchResults
(
REQUEST
,
used
,
**
kw
)
return
self
.
_catalog
.
searchResults
(
REQUEST
,
used
,
**
kw
)
...
@@ -608,7 +608,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -608,7 +608,7 @@ class ZCatalog(Folder, Persistent, Implicit):
## this stuff is so the find machinery works
## this stuff is so the find machinery works
meta_types
=
()
# Sub-object types that are specific to this object
meta_types
=
()
# Sub-object types that are specific to this object
# Dont need this anymore -- we inherit from object manager
# Dont need this anymore -- we inherit from object manager
#def all_meta_types(self):
#def all_meta_types(self):
# pmt=()
# pmt=()
...
@@ -649,7 +649,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -649,7 +649,7 @@ class ZCatalog(Folder, Persistent, Implicit):
This is a *great* hack. Zope find just doesn't do what we
This is a *great* hack. Zope find just doesn't do what we
need here; the ability to apply a method to all the objects
need here; the ability to apply a method to all the objects
*as they're found* and the need to pass the object's path into
*as they're found* and the need to pass the object's path into
that method.
that method.
"""
"""
...
@@ -659,7 +659,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -659,7 +659,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
obj_metatypes
and
'all'
in
obj_metatypes
:
if
obj_metatypes
and
'all'
in
obj_metatypes
:
obj_metatypes
=
None
obj_metatypes
=
None
if
obj_mtime
and
type
(
obj_mtime
)
==
type
(
's'
):
if
obj_mtime
and
type
(
obj_mtime
)
==
type
(
's'
):
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
...
@@ -668,7 +668,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -668,7 +668,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
obj_roles
and
type
(
obj_roles
)
is
type
(
's'
):
if
obj_roles
and
type
(
obj_roles
)
is
type
(
's'
):
obj_roles
=
[
obj_roles
]
obj_roles
=
[
obj_roles
]
if
obj_expr
:
if
obj_expr
:
# Setup expr machinations
# Setup expr machinations
md
=
td
()
md
=
td
()
...
@@ -690,7 +690,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -690,7 +690,7 @@ class ZCatalog(Folder, Persistent, Implicit):
for
id
,
ob
in
items
:
for
id
,
ob
in
items
:
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
else
:
p
=
id
dflag
=
0
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
dflag
=
1
dflag
=
1
...
@@ -723,7 +723,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -723,7 +723,7 @@ class ZCatalog(Folder, Persistent, Implicit):
else
:
else
:
add_result
((
p
,
ob
))
add_result
((
p
,
ob
))
dflag
=
0
dflag
=
0
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
obj_searchterm
,
obj_expr
,
obj_searchterm
,
obj_expr
,
...
@@ -737,7 +737,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -737,7 +737,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
result
return
result
def
resolve_url
(
self
,
path
,
REQUEST
):
def
resolve_url
(
self
,
path
,
REQUEST
):
"""
"""
Attempt to resolve a url into an object in the Zope
Attempt to resolve a url into an object in the Zope
namespace. The url may be absolute or a catalog path
namespace. The url may be absolute or a catalog path
style url. If no object is found, None is returned.
style url. If no object is found, None is returned.
...
@@ -745,12 +745,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -745,12 +745,12 @@ class ZCatalog(Folder, Persistent, Implicit):
"""
"""
script
=
REQUEST
.
script
script
=
REQUEST
.
script
if
path
.
find
(
script
)
!=
0
:
if
path
.
find
(
script
)
!=
0
:
path
=
'%s/%s'
%
(
script
,
path
)
path
=
'%s/%s'
%
(
script
,
path
)
try
:
return
REQUEST
.
resolve_url
(
path
)
try
:
return
REQUEST
.
resolve_url
(
path
)
except
:
pass
except
:
pass
def
resolve_path
(
self
,
path
):
def
resolve_path
(
self
,
path
):
"""
"""
Attempt to resolve a url into an object in the Zope
Attempt to resolve a url into an object in the Zope
namespace. The url may be absolute or a catalog path
namespace. The url may be absolute or a catalog path
style url. If no object is found, None is returned.
style url. If no object is found, None is returned.
...
@@ -813,7 +813,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -813,7 +813,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
manage_convertIndex
(
self
,
ids
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_convertIndex
(
self
,
ids
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
"""convert old-style indexes to new-style indexes"""
"""convert old-style indexes to new-style indexes"""
from
Products.PluginIndexes.KeywordIndex
import
KeywordIndex
from
Products.PluginIndexes.KeywordIndex
import
KeywordIndex
from
Products.PluginIndexes.FieldIndex
import
FieldIndex
from
Products.PluginIndexes.FieldIndex
import
FieldIndex
from
Products.PluginIndexes.TextIndex
import
TextIndex
from
Products.PluginIndexes.TextIndex
import
TextIndex
...
@@ -845,10 +845,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -845,10 +845,10 @@ class ZCatalog(Folder, Persistent, Implicit):
'/manage_main?'
'/manage_main?'
'manage_tabs_message='
'manage_tabs_message='
'No%20indexes%20found%20to%20be%20converted'
)
'No%20indexes%20found%20to%20be%20converted'
)
#
#
# Indexing methods
# Indexing methods
#
#
def
addIndex
(
self
,
name
,
type
,
extra
=
None
):
def
addIndex
(
self
,
name
,
type
,
extra
=
None
):
...
@@ -861,7 +861,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -861,7 +861,7 @@ class ZCatalog(Folder, Persistent, Implicit):
p
=
None
p
=
None
for
prod
in
products
:
for
prod
in
products
:
if
prod
[
'name'
]
==
type
:
if
prod
[
'name'
]
==
type
:
p
=
prod
p
=
prod
break
break
...
@@ -882,7 +882,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -882,7 +882,7 @@ class ZCatalog(Folder, Persistent, Implicit):
index
=
apply
(
base
,(
name
,),
{
"extra"
:
extra
,
"caller"
:
self
})
index
=
apply
(
base
,(
name
,),
{
"extra"
:
extra
,
"caller"
:
self
})
else
:
else
:
index
=
base
(
name
,
self
)
index
=
base
(
name
,
self
)
self
.
_catalog
.
addIndex
(
name
,
index
)
self
.
_catalog
.
addIndex
(
name
,
index
)
...
@@ -899,7 +899,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -899,7 +899,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
delColumn
(
self
,
name
):
def
delColumn
(
self
,
name
):
return
self
.
_catalog
.
delColumn
(
name
)
return
self
.
_catalog
.
delColumn
(
name
)
Globals
.
default__class_init__
(
ZCatalog
)
Globals
.
default__class_init__
(
ZCatalog
)
...
@@ -924,13 +924,13 @@ def expr_match(ob, ed, c=InstanceDict, r=0):
...
@@ -924,13 +924,13 @@ def expr_match(ob, ed, c=InstanceDict, r=0):
def
mtime_match
(
ob
,
t
,
q
,
fn
=
hasattr
):
def
mtime_match
(
ob
,
t
,
q
,
fn
=
hasattr
):
if
not
fn
(
ob
,
'_p_mtime'
):
if
not
fn
(
ob
,
'_p_mtime'
):
return
0
return
0
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
def
role_match
(
ob
,
permission
,
roles
,
lt
=
type
([]),
tt
=
type
(())):
def
role_match
(
ob
,
permission
,
roles
,
lt
=
type
([]),
tt
=
type
(())):
pr
=
[]
pr
=
[]
fn
=
pr
.
append
fn
=
pr
.
append
while
1
:
while
1
:
if
hasattr
(
ob
,
permission
):
if
hasattr
(
ob
,
permission
):
p
=
getattr
(
ob
,
permission
)
p
=
getattr
(
ob
,
permission
)
...
...
lib/python/Products/ZCatalog/ZCatalogIndexes.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""$Id: ZCatalogIndexes.py,v 1.
7 2002/06/28 17:25:23 caseman
Exp $
"""$Id: ZCatalogIndexes.py,v 1.
8 2002/08/14 22:25:15 mj
Exp $
"""
"""
from
Globals
import
DTMLFile
,
InitializeClass
from
Globals
import
DTMLFile
,
InitializeClass
...
@@ -42,19 +42,19 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
...
@@ -42,19 +42,19 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
meta_type
=
"ZCatalogIndex"
meta_type
=
"ZCatalogIndex"
manage_options
=
()
manage_options
=
()
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
manage_zcatalog_indexes
)
security
.
declareObjectProtected
(
manage_zcatalog_indexes
)
security
.
setPermissionDefault
(
manage_zcatalog_indexes
,
(
'Manager'
,))
security
.
setPermissionDefault
(
manage_zcatalog_indexes
,
(
'Manager'
,))
security
.
declareProtected
(
manage_zcatalog_indexes
,
'addIndexForm'
)
security
.
declareProtected
(
manage_zcatalog_indexes
,
'addIndexForm'
)
addIndexForm
=
DTMLFile
(
'dtml/addIndexForm'
,
globals
())
addIndexForm
=
DTMLFile
(
'dtml/addIndexForm'
,
globals
())
# You no longer manage the Indexes here, they are managed from ZCatalog
# You no longer manage the Indexes here, they are managed from ZCatalog
def
manage_main
(
self
,
REQUEST
,
RESPONSE
):
def
manage_main
(
self
,
REQUEST
,
RESPONSE
):
"""Redirect to the parent where the management screen now lives"""
"""Redirect to the parent where the management screen now lives"""
RESPONSE
.
redirect
(
'../manage_catalogIndexes'
)
RESPONSE
.
redirect
(
'../manage_catalogIndexes'
)
manage_workspace
=
manage_main
manage_workspace
=
manage_main
#
#
...
@@ -62,7 +62,7 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
...
@@ -62,7 +62,7 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
#
#
# base accessors loop back through our dictionary interface
# base accessors loop back through our dictionary interface
def
_setOb
(
self
,
id
,
object
):
def
_setOb
(
self
,
id
,
object
):
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
indexes
[
id
]
=
object
indexes
[
id
]
=
object
self
.
aq_parent
.
_indexes
=
indexes
self
.
aq_parent
.
_indexes
=
indexes
...
@@ -74,14 +74,14 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
...
@@ -74,14 +74,14 @@ class ZCatalogIndexes (IFAwareObjectManager, Folder, Persistent, Implicit):
self
.
aq_parent
.
_indexes
=
indexes
self
.
aq_parent
.
_indexes
=
indexes
#self.aq_parent._p_changed = 1
#self.aq_parent._p_changed = 1
def
_getOb
(
self
,
id
,
default
=
_marker
):
def
_getOb
(
self
,
id
,
default
=
_marker
):
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
if
default
is
_marker
:
return
indexes
.
get
(
id
)
if
default
is
_marker
:
return
indexes
.
get
(
id
)
return
indexes
.
get
(
id
,
default
)
return
indexes
.
get
(
id
,
default
)
security
.
declareProtected
(
manage_zcatalog_indexes
,
'objectIds'
)
security
.
declareProtected
(
manage_zcatalog_indexes
,
'objectIds'
)
def
objectIds
(
self
,
spec
=
None
):
def
objectIds
(
self
,
spec
=
None
):
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
indexes
=
self
.
aq_parent
.
_catalog
.
indexes
if
spec
is
not
None
:
if
spec
is
not
None
:
if
type
(
spec
)
==
type
(
's'
):
if
type
(
spec
)
==
type
(
's'
):
...
@@ -121,15 +121,13 @@ InitializeClass(ZCatalogIndexes)
...
@@ -121,15 +121,13 @@ InitializeClass(ZCatalogIndexes)
class
OldCatalogWrapperObject
(
SimpleItem
,
Implicit
):
class
OldCatalogWrapperObject
(
SimpleItem
,
Implicit
):
manage_options
=
(
manage_options
=
(
{
'label'
:
'Settings'
,
{
'label'
:
'Settings'
,
'action'
:
'manage_main'
},
'action'
:
'manage_main'
},
)
)
manage_main
=
DTMLFile
(
'dtml/manageOldindex'
,
globals
())
manage_main
=
DTMLFile
(
'dtml/manageOldindex'
,
globals
())
manage_main
.
_setName
(
'manage_main'
)
manage_main
.
_setName
(
'manage_main'
)
manage_workspace
=
manage_main
manage_workspace
=
manage_main
def
__init__
(
self
,
o
):
def
__init__
(
self
,
o
):
self
.
index
=
o
self
.
index
=
o
lib/python/Products/ZCatalog/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""ZCatalog product"""
"""ZCatalog product"""
...
@@ -26,7 +26,7 @@ createZClassForBase( CatalogPathAwareness.CatalogPathAware, globals()
...
@@ -26,7 +26,7 @@ createZClassForBase( CatalogPathAwareness.CatalogPathAware, globals()
def
initialize
(
context
):
def
initialize
(
context
):
context
.
registerClass
(
context
.
registerClass
(
ZCatalog
.
ZCatalog
,
ZCatalog
.
ZCatalog
,
permission
=
'Add ZCatalogs'
,
permission
=
'Add ZCatalogs'
,
constructors
=
(
ZCatalog
.
manage_addZCatalogForm
,
constructors
=
(
ZCatalog
.
manage_addZCatalogForm
,
ZCatalog
.
manage_addZCatalog
),
ZCatalog
.
manage_addZCatalog
),
...
@@ -40,7 +40,6 @@ def initialize(context):
...
@@ -40,7 +40,6 @@ def initialize(context):
Vocabulary
.
manage_addVocabulary
),
Vocabulary
.
manage_addVocabulary
),
icon
=
'www/Vocabulary.gif'
,
icon
=
'www/Vocabulary.gif'
,
)
)
context
.
registerHelp
()
context
.
registerHelp
()
context
.
registerHelpTitle
(
'Zope Help'
)
context
.
registerHelpTitle
(
'Zope Help'
)
lib/python/Products/ZCatalog/help/Vocabulary.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
def
manage_addVocabulary
(
id
,
title
,
globbing
=
None
,
REQUEST
=
None
):
def
manage_addVocabulary
(
id
,
title
,
globbing
=
None
,
REQUEST
=
None
):
"""
"""
Add a Vocabulary object to an ObjectManager.
Add a Vocabulary object to an ObjectManager.
"""
"""
...
@@ -28,7 +28,7 @@ class Vocabulary:
...
@@ -28,7 +28,7 @@ class Vocabulary:
A Vocabulary manages words and language rules for text indexing.
A Vocabulary manages words and language rules for text indexing.
Text indexing is done by the ZCatalog and other third party
Text indexing is done by the ZCatalog and other third party
Products.
Products.
"""
"""
__constructor__
=
manage_addVocabulary
__constructor__
=
manage_addVocabulary
...
@@ -39,7 +39,7 @@ class Vocabulary:
...
@@ -39,7 +39,7 @@ class Vocabulary:
Query Vocabulary for words matching pattern.
Query Vocabulary for words matching pattern.
"""
"""
def
insert
(
word
):
def
insert
(
word
):
"""
"""
...
@@ -47,12 +47,10 @@ class Vocabulary:
...
@@ -47,12 +47,10 @@ class Vocabulary:
Insert a word in the Vocabulary.
Insert a word in the Vocabulary.
"""
"""
def
words
():
def
words
():
"""
"""
Return list of words.
Return list of words.
"""
"""
lib/python/Products/ZCatalog/help/ZCatalog.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
def
manage_addZCatalog
(
id
,
title
,
vocab_id
=
None
):
def
manage_addZCatalog
(
id
,
title
,
vocab_id
=
None
):
...
@@ -43,20 +43,20 @@ class ZCatalog:
...
@@ -43,20 +43,20 @@ class ZCatalog:
Keyword -- Keyword indexes index sequences of values. The index
Keyword -- Keyword indexes index sequences of values. The index
can be used to search for objects that match one or more of the
can be used to search for objects that match one or more of the
search terms.
search terms.
Path -- Path indexes index URI paths. They allow you to find objects
Path -- Path indexes index URI paths. They allow you to find objects
based on their placement in a hierarchy.
based on their placement in a hierarchy.
Date -- Date indexes index date and type data. They are a type of field
Date -- Date indexes index date and type data. They are a type of field
index specifically optimized for indexing dates.
index specifically optimized for indexing dates.
Date Range -- Date range indexes index time intervals. They are designed
Date Range -- Date range indexes index time intervals. They are designed
for efficient searching of dates falling between two boundaries
for efficient searching of dates falling between two boundaries
(such as effective / expiration dates).
(such as effective / expiration dates).
Topic -- Topic indexes store prefiltered sets of documents. They are used
Topic -- Topic indexes store prefiltered sets of documents. They are used
to optimize complex queries into a single fast query by prefiltering
to optimize complex queries into a single fast query by prefiltering
documents by an expression
documents by an expression
The ZCatalog can maintain a table of extra data about cataloged
The ZCatalog can maintain a table of extra data about cataloged
objects. This information can be used on search result pages to
objects. This information can be used on search result pages to
...
@@ -69,7 +69,7 @@ class ZCatalog:
...
@@ -69,7 +69,7 @@ class ZCatalog:
ZCatalog does not store references to the objects themselves, but
ZCatalog does not store references to the objects themselves, but
rather to a unique identifier that defines how to get to the
rather to a unique identifier that defines how to get to the
object. In Zope, this unique identifier is the object's relative
object. In Zope, this unique identifier is the object's relative
path to the ZCatalog (since two Zope objects cannot have the same
path to the ZCatalog (since two Zope objects cannot have the same
URL, this is an excellent unique qualifier in Zope).
URL, this is an excellent unique qualifier in Zope).
"""
"""
...
@@ -99,18 +99,18 @@ class ZCatalog:
...
@@ -99,18 +99,18 @@ class ZCatalog:
def
getpath
(
rid
):
def
getpath
(
rid
):
"""
"""
Return the path to a cataloged object given a
Return the path to a cataloged object given a
'data_record_id_'
'data_record_id_'
"""
"""
def
getobject
(
rid
,
REQUEST
=
None
):
def
getobject
(
rid
,
REQUEST
=
None
):
"""
"""
Return a cataloged object given a 'data_record_id_'
Return a cataloged object given a 'data_record_id_'
"""
"""
def
schema
():
def
schema
():
...
@@ -123,24 +123,24 @@ class ZCatalog:
...
@@ -123,24 +123,24 @@ class ZCatalog:
def
index_objects
():
def
index_objects
():
"""
"""
Returns a sequence of actual index objects.
Returns a sequence of actual index objects.
NOTE: This returns unwrapped indexes! You should probably use
NOTE: This returns unwrapped indexes! You should probably use
getIndexObjects instead. Some indexes expect to be wrapped.
getIndexObjects instead. Some indexes expect to be wrapped.
"""
"""
def
getIndexObjects
():
def
getIndexObjects
():
"""
"""
Returns a list of acquisition wrapped index objects
Returns a list of acquisition wrapped index objects
"""
"""
def
searchResults
(
REQUEST
=
None
,
**
kw
):
def
searchResults
(
REQUEST
=
None
,
**
kw
):
"""
"""
Search the catalog. Search terms can be passed in the REQUEST
Search the catalog. Search terms can be passed in the REQUEST
or as keyword arguments.
or as keyword arguments.
...
@@ -206,9 +206,8 @@ class ZCatalog:
...
@@ -206,9 +206,8 @@ class ZCatalog:
documented in The Zope Book.
documented in The Zope Book.
"""
"""
def
__call__
(
REQUEST
=
None
,
**
kw
):
def
__call__
(
REQUEST
=
None
,
**
kw
):
"""
"""
Search the catalog, the same way as 'searchResults'.
Search the catalog, the same way as 'searchResults'.
"""
"""
lib/python/Products/ZCatalog/regressiontests/keywords.py
View file @
2639fcb7
...
@@ -8,41 +8,39 @@ class Keywords:
...
@@ -8,41 +8,39 @@ class Keywords:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
kw
=
[]
self
.
kw
=
[]
def
build
(
self
,
mbox
,
limit
):
def
build
(
self
,
mbox
,
limit
):
mb
=
mailbox
.
UnixMailbox
(
open
(
mbox
))
mb
=
mailbox
.
UnixMailbox
(
open
(
mbox
))
msg
=
mb
.
next
()
msg
=
mb
.
next
()
while
msg
and
len
(
self
.
kw
)
<
limit
:
while
msg
and
len
(
self
.
kw
)
<
limit
:
sub
=
msg
.
dict
.
get
(
"subject"
,
""
).
split
(
' '
)
sub
=
msg
.
dict
.
get
(
"subject"
,
""
).
split
(
' '
)
for
f
in
sub
:
for
f
in
sub
:
ok
=
1
ok
=
1
for
c
in
f
:
for
c
in
f
:
if
not
c
in
string
.
letters
:
ok
=
0
if
not
c
in
string
.
letters
:
ok
=
0
if
ok
==
1
and
not
f
in
self
.
kw
:
self
.
kw
.
append
(
f
)
if
ok
==
1
and
not
f
in
self
.
kw
:
self
.
kw
.
append
(
f
)
msg
=
mb
.
next
()
msg
=
mb
.
next
()
P
=
cPickle
.
Pickler
(
open
(
'data/keywords'
,
'w'
))
P
=
cPickle
.
Pickler
(
open
(
'data/keywords'
,
'w'
))
P
.
dump
(
self
.
kw
)
P
.
dump
(
self
.
kw
)
def
reload
(
self
):
def
reload
(
self
):
P
=
cPickle
.
Unpickler
(
open
(
'data/keywords'
,
'r'
))
P
=
cPickle
.
Unpickler
(
open
(
'data/keywords'
,
'r'
))
self
.
kw
=
P
.
load
()
self
.
kw
=
P
.
load
()
def
keywords
(
self
):
def
keywords
(
self
):
return
self
.
kw
return
self
.
kw
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
k
=
Keywords
()
k
=
Keywords
()
k
.
build
(
"/home/andreas/zope.mbox"
,
1000
)
k
.
build
(
"/home/andreas/zope.mbox"
,
1000
)
lib/python/Products/ZCatalog/regressiontests/loadmail.py
View file @
2639fcb7
...
@@ -89,13 +89,13 @@ Commands:
...
@@ -89,13 +89,13 @@ Commands:
3.41 (0, 1)
3.41 (0, 1)
as described above.
as described above.
pdebug command args
pdebug command args
Run one of the other commands in the Python debugger.
Run one of the other commands in the Python debugger.
sample suite of tests::
sample suite of tests::
cd lib/python
cd lib/python
python Products/ZCatalog/regressiontests/loadmail.py base ~/zope.mbox 1000
python Products/ZCatalog/regressiontests/loadmail.py base ~/zope.mbox 1000
python Products/ZCatalog/regressiontests/loadmail.py index 100
python Products/ZCatalog/regressiontests/loadmail.py index 100
...
@@ -162,7 +162,7 @@ def loadmail(dest, name, mbox, printstat=0, max=-1):
...
@@ -162,7 +162,7 @@ def loadmail(dest, name, mbox, printstat=0, max=-1):
dest
.
manage_addFolder
(
name
)
dest
.
manage_addFolder
(
name
)
else
:
else
:
Products
.
BTreeFolder
.
BTreeFolder
.
manage_addBTreeFolder
(
dest
,
name
)
Products
.
BTreeFolder
.
BTreeFolder
.
manage_addBTreeFolder
(
dest
,
name
)
dest
=
getattr
(
dest
,
name
)
dest
=
getattr
(
dest
,
name
)
f
=
open
(
mbox
)
f
=
open
(
mbox
)
mb
=
mailbox
.
UnixMailbox
(
f
)
mb
=
mailbox
.
UnixMailbox
(
f
)
...
@@ -186,7 +186,7 @@ def loadmail(dest, name, mbox, printstat=0, max=-1):
...
@@ -186,7 +186,7 @@ def loadmail(dest, name, mbox, printstat=0, max=-1):
message
=
mb
.
next
()
message
=
mb
.
next
()
dest
.
number_of_messages
=
i
dest
.
number_of_messages
=
i
print
print
get_transaction
().
commit
()
get_transaction
().
commit
()
def
loadinc
(
name
,
mb
,
printstat
=
0
,
max
=
99999999
,
wait
=
1
):
def
loadinc
(
name
,
mb
,
printstat
=
0
,
max
=
99999999
,
wait
=
1
):
...
@@ -233,8 +233,8 @@ def loadinc(name, mb, printstat=0, max=99999999, wait=1):
...
@@ -233,8 +233,8 @@ def loadinc(name, mb, printstat=0, max=99999999, wait=1):
doc
=
app
=
mdest
=
0
doc
=
app
=
mdest
=
0
jar
.
close
()
jar
.
close
()
if
printstat
:
sys
.
stdout
.
write
(
"
\
t
%s
\
t
%s
\
t
\
n
"
%
(
i
,
f
.
tell
()))
if
printstat
:
sys
.
stdout
.
write
(
"
\
t
%s
\
t
%s
\
t
\
n
"
%
(
i
,
f
.
tell
()))
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
return
rconflicts
,
wconflicts
return
rconflicts
,
wconflicts
...
@@ -259,7 +259,7 @@ def indexf(app):
...
@@ -259,7 +259,7 @@ def indexf(app):
r
.
PARENTS
=
[
0
,
app
.
mail
]
r
.
PARENTS
=
[
0
,
app
.
mail
]
app
.
cat
.
manage_catalogFoundItems
(
r
,
r
,
''
,
''
,[
'DTML Document'
])
app
.
cat
.
manage_catalogFoundItems
(
r
,
r
,
''
,
''
,[
'DTML Document'
])
get_transaction
().
commit
()
get_transaction
().
commit
()
def
index
():
def
index
():
os
.
environ
[
'STUPID_LOG_FILE'
]
=
''
os
.
environ
[
'STUPID_LOG_FILE'
]
=
''
os
.
environ
[
'STUPID_LOG_SEVERITY'
]
=
'-111'
os
.
environ
[
'STUPID_LOG_SEVERITY'
]
=
'-111'
...
@@ -276,16 +276,16 @@ def index():
...
@@ -276,16 +276,16 @@ def index():
import
PLexicon
import
PLexicon
from
Products.ZCTextIndex.Lexicon
\
from
Products.ZCTextIndex.Lexicon
\
import
Splitter
,
CaseNormalizer
import
Splitter
,
CaseNormalizer
app
.
cat
.
_setObject
(
'lex'
,
app
.
cat
.
_setObject
(
'lex'
,
PLexicon
(
'lex'
,
''
,
Splitter
(),
CaseNormalizer
())
PLexicon
(
'lex'
,
''
,
Splitter
(),
CaseNormalizer
())
)
)
class
extra
:
class
extra
:
doc_attr
=
'PrincipiaSearchSource'
doc_attr
=
'PrincipiaSearchSource'
lexicon_id
=
'lex'
lexicon_id
=
'lex'
index_type
=
'Okapi BM25 Rank'
index_type
=
'Okapi BM25 Rank'
app
.
cat
.
addIndex
(
'PrincipiaSearchSource'
,
'ZCTextIndex'
,
extra
)
app
.
cat
.
addIndex
(
'PrincipiaSearchSource'
,
'ZCTextIndex'
,
extra
)
get_transaction
().
commit
()
get_transaction
().
commit
()
...
@@ -377,7 +377,7 @@ def inc():
...
@@ -377,7 +377,7 @@ def inc():
print
t
,
c
,
size
,
mem
print
t
,
c
,
size
,
mem
#hist("%s-%s-%s" % (omin, count, threads))
#hist("%s-%s-%s" % (omin, count, threads))
Zope
.
DB
.
close
()
Zope
.
DB
.
close
()
words
=
[
'banishment'
,
'indirectly'
,
'imprecise'
,
'peeks'
,
words
=
[
'banishment'
,
'indirectly'
,
'imprecise'
,
'peeks'
,
...
@@ -608,7 +608,7 @@ def incedit(edits, wait, ndel=20, nins=20):
...
@@ -608,7 +608,7 @@ def incedit(edits, wait, ndel=20, nins=20):
doc
=
app
=
0
doc
=
app
=
0
jar
.
close
()
jar
.
close
()
return
rconflicts
,
wconflicts
return
rconflicts
,
wconflicts
def
edit
():
def
edit
():
...
@@ -671,7 +671,7 @@ def edit():
...
@@ -671,7 +671,7 @@ def edit():
print
t
,
c
,
size
,
mem
print
t
,
c
,
size
,
mem
#hist("e%s" % (threads))
#hist("e%s" % (threads))
Zope
.
DB
.
close
()
Zope
.
DB
.
close
()
def
VmSize
():
def
VmSize
():
...
...
lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py
View file @
2639fcb7
...
@@ -59,28 +59,28 @@ class testZODB:
...
@@ -59,28 +59,28 @@ class testZODB:
""" some wrapper stuff around ZODB """
""" some wrapper stuff around ZODB """
def
__init__
(
self
,
file
=
"data/work/Data.fs"
,
open
=
1
):
def
__init__
(
self
,
file
=
"data/work/Data.fs"
,
open
=
1
):
self
.
db
=
ZODB
.
DB
(
ZODB
.
FileStorage
.
FileStorage
(
file
)
)
self
.
db
=
ZODB
.
DB
(
ZODB
.
FileStorage
.
FileStorage
(
file
)
)
if
open
==
1
:
if
open
==
1
:
self
.
connection
=
self
.
db
.
open
()
self
.
connection
=
self
.
db
.
open
()
self
.
root
=
self
.
connection
.
root
()
self
.
root
=
self
.
connection
.
root
()
def
write
(
self
,
name
,
obj
):
def
write
(
self
,
name
,
obj
):
self
.
root
[
name
]
=
obj
self
.
root
[
name
]
=
obj
get_transaction
().
commit
()
get_transaction
().
commit
()
def
read
(
self
,
name
):
def
read
(
self
,
name
):
return
self
.
root
[
name
]
return
self
.
root
[
name
]
def
__del__
(
self
):
def
__del__
(
self
):
self
.
db
.
close
()
self
.
db
.
close
()
class
testCatalog
(
Persistence
.
Persistent
,
unittest
.
TestCase
):
class
testCatalog
(
Persistence
.
Persistent
,
unittest
.
TestCase
):
""" Wrapper around the catalog stuff """
""" Wrapper around the catalog stuff """
...
@@ -89,7 +89,7 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
...
@@ -89,7 +89,7 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
self
.
num_files
=
0
self
.
num_files
=
0
self
.
keywords
=
[]
self
.
keywords
=
[]
self
.
maxfiles
=
maxfiles
self
.
maxfiles
=
maxfiles
self
.
_vocabulary
=
Vocabulary
.
Vocabulary
(
'Vocabulary'
,
self
.
_vocabulary
=
Vocabulary
.
Vocabulary
(
'Vocabulary'
,
'Vocabulary'
,
globbing
=
1
)
'Vocabulary'
,
globbing
=
1
)
self
.
_catalog
=
ZCatalog
.
ZCatalog
(
"zcatalog"
)
self
.
_catalog
=
ZCatalog
.
ZCatalog
(
"zcatalog"
)
...
@@ -118,7 +118,7 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
...
@@ -118,7 +118,7 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
try
:
try
:
self
.
catMessage
(
msg
)
self
.
catMessage
(
msg
)
self
.
msg_ids
.
append
(
msg
.
dict
[
"message-id"
])
self
.
msg_ids
.
append
(
msg
.
dict
[
"message-id"
])
except
:
except
:
msg
=
mb
.
next
()
msg
=
mb
.
next
()
continue
continue
...
@@ -133,20 +133,20 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
...
@@ -133,20 +133,20 @@ class testCatalog(Persistence.Persistent,unittest.TestCase):
msg
=
mb
.
next
()
msg
=
mb
.
next
()
continue
continue
for
s
in
sub
:
for
s
in
sub
:
if
not
s
in
self
.
keywords
:
self
.
keywords
.
append
(
s
)
if
not
s
in
self
.
keywords
:
self
.
keywords
.
append
(
s
)
self
.
_catalog
.
aq_parent
=
None
self
.
_catalog
.
aq_parent
=
None
def
catMessage
(
self
,
m
):
def
catMessage
(
self
,
m
):
self
.
_catalog
.
catalogObject
(
testMessage
(
m
)
,
self
.
_catalog
.
catalogObject
(
testMessage
(
m
)
,
m
.
dict
[
"message-id"
]
)
m
.
dict
[
"message-id"
]
)
def
uncatMessage
(
self
,
uid
):
def
uncatMessage
(
self
,
uid
):
self
.
_catalog
.
uncatalogObject
(
uid
)
self
.
_catalog
.
uncatalogObject
(
uid
)
class
testMessage
(
ExtensionClass
.
Base
):
class
testMessage
(
ExtensionClass
.
Base
):
def
__init__
(
self
,
msg
,
modify_doc
=
0
):
def
__init__
(
self
,
msg
,
modify_doc
=
0
):
...
@@ -159,28 +159,28 @@ class testMessage(ExtensionClass.Base):
...
@@ -159,28 +159,28 @@ class testMessage(ExtensionClass.Base):
if
modify_doc
!=
0
:
if
modify_doc
!=
0
:
self
.
keywords
=
map
(
self
.
reverse
,
self
.
keywords
)
self
.
keywords
=
map
(
self
.
reverse
,
self
.
keywords
)
self
.
file_id
=
msg
.
dict
.
get
(
"message-id"
,
""
)
self
.
file_id
=
msg
.
dict
.
get
(
"message-id"
,
""
)
self
.
length
=
len
(
str
(
msg
))
self
.
length
=
len
(
str
(
msg
))
date
=
msg
.
dict
.
get
(
"date"
,
""
)
date
=
msg
.
dict
.
get
(
"date"
,
""
)
try
:
try
:
self
.
date
=
time
.
mktime
(
rfc822
.
parsedate
(
date
)[:
9
])
self
.
date
=
time
.
mktime
(
rfc822
.
parsedate
(
date
)[:
9
])
except
:
pass
except
:
pass
def
reverse
(
self
,
s
):
def
reverse
(
self
,
s
):
l
=
list
(
s
)
l
=
list
(
s
)
l
.
reverse
()
l
.
reverse
()
return
string
.
join
(
l
,
""
)
return
string
.
join
(
l
,
""
)
def
__del__
(
self
):
def
__del__
(
self
):
pass
pass
class
BuildEnv
(
dispatcher
.
Dispatcher
,
unittest
.
TestCase
):
class
BuildEnv
(
dispatcher
.
Dispatcher
,
unittest
.
TestCase
):
""" build environment """
""" build environment """
def
__init__
(
self
,
func
,
*
args
,
**
kw
):
def
__init__
(
self
,
func
,
*
args
,
**
kw
):
...
@@ -190,16 +190,16 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -190,16 +190,16 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
self
.
init_phase
=
0
self
.
init_phase
=
0
self
.
setlog
(
open
(
"dispatcher.log"
,
"a"
)
)
self
.
setlog
(
open
(
"dispatcher.log"
,
"a"
)
)
self
.
logn
(
'treads=%d searchiterations=%d'
%
self
.
logn
(
'treads=%d searchiterations=%d'
%
(
numThreads
,
searchIterations
))
(
numThreads
,
searchIterations
))
self
.
logn
(
'updateiterations=%d maxfiles=%d'
%
self
.
logn
(
'updateiterations=%d maxfiles=%d'
%
(
updateIterations
,
maxFiles
))
(
updateIterations
,
maxFiles
))
#############################################################
#############################################################
# Build up ZODB
# Build up ZODB
#############################################################
#############################################################
def
buildTestEnvironment
(
self
,
args
,
kw
):
def
buildTestEnvironment
(
self
,
args
,
kw
):
self
.
init_phase
=
1
self
.
init_phase
=
1
self
.
dispatcher
(
"funcTestEnvironment"
,(
"funcTestEnvironment"
,
1
,
args
,
kw
))
self
.
dispatcher
(
"funcTestEnvironment"
,(
"funcTestEnvironment"
,
1
,
args
,
kw
))
...
@@ -210,13 +210,13 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -210,13 +210,13 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
env
=
self
.
th_setup
()
env
=
self
.
th_setup
()
if
not
os
.
path
.
exists
(
dataDir
):
os
.
makedirs
(
dataDir
)
if
not
os
.
path
.
exists
(
dataDir
):
os
.
makedirs
(
dataDir
)
os
.
system
(
"rm -f %s/*"
%
dataDir
)
os
.
system
(
"rm -f %s/*"
%
dataDir
)
zodb
=
testZODB
(
"%s/Data_orig.fs"
%
dataDir
)
zodb
=
testZODB
(
"%s/Data_orig.fs"
%
dataDir
)
print
"parsing and reading mailbox file %s....please wait"
%
mbox
print
"parsing and reading mailbox file %s....please wait"
%
mbox
tc
=
testCatalog
(
mbox
,
maxFiles
)
tc
=
testCatalog
(
mbox
,
maxFiles
)
print
"writing Catalog to ZODB"
print
"writing Catalog to ZODB"
zodb
.
write
(
"catalog"
,
tc
)
zodb
.
write
(
"catalog"
,
tc
)
...
@@ -224,25 +224,25 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -224,25 +224,25 @@ class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
kw
=
keywords
.
Keywords
()
kw
=
keywords
.
Keywords
()
kw
.
build
(
mbox
,
1000
)
kw
.
build
(
mbox
,
1000
)
print
tc
.
num_files
,
"files read"
print
tc
.
num_files
,
"files read"
print
"Initalization complete"
print
"Initalization complete"
self
.
th_teardown
(
env
)
self
.
th_teardown
(
env
)
class
testSearches
(
dispatcher
.
Dispatcher
,
unittest
.
TestCase
):
class
testSearches
(
dispatcher
.
Dispatcher
,
unittest
.
TestCase
):
""" test searches """
""" test searches """
def
__init__
(
self
,
func
,
*
args
,
**
kw
):
def
__init__
(
self
,
func
,
*
args
,
**
kw
):
unittest
.
TestCase
.
__init__
(
self
,
func
,
args
,
kw
)
unittest
.
TestCase
.
__init__
(
self
,
func
,
args
,
kw
)
dispatcher
.
Dispatcher
.
__init__
(
self
,
func
)
dispatcher
.
Dispatcher
.
__init__
(
self
,
func
)
self
.
init_phase
=
0
self
.
init_phase
=
0
self
.
setlog
(
open
(
"dispatcher.log"
,
"a"
)
)
self
.
setlog
(
open
(
"dispatcher.log"
,
"a"
)
)
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -250,19 +250,19 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -250,19 +250,19 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
if
not
os
.
path
.
exists
(
"data/work"
):
os
.
makedirs
(
"data/work"
)
if
not
os
.
path
.
exists
(
"data/work"
):
os
.
makedirs
(
"data/work"
)
assert
os
.
system
(
"cp %s/Data_orig.fs data/work/Data.fs"
%
dataDir
)
==
0
,
\
assert
os
.
system
(
"cp %s/Data_orig.fs data/work/Data.fs"
%
dataDir
)
==
0
,
\
"Error while replicating original data"
"Error while replicating original data"
self
.
zodb
=
testZODB
(
"data/work/Data.fs"
,
open
=
0
)
self
.
zodb
=
testZODB
(
"data/work/Data.fs"
,
open
=
0
)
self
.
threads
=
{}
self
.
threads
=
{}
self
.
init_zodb_size
=
self
.
zodb_size
()
self
.
init_zodb_size
=
self
.
zodb_size
()
kw
=
keywords
.
Keywords
()
kw
=
keywords
.
Keywords
()
kw
.
reload
()
kw
.
reload
()
self
.
keywords
=
kw
.
keywords
()
self
.
keywords
=
kw
.
keywords
()
self
.
logn
(
"-"
*
80
)
self
.
logn
(
"-"
*
80
)
self
.
logn
(
'treads=%d searchiterations=%d'
%
self
.
logn
(
'treads=%d searchiterations=%d'
%
(
numThreads
,
searchIterations
))
(
numThreads
,
searchIterations
))
self
.
logn
(
'updateiterations=%d maxfiles=%d'
%
self
.
logn
(
'updateiterations=%d maxfiles=%d'
%
(
updateIterations
,
maxFiles
))
(
updateIterations
,
maxFiles
))
...
@@ -270,7 +270,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -270,7 +270,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
self
.
log_zodb_size
(
"before"
,
self
.
init_zodb_size
)
self
.
log_zodb_size
(
"before"
,
self
.
init_zodb_size
)
self
.
log_zodb_size
(
"after "
,
self
.
zodb_size
())
self
.
log_zodb_size
(
"after "
,
self
.
zodb_size
())
del
self
.
zodb
del
self
.
zodb
self
.
zodb
=
self
.
catalog
=
None
self
.
zodb
=
self
.
catalog
=
None
def
log_zodb_size
(
self
,
s
,
n
):
def
log_zodb_size
(
self
,
s
,
n
):
self
.
logn
(
"Size of ZODB (data/work/Data.fs) %s test : %s"
%
(
s
,
n
)
)
self
.
logn
(
"Size of ZODB (data/work/Data.fs) %s test : %s"
%
(
s
,
n
)
)
...
@@ -285,16 +285,16 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -285,16 +285,16 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
if
n
<
1024.0
*
1024.0
:
return
"%8.3lf KB"
%
(
1.0
*
n
/
1024.0
)
if
n
<
1024.0
*
1024.0
:
return
"%8.3lf KB"
%
(
1.0
*
n
/
1024.0
)
if
n
<
1024.0
*
1024.0
*
1024.0
:
return
"%8.3lf MB"
%
(
1.0
*
n
/
1024.0
/
1024.0
)
if
n
<
1024.0
*
1024.0
*
1024.0
:
return
"%8.3lf MB"
%
(
1.0
*
n
/
1024.0
/
1024.0
)
#############################################################
#############################################################
# Fulltext test
# Fulltext test
#############################################################
#############################################################
def
testFulltextIndex
(
self
,
args
,
kw
):
def
testFulltextIndex
(
self
,
args
,
kw
):
""" benchmark FulltextIndex """
""" benchmark FulltextIndex """
self
.
dispatcher
(
'funcFulltextIndex'
,
self
.
dispatcher
(
'funcFulltextIndex'
,
(
'funcFulltextIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
(
'funcFulltextIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
...
@@ -311,13 +311,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -311,13 +311,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
self
.
th_teardown
(
env
)
self
.
th_teardown
(
env
)
#############################################################
#############################################################
# Field index test
# Field index test
#############################################################
#############################################################
def
testFieldIndex
(
self
,
args
,
kw
):
def
testFieldIndex
(
self
,
args
,
kw
):
""" benchmark field index"""
""" benchmark field index"""
self
.
dispatcher
(
'funcFieldIndex'
,
self
.
dispatcher
(
'funcFieldIndex'
,
(
'funcFieldIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
(
'funcFieldIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
...
@@ -329,21 +329,21 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -329,21 +329,21 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
env
=
self
.
th_setup
()
env
=
self
.
th_setup
()
for
i
in
range
(
0
,
searchIterations
):
for
i
in
range
(
0
,
searchIterations
):
res
=
cat
.
searchResults
(
{
"length"
:
i
}
)
res
=
cat
.
searchResults
(
{
"length"
:
i
}
)
for
r
in
res
:
for
r
in
res
:
assert
i
==
r
.
length
,
"%s should have size %d but is %s"
%
\
assert
i
==
r
.
length
,
"%s should have size %d but is %s"
%
\
(
r
.
file_id
,
i
,
r
.
length
)
(
r
.
file_id
,
i
,
r
.
length
)
self
.
th_teardown
(
env
)
self
.
th_teardown
(
env
)
#############################################################
#############################################################
# Keyword index test
# Keyword index test
#############################################################
#############################################################
def
testKeywordIndex
(
self
,
args
,
kw
):
def
testKeywordIndex
(
self
,
args
,
kw
):
""" benchmark Keyword index"""
""" benchmark Keyword index"""
self
.
dispatcher
(
'funcKeywordIndex'
,
self
.
dispatcher
(
'funcKeywordIndex'
,
(
'funcKeywordIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
(
'funcKeywordIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
...
@@ -351,22 +351,22 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -351,22 +351,22 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
""" benchmark KeywordIndex """
""" benchmark KeywordIndex """
cat
,
msg_ids
=
self
.
get_catalog
()
cat
,
msg_ids
=
self
.
get_catalog
()
env
=
self
.
th_setup
()
env
=
self
.
th_setup
()
for
kw
in
self
.
keywords
:
for
kw
in
self
.
keywords
:
res
=
cat
.
searchResults
(
{
"subject"
:
kw
}
)
res
=
cat
.
searchResults
(
{
"subject"
:
kw
}
)
# assert len(res) != 0 , "Search result for keyword '%s' is empty" % kw
# assert len(res) != 0 , "Search result for keyword '%s' is empty" % kw
self
.
th_teardown
(
env
)
self
.
th_teardown
(
env
)
#############################################################
#############################################################
# Field range index test
# Field range index test
#############################################################
#############################################################
def
testFieldRangeIndex
(
self
,
args
,
kw
):
def
testFieldRangeIndex
(
self
,
args
,
kw
):
""" benchmark field range index"""
""" benchmark field range index"""
self
.
dispatcher
(
'funcFieldRangeIndex'
,
self
.
dispatcher
(
'funcFieldRangeIndex'
,
(
'funcFieldRangeIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
(
'funcFieldRangeIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
...
@@ -379,7 +379,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -379,7 +379,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
rg
=
[]
rg
=
[]
for
i
in
range
(
searchIterations
):
for
i
in
range
(
searchIterations
):
m
=
whrandom
.
randint
(
0
,
10000
)
m
=
whrandom
.
randint
(
0
,
10000
)
n
=
m
+
200
n
=
m
+
200
rg
.
append
((
m
,
n
))
rg
.
append
((
m
,
n
))
...
@@ -394,13 +394,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -394,13 +394,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
#############################################################
#############################################################
# Keyword + range index test
# Keyword + range index test
#############################################################
#############################################################
def
testKeywordRangeIndex
(
self
,
args
,
kw
):
def
testKeywordRangeIndex
(
self
,
args
,
kw
):
""" benchmark Keyword range index"""
""" benchmark Keyword range index"""
self
.
dispatcher
(
'funcKeywordRangeIndex'
,
self
.
dispatcher
(
'funcKeywordRangeIndex'
,
(
'funcKeywordRangeIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
(
'funcKeywordRangeIndex'
,
kw
[
"numThreads"
]
,
()
,
{}
)
)
...
@@ -411,15 +411,15 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -411,15 +411,15 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
rg
=
[]
rg
=
[]
for
i
in
range
(
len
(
self
.
keywords
)):
for
i
in
range
(
len
(
self
.
keywords
)):
m
=
whrandom
.
randint
(
0
,
10000
)
m
=
whrandom
.
randint
(
0
,
10000
)
n
=
m
+
200
n
=
m
+
200
rg
.
append
(
(
m
,
n
)
)
rg
.
append
(
(
m
,
n
)
)
env
=
self
.
th_setup
()
env
=
self
.
th_setup
()
results
=
[]
results
=
[]
for
i
in
range
(
len
(
self
.
keywords
)):
for
i
in
range
(
len
(
self
.
keywords
)):
results
.
append
(
cat
.
searchResults
(
{
"keywords"
:
self
.
keywords
[
i
],
results
.
append
(
cat
.
searchResults
(
{
"keywords"
:
self
.
keywords
[
i
],
"length"
:
rg
[
i
],
"length"
:
rg
[
i
],
"length_usage"
:
"range:min:max"
}
)
"length_usage"
:
"range:min:max"
}
)
)
)
...
@@ -427,13 +427,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -427,13 +427,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
self
.
th_teardown
(
env
)
self
.
th_teardown
(
env
)
#############################################################
#############################################################
# Test full reindexing
# Test full reindexing
#############################################################
#############################################################
def
testUpdates
(
self
,
args
,
kw
):
def
testUpdates
(
self
,
args
,
kw
):
""" benchmark concurrent catalog/uncatalog operations """
""" benchmark concurrent catalog/uncatalog operations """
self
.
dispatcher
(
"testUpdates"
,
self
.
dispatcher
(
"testUpdates"
,
(
"funcUpdates"
,
kw
[
"numThreads"
]
,
args
,
kw
))
(
"funcUpdates"
,
kw
[
"numThreads"
]
,
args
,
kw
))
...
@@ -463,7 +463,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -463,7 +463,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
cat
.
uncatalog_object
(
mid
)
cat
.
uncatalog_object
(
mid
)
if
kw
.
get
(
"commit"
,
1
)
==
1
:
if
kw
.
get
(
"commit"
,
1
)
==
1
:
get_transaction
().
commit
()
get_transaction
().
commit
()
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
except
ZODB
.
POSException
.
ConflictError
:
except
ZODB
.
POSException
.
ConflictError
:
uncat_conflicts
=
uncat_conflicts
+
1
uncat_conflicts
=
uncat_conflicts
+
1
...
@@ -472,14 +472,14 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -472,14 +472,14 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
cat
.
catalog_object
(
obj
,
mid
)
cat
.
catalog_object
(
obj
,
mid
)
if
kw
.
get
(
"commit"
,
1
)
==
1
:
if
kw
.
get
(
"commit"
,
1
)
==
1
:
get_transaction
().
commit
()
get_transaction
().
commit
()
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
except
ZODB
.
POSException
.
ConflictError
:
except
ZODB
.
POSException
.
ConflictError
:
cat_conflicts
=
cat_conflicts
+
1
cat_conflicts
=
cat_conflicts
+
1
try
:
try
:
get_transaction
().
commit
()
get_transaction
().
commit
()
except
:
pass
except
:
pass
...
@@ -501,30 +501,30 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -501,30 +501,30 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
while
msg
and
i
<
numUpdates
:
while
msg
and
i
<
numUpdates
:
obj
=
testMessage
(
msg
)
obj
=
testMessage
(
msg
)
mid
=
msg
.
dict
.
get
(
"message-id"
,
None
)
mid
=
msg
.
dict
.
get
(
"message-id"
,
None
)
if
mid
:
if
mid
:
dict
[
mid
]
=
obj
dict
[
mid
]
=
obj
i
=
i
+
1
i
=
i
+
1
msg
=
mb
.
next
()
msg
=
mb
.
next
()
return
dict
return
dict
#############################################################
#############################################################
# Test full reindexing
# Test full reindexing
#############################################################
#############################################################
def
testReindexing
(
self
,
args
,
kw
):
def
testReindexing
(
self
,
args
,
kw
):
""" test reindexing of existing data """
""" test reindexing of existing data """
self
.
dispatcher
(
"testReindexing"
,
self
.
dispatcher
(
"testReindexing"
,
(
"funcReindexing"
,
kw
[
"numThreads"
]
,
(
mbox
,
1000
)
,
{}
))
(
"funcReindexing"
,
kw
[
"numThreads"
]
,
(
mbox
,
1000
)
,
{}
))
def
testReindexingAndModify
(
self
,
args
,
kw
):
def
testReindexingAndModify
(
self
,
args
,
kw
):
""" test reindexing of existing data but with modifications"""
""" test reindexing of existing data but with modifications"""
self
.
dispatcher
(
"testReindexing"
,
self
.
dispatcher
(
"testReindexing"
,
(
"funcReindexing"
,
kw
[
"numThreads"
]
,
(
mbox
,
1000
,
1
)
,
{}
))
(
"funcReindexing"
,
kw
[
"numThreads"
]
,
(
mbox
,
1000
,
1
)
,
{}
))
...
@@ -563,13 +563,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -563,13 +563,13 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
self
.
th_teardown
(
env
,
cat_conflicts
=
cat_conflicts
)
self
.
th_teardown
(
env
,
cat_conflicts
=
cat_conflicts
)
#############################################################
#############################################################
# Test full reindexing
# Test full reindexing
#############################################################
#############################################################
def
testIncrementalIndexing
(
self
,
args
,
kw
):
def
testIncrementalIndexing
(
self
,
args
,
kw
):
""" testing incremental indexing """
""" testing incremental indexing """
self
.
dispatcher
(
"testIncrementalIndexing"
,
self
.
dispatcher
(
"testIncrementalIndexing"
,
(
"funcReindexing"
,
kw
[
"numThreads"
],
(
mbox2
,
1000
)
,
{}))
(
"funcReindexing"
,
kw
[
"numThreads"
],
(
mbox2
,
1000
)
,
{}))
...
@@ -581,7 +581,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
...
@@ -581,7 +581,7 @@ class testSearches(dispatcher.Dispatcher,unittest.TestCase):
connection
=
self
.
zodb
.
db
.
open
()
connection
=
self
.
zodb
.
db
.
open
()
root
=
connection
.
root
()
root
=
connection
.
root
()
cat
=
root
[
"catalog"
].
_catalog
cat
=
root
[
"catalog"
].
_catalog
msg_ids
=
root
[
'catalog'
].
msg_ids
msg_ids
=
root
[
'catalog'
].
msg_ids
return
cat
,
msg_ids
return
cat
,
msg_ids
...
@@ -594,7 +594,7 @@ def usage(program):
...
@@ -594,7 +594,7 @@ def usage(program):
print
"initalize the test catalog: %s -i -f <maximum number files to use> "
%
program
print
"initalize the test catalog: %s -i -f <maximum number files to use> "
%
program
print
"to run the basic tests: %s -b -f <maximum number files to use> "
%
program
print
"to run the basic tests: %s -b -f <maximum number files to use> "
%
program
print
"to run the advanced tests: %s -a -f <maximum number files to use> "
%
program
print
"to run the advanced tests: %s -a -f <maximum number files to use> "
%
program
def
main
():
def
main
():
...
@@ -606,7 +606,7 @@ def main():
...
@@ -606,7 +606,7 @@ def main():
optsLst
=
map
(
lambda
x
:
x
[
0
],
opts
)
optsLst
=
map
(
lambda
x
:
x
[
0
],
opts
)
if
optsLst
==
[]:
usage
(
os
.
path
.
basename
(
sys
.
argv
[
0
]));
sys
.
exit
(
0
)
if
optsLst
==
[]:
usage
(
os
.
path
.
basename
(
sys
.
argv
[
0
]));
sys
.
exit
(
0
)
for
k
,
v
in
opts
:
for
k
,
v
in
opts
:
if
k
in
[
'-h'
,
'--help'
]
:
usage
(
os
.
path
.
basename
(
sys
.
argv
[
0
]));
sys
.
exit
(
0
)
if
k
in
[
'-h'
,
'--help'
]
:
usage
(
os
.
path
.
basename
(
sys
.
argv
[
0
]));
sys
.
exit
(
0
)
if
k
==
"-f"
:
maxFiles
=
string
.
atoi
(
v
)
if
k
==
"-f"
:
maxFiles
=
string
.
atoi
(
v
)
...
@@ -616,7 +616,7 @@ def main():
...
@@ -616,7 +616,7 @@ def main():
if
'-i'
in
optsLst
:
if
'-i'
in
optsLst
:
unittest
.
TextTestRunner
().
run
(
get_tests
(
'init'
))
unittest
.
TextTestRunner
().
run
(
get_tests
(
'init'
))
if
'-b'
in
optsLst
:
if
'-b'
in
optsLst
:
unittest
.
TextTestRunner
().
run
(
get_tests
(
'bench1'
))
unittest
.
TextTestRunner
().
run
(
get_tests
(
'bench1'
))
...
@@ -680,8 +680,8 @@ def get_tests(what):
...
@@ -680,8 +680,8 @@ def get_tests(what):
testSearches
(
"testReindexingAndModify"
,
numThreads
=
1
),
testSearches
(
"testReindexingAndModify"
,
numThreads
=
1
),
# testSearches("testUpdates",numThreads=10,numUpdates=100),
# testSearches("testUpdates",numThreads=10,numUpdates=100),
)
)
init_tests
=
(
init_tests
=
(
BuildEnv
(
"buildTestEnvironment"
,
dataDir
,
maxFiles
)
,
BuildEnv
(
"buildTestEnvironment"
,
dataDir
,
maxFiles
)
,
)
)
...
@@ -698,13 +698,12 @@ def pdebug():
...
@@ -698,13 +698,12 @@ def pdebug():
test_suite
()
test_suite
()
def
debug
():
def
debug
():
test_suite
().
debug
()
test_suite
().
debug
()
def
pdebug
():
def
pdebug
():
import
pdb
import
pdb
pdb
.
run
(
'debug()'
)
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
lib/python/Products/ZCatalog/regressiontests/regressionCatalogTiming.py
View file @
2639fcb7
...
@@ -51,7 +51,7 @@ class TestTimeIndex(TestCase):
...
@@ -51,7 +51,7 @@ class TestTimeIndex(TestCase):
c
.
manage_addIndex
(
'from'
,
'TextIndex'
)
c
.
manage_addIndex
(
'from'
,
'TextIndex'
)
c
.
manage_addIndex
(
'date'
,
'FieldIndex'
)
c
.
manage_addIndex
(
'date'
,
'FieldIndex'
)
c
.
manage_addIndex
(
'raw'
,
'TextIndex'
)
c
.
manage_addIndex
(
'raw'
,
'TextIndex'
)
def
tearDown
(
self
):
def
tearDown
(
self
):
try
:
self
.
app
.
_delObject
(
'catalogtest'
)
try
:
self
.
app
.
_delObject
(
'catalogtest'
)
except
AttributeError
:
pass
except
AttributeError
:
pass
...
@@ -61,7 +61,7 @@ class TestTimeIndex(TestCase):
...
@@ -61,7 +61,7 @@ class TestTimeIndex(TestCase):
except
AttributeError
:
pass
except
AttributeError
:
pass
self
.
app
=
None
self
.
app
=
None
del
self
.
app
del
self
.
app
def
checkTimeBulkIndex
(
self
):
def
checkTimeBulkIndex
(
self
):
print
print
c
=
self
.
app
.
catalogtest
.
catalog
c
=
self
.
app
.
catalogtest
.
catalog
...
@@ -109,7 +109,7 @@ class TestTimeIndex(TestCase):
...
@@ -109,7 +109,7 @@ class TestTimeIndex(TestCase):
assert
len
(
c
({
'raw'
:
'chris'
}))
!=
0
assert
len
(
c
({
'raw'
:
'chris'
}))
!=
0
assert
len
(
c
({
'raw'
:
'gghdjkasjdsda'
}))
==
0
assert
len
(
c
({
'raw'
:
'gghdjkasjdsda'
}))
==
0
assert
c
({
'PrincipiaSearchSource'
:
'the*'
})
assert
c
({
'PrincipiaSearchSource'
:
'the*'
})
def
checkTimeSubcommit
(
self
):
def
checkTimeSubcommit
(
self
):
print
print
for
x
in
(
None
,
100
,
500
,
1000
,
10000
):
for
x
in
(
None
,
100
,
500
,
1000
,
10000
):
...
@@ -190,7 +190,7 @@ def out(s):
...
@@ -190,7 +190,7 @@ def out(s):
def
test_suite
():
def
test_suite
():
s1
=
makeSuite
(
TestTimeIndex
,
'check'
)
s1
=
makeSuite
(
TestTimeIndex
,
'check'
)
testsuite
=
TestSuite
((
s1
,))
testsuite
=
TestSuite
((
s1
,))
return
testsuite
return
testsuite
...
@@ -199,7 +199,7 @@ def main():
...
@@ -199,7 +199,7 @@ def main():
if
not
os
.
path
.
isfile
(
mb
):
if
not
os
.
path
.
isfile
(
mb
):
print
"do you want to get the zope.mbox file from lists.zope.org?"
print
"do you want to get the zope.mbox file from lists.zope.org?"
print
"it's required for testing (98MB, ~ 30mins on fast conn)"
print
"it's required for testing (98MB, ~ 30mins on fast conn)"
print
"it's also available at korak:/home/chrism/zope.mbox"
print
"it's also available at korak:/home/chrism/zope.mbox"
print
"-- type 'Y' or 'N'"
print
"-- type 'Y' or 'N'"
a
=
raw_input
()
a
=
raw_input
()
if
lower
(
a
[:
1
])
==
'y'
:
if
lower
(
a
[:
1
])
==
'y'
:
...
@@ -235,8 +235,7 @@ def debug():
...
@@ -235,8 +235,7 @@ def debug():
test_suite
().
debug
()
test_suite
().
debug
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
globals
()[
sys
.
argv
[
1
]]()
else
:
else
:
main
()
main
()
lib/python/Products/ZCatalog/regressiontests/regressionUnicode.py
View file @
2639fcb7
...
@@ -37,15 +37,15 @@ class UnicodeTextIndexCatalogTest(unittest.TestCase):
...
@@ -37,15 +37,15 @@ class UnicodeTextIndexCatalogTest(unittest.TestCase):
t4
=
TO
(
'i am a brown '
+
unicode
(
'fox'
)
+
' dancing with a future alien'
,[])
t4
=
TO
(
'i am a brown '
+
unicode
(
'fox'
)
+
' dancing with a future alien'
,[])
t5
=
TO
(
"""
t5
=
TO
(
"""
Die USA und Grobritannien knnen nach der Zerstrung der
Die USA und Grobritannien knnen nach der Zerstrung der
afghanischen Luftabwehr nun rund um die Uhr Angriffe fliegen. Das gab
afghanischen Luftabwehr nun rund um die Uhr Angriffe fliegen. Das gab
Verteidigungsminister Donald Rumsfeld bekannt. Bei den dreitgigen Angriffen
Verteidigungsminister Donald Rumsfeld bekannt. Bei den dreitgigen Angriffen
seien auch bis auf einen alle Flugpltze der Taliban zerstrt worden. Rumsfeld
seien auch bis auf einen alle Flugpltze der Taliban zerstrt worden. Rumsfeld
erklrte weiter, er knne die Berichte nicht besttigen, wonach bei den
erklrte weiter, er knne die Berichte nicht besttigen, wonach bei den
amerikanischen Angriffen vier afghanische Mitarbeiter einer von den UN
amerikanischen Angriffen vier afghanische Mitarbeiter einer von den UN
finanzierten Hilfsorganisation gettet wurden. Diese knnten auch durch
finanzierten Hilfsorganisation gettet wurden. Diese knnten auch durch
Gegenfeuer der Taliban gettet worden sein.
Gegenfeuer der Taliban gettet worden sein.
"""
,[
unicode
(
'dreitgigen'
,
'latin1'
),
'zerstrt'
])
"""
,[
unicode
(
'dreitgigen'
,
'latin1'
),
'zerstrt'
])
self
.
cat
.
catalog_object
(
t1
,
"o1"
)
self
.
cat
.
catalog_object
(
t1
,
"o1"
)
self
.
cat
.
catalog_object
(
t2
,
"o2"
)
self
.
cat
.
catalog_object
(
t2
,
"o2"
)
...
@@ -59,7 +59,7 @@ class UnicodeTextIndexCatalogTest(unittest.TestCase):
...
@@ -59,7 +59,7 @@ class UnicodeTextIndexCatalogTest(unittest.TestCase):
(
'dreitgigen'
,(
'o5'
,))
(
'dreitgigen'
,(
'o5'
,))
]
]
self
.
kw_tests
=
[
(
'quick'
,(
'o1'
,)
),
self
.
kw_tests
=
[
(
'quick'
,(
'o1'
,)
),
(
'zerstrt'
,(
'o3'
,
'o5'
)),
(
'zerstrt'
,(
'o3'
,
'o5'
)),
(
'dreitgigen'
,(
'o5'
,))
(
'dreitgigen'
,(
'o5'
,))
...
...
lib/python/Products/ZCatalog/regressiontests/unittest_patched.py
View file @
2639fcb7
...
@@ -31,14 +31,14 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
...
@@ -31,14 +31,14 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
# This is patched version of unittest.py and allows to pass additional
# This is patched version of unittest.py and allows to pass additional
# parameters to the TestCase constructor.
# parameters to the TestCase constructor.
# This special version is only need to run the regression test
# This special version is only need to run the regression test
# in testCatalog.py#
# in testCatalog.py#
#
#
# ajung
# ajung
__author__
=
"Steve Purcell"
__author__
=
"Steve Purcell"
__email__
=
"stephen_purcell@yahoo.com"
__email__
=
"stephen_purcell@yahoo.com"
__version__
=
"$Revision: 1.
2
$"
[
11
:
-
2
]
__version__
=
"$Revision: 1.
3
$"
[
11
:
-
2
]
import
time
import
time
import
sys
import
sys
...
@@ -101,7 +101,7 @@ class TestResult:
...
@@ -101,7 +101,7 @@ class TestResult:
def
stop
(
self
):
def
stop
(
self
):
"Indicates that the tests should be aborted"
"Indicates that the tests should be aborted"
self
.
shouldStop
=
1
self
.
shouldStop
=
1
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<%s run=%i errors=%i failures=%i>"
%
\
return
"<%s run=%i errors=%i failures=%i>"
%
\
(
self
.
__class__
,
self
.
testsRun
,
len
(
self
.
errors
),
(
self
.
__class__
,
self
.
testsRun
,
len
(
self
.
errors
),
...
@@ -111,14 +111,14 @@ class TestResult:
...
@@ -111,14 +111,14 @@ class TestResult:
class
TestCase
:
class
TestCase
:
"""A class whose instances are single test cases.
"""A class whose instances are single test cases.
Test authors should subclass TestCase for their own tests. Construction
Test authors should subclass TestCase for their own tests. Construction
and deconstruction of the test's environment ('fixture') can be
and deconstruction of the test's environment ('fixture') can be
implemented by overriding the 'setUp' and 'tearDown' methods respectively.
implemented by overriding the 'setUp' and 'tearDown' methods respectively.
By default, the test code itself should be placed in a method named
By default, the test code itself should be placed in a method named
'runTest'.
'runTest'.
If the fixture may be used for many test cases, create as
If the fixture may be used for many test cases, create as
many test methods as are needed. When instantiating such a TestCase
many test methods as are needed. When instantiating such a TestCase
subclass, specify in the constructor arguments the name of the test method
subclass, specify in the constructor arguments the name of the test method
that the instance is to execute.
that the instance is to execute.
...
@@ -131,7 +131,7 @@ class TestCase:
...
@@ -131,7 +131,7 @@ class TestCase:
method when executed. Raises a ValueError if the instance does
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
not have a method with the specified name.
"""
"""
try
:
try
:
self
.
__testMethodName
=
methodName
self
.
__testMethodName
=
methodName
testMethod
=
getattr
(
self
,
methodName
)
testMethod
=
getattr
(
self
,
methodName
)
...
@@ -250,7 +250,7 @@ class TestCase:
...
@@ -250,7 +250,7 @@ class TestCase:
def
fail
(
self
,
msg
=
None
):
def
fail
(
self
,
msg
=
None
):
"""Fail immediately, with the given message."""
"""Fail immediately, with the given message."""
raise
AssertionError
,
msg
raise
AssertionError
,
msg
def
__exc_info
(
self
):
def
__exc_info
(
self
):
"""Return a version of sys.exc_info() with the traceback frame
"""Return a version of sys.exc_info() with the traceback frame
minimised; usually the top level of the traceback frame is not
minimised; usually the top level of the traceback frame is not
...
@@ -465,7 +465,7 @@ class _WritelnDecorator:
...
@@ -465,7 +465,7 @@ class _WritelnDecorator:
if
args
:
apply
(
self
.
write
,
args
)
if
args
:
apply
(
self
.
write
,
args
)
self
.
write
(
self
.
linesep
)
self
.
write
(
self
.
linesep
)
class
_JUnitTextTestResult
(
TestResult
):
class
_JUnitTextTestResult
(
TestResult
):
"""A test result class that can print formatted text results to a stream.
"""A test result class that can print formatted text results to a stream.
...
@@ -481,12 +481,12 @@ class _JUnitTextTestResult(TestResult):
...
@@ -481,12 +481,12 @@ class _JUnitTextTestResult(TestResult):
self
.
stream
.
flush
()
self
.
stream
.
flush
()
if
error
[
0
]
is
KeyboardInterrupt
:
if
error
[
0
]
is
KeyboardInterrupt
:
self
.
shouldStop
=
1
self
.
shouldStop
=
1
def
addFailure
(
self
,
test
,
error
):
def
addFailure
(
self
,
test
,
error
):
TestResult
.
addFailure
(
self
,
test
,
error
)
TestResult
.
addFailure
(
self
,
test
,
error
)
self
.
stream
.
write
(
'F'
)
self
.
stream
.
write
(
'F'
)
self
.
stream
.
flush
()
self
.
stream
.
flush
()
def
startTest
(
self
,
test
):
def
startTest
(
self
,
test
):
TestResult
.
startTest
(
self
,
test
)
TestResult
.
startTest
(
self
,
test
)
self
.
stream
.
write
(
'.'
)
self
.
stream
.
write
(
'.'
)
...
@@ -505,7 +505,7 @@ class _JUnitTextTestResult(TestResult):
...
@@ -505,7 +505,7 @@ class _JUnitTextTestResult(TestResult):
self
.
stream
.
writeln
(
"%i) %s"
%
(
i
,
test
))
self
.
stream
.
writeln
(
"%i) %s"
%
(
i
,
test
))
self
.
stream
.
writeln
(
errString
)
self
.
stream
.
writeln
(
errString
)
i
=
i
+
1
i
=
i
+
1
def
printErrors
(
self
):
def
printErrors
(
self
):
self
.
printNumberedErrors
(
"error"
,
self
.
errors
)
self
.
printNumberedErrors
(
"error"
,
self
.
errors
)
...
@@ -523,7 +523,7 @@ class _JUnitTextTestResult(TestResult):
...
@@ -523,7 +523,7 @@ class _JUnitTextTestResult(TestResult):
self
.
stream
.
writeln
(
"Run: %i ; Failures: %i ; Errors: %i"
%
self
.
stream
.
writeln
(
"Run: %i ; Failures: %i ; Errors: %i"
%
(
self
.
testsRun
,
len
(
self
.
failures
),
(
self
.
testsRun
,
len
(
self
.
failures
),
len
(
self
.
errors
)))
len
(
self
.
errors
)))
def
printResult
(
self
):
def
printResult
(
self
):
self
.
printHeader
()
self
.
printHeader
()
self
.
printErrors
()
self
.
printErrors
()
...
@@ -532,7 +532,7 @@ class _JUnitTextTestResult(TestResult):
...
@@ -532,7 +532,7 @@ class _JUnitTextTestResult(TestResult):
class
JUnitTextTestRunner
:
class
JUnitTextTestRunner
:
"""A test runner class that displays results in textual form.
"""A test runner class that displays results in textual form.
The display format approximates that of JUnit's 'textui' test runner.
The display format approximates that of JUnit's 'textui' test runner.
This test runner may be removed in a future version of PyUnit.
This test runner may be removed in a future version of PyUnit.
"""
"""
...
@@ -565,7 +565,7 @@ class _VerboseTextTestResult(TestResult):
...
@@ -565,7 +565,7 @@ class _VerboseTextTestResult(TestResult):
self
.
stream
=
stream
self
.
stream
=
stream
self
.
lastFailure
=
None
self
.
lastFailure
=
None
self
.
descriptions
=
descriptions
self
.
descriptions
=
descriptions
def
startTest
(
self
,
test
):
def
startTest
(
self
,
test
):
TestResult
.
startTest
(
self
,
test
)
TestResult
.
startTest
(
self
,
test
)
if
self
.
descriptions
:
if
self
.
descriptions
:
...
@@ -608,7 +608,7 @@ class _VerboseTextTestResult(TestResult):
...
@@ -608,7 +608,7 @@ class _VerboseTextTestResult(TestResult):
class
VerboseTextTestRunner
:
class
VerboseTextTestRunner
:
"""A test runner class that displays results in textual form.
"""A test runner class that displays results in textual form.
It prints out the names of tests as they are run, errors as they
It prints out the names of tests as they are run, errors as they
occur, and a summary of the results at the end of the test run.
occur, and a summary of the results at the end of the test run.
"""
"""
...
@@ -640,7 +640,7 @@ class VerboseTextTestRunner:
...
@@ -640,7 +640,7 @@ class VerboseTextTestRunner:
else
:
else
:
self
.
stream
.
writeln
(
"OK"
)
self
.
stream
.
writeln
(
"OK"
)
return
result
return
result
# Which flavour of TextTestRunner is the default?
# Which flavour of TextTestRunner is the default?
TextTestRunner
=
VerboseTextTestRunner
TextTestRunner
=
VerboseTextTestRunner
...
@@ -717,7 +717,7 @@ Examples:
...
@@ -717,7 +717,7 @@ Examples:
if
self
.
testRunner
is
None
:
if
self
.
testRunner
is
None
:
self
.
testRunner
=
TextTestRunner
()
self
.
testRunner
=
TextTestRunner
()
result
=
self
.
testRunner
.
run
(
self
.
test
)
result
=
self
.
testRunner
.
run
(
self
.
test
)
sys
.
exit
(
not
result
.
wasSuccessful
())
sys
.
exit
(
not
result
.
wasSuccessful
())
main
=
TestProgram
main
=
TestProgram
...
...
lib/python/Products/ZCatalog/tests/testCatalog.py
View file @
2639fcb7
...
@@ -109,13 +109,13 @@ class TestAddDelIndexes(CatalogBase, unittest.TestCase):
...
@@ -109,13 +109,13 @@ class TestAddDelIndexes(CatalogBase, unittest.TestCase):
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
self
.
_catalog
.
delIndex
(
'id'
)
self
.
_catalog
.
delIndex
(
'id'
)
assert
self
.
_catalog
.
indexes
.
has_key
(
'id'
)
!=
1
,
'del index failed'
assert
self
.
_catalog
.
indexes
.
has_key
(
'id'
)
!=
1
,
'del index failed'
def
testDelTextIndex
(
self
):
def
testDelTextIndex
(
self
):
idx
=
TextIndex
(
'id'
)
idx
=
TextIndex
(
'id'
)
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
self
.
_catalog
.
delIndex
(
'id'
)
self
.
_catalog
.
delIndex
(
'id'
)
assert
self
.
_catalog
.
indexes
.
has_key
(
'id'
)
!=
1
,
'del index failed'
assert
self
.
_catalog
.
indexes
.
has_key
(
'id'
)
!=
1
,
'del index failed'
def
testDelKeywordIndex
(
self
):
def
testDelKeywordIndex
(
self
):
idx
=
KeywordIndex
(
'id'
)
idx
=
KeywordIndex
(
'id'
)
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
self
.
_catalog
.
addIndex
(
'id'
,
idx
)
...
@@ -138,7 +138,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -138,7 +138,7 @@ class TestCatalogObject(unittest.TestCase):
self
.
_catalog
.
addIndex
(
'col1'
,
col1
)
self
.
_catalog
.
addIndex
(
'col1'
,
col1
)
self
.
_catalog
.
addIndex
(
'col2'
,
col2
)
self
.
_catalog
.
addIndex
(
'col2'
,
col2
)
self
.
_catalog
.
addIndex
(
'col3'
,
col3
)
self
.
_catalog
.
addIndex
(
'col3'
,
col3
)
self
.
_catalog
.
addColumn
(
'col1'
)
self
.
_catalog
.
addColumn
(
'col1'
)
self
.
_catalog
.
addColumn
(
'col2'
)
self
.
_catalog
.
addColumn
(
'col2'
)
self
.
_catalog
.
addColumn
(
'col3'
)
self
.
_catalog
.
addColumn
(
'col3'
)
...
@@ -146,12 +146,12 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -146,12 +146,12 @@ class TestCatalogObject(unittest.TestCase):
att2
=
TextIndex
(
'att2'
)
att2
=
TextIndex
(
'att2'
)
att3
=
KeywordIndex
(
'att3'
)
att3
=
KeywordIndex
(
'att3'
)
num
=
FieldIndex
(
'num'
)
num
=
FieldIndex
(
'num'
)
self
.
_catalog
.
addIndex
(
'att1'
,
att1
)
self
.
_catalog
.
addIndex
(
'att1'
,
att1
)
self
.
_catalog
.
addIndex
(
'att2'
,
att2
)
self
.
_catalog
.
addIndex
(
'att2'
,
att2
)
self
.
_catalog
.
addIndex
(
'att3'
,
att3
)
self
.
_catalog
.
addIndex
(
'att3'
,
att3
)
self
.
_catalog
.
addIndex
(
'num'
,
num
)
self
.
_catalog
.
addIndex
(
'num'
,
num
)
self
.
_catalog
.
addColumn
(
'att1'
)
self
.
_catalog
.
addColumn
(
'att1'
)
self
.
_catalog
.
addColumn
(
'att2'
)
self
.
_catalog
.
addColumn
(
'att2'
)
self
.
_catalog
.
addColumn
(
'att3'
)
self
.
_catalog
.
addColumn
(
'att3'
)
self
.
_catalog
.
addColumn
(
'num'
)
self
.
_catalog
.
addColumn
(
'num'
)
...
@@ -163,7 +163,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -163,7 +163,7 @@ class TestCatalogObject(unittest.TestCase):
att3
=
[
'att3'
]
att3
=
[
'att3'
]
def
__init__
(
self
,
num
):
def
__init__
(
self
,
num
):
self
.
num
=
num
self
.
num
=
num
def
col1
(
self
):
def
col1
(
self
):
return
'col1'
return
'col1'
...
@@ -173,7 +173,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -173,7 +173,7 @@ class TestCatalogObject(unittest.TestCase):
def
col3
(
self
):
def
col3
(
self
):
return
[
'col3'
]
return
[
'col3'
]
for
x
in
range
(
0
,
self
.
upper
):
for
x
in
range
(
0
,
self
.
upper
):
self
.
_catalog
.
catalogObject
(
dummy
(
x
),
`x`
)
self
.
_catalog
.
catalogObject
(
dummy
(
x
),
`x`
)
self
.
_catalog
.
aq_parent
=
dummy
(
'foo'
)
# fake out acquisition
self
.
_catalog
.
aq_parent
=
dummy
(
'foo'
)
# fake out acquisition
...
@@ -208,11 +208,11 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -208,11 +208,11 @@ class TestCatalogObject(unittest.TestCase):
assert
len
(
a
)
==
self
.
upper
,
'should be %s, but is %s'
%
(
self
.
upper
,
assert
len
(
a
)
==
self
.
upper
,
'should be %s, but is %s'
%
(
self
.
upper
,
len
(
a
))
len
(
a
))
def
testUncatalogFieldIndex
(
self
):
def
testUncatalogFieldIndex
(
self
):
self
.
uncatalog
()
self
.
uncatalog
()
a
=
self
.
_catalog
(
att1
=
'att1'
)
a
=
self
.
_catalog
(
att1
=
'att1'
)
assert
len
(
a
)
==
0
,
'len: %s'
%
(
len
(
a
))
assert
len
(
a
)
==
0
,
'len: %s'
%
(
len
(
a
))
def
testUncatalogTextIndex
(
self
):
def
testUncatalogTextIndex
(
self
):
self
.
uncatalog
()
self
.
uncatalog
()
a
=
self
.
_catalog
(
att2
=
'att2'
)
a
=
self
.
_catalog
(
att2
=
'att2'
)
...
@@ -259,7 +259,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -259,7 +259,7 @@ class TestCatalogObject(unittest.TestCase):
assert
len
(
a
)
==
upper
,
'length should be %s, its %s'
%
(
upper
,
len
(
a
))
assert
len
(
a
)
==
upper
,
'length should be %s, its %s'
%
(
upper
,
len
(
a
))
for
x
in
range
(
self
.
upper
):
for
x
in
range
(
self
.
upper
):
assert
a
[
x
].
num
==
x
,
x
assert
a
[
x
].
num
==
x
,
x
def
testBadSortIndex
(
self
):
def
testBadSortIndex
(
self
):
self
.
assertRaises
(
CatalogError
,
self
.
badsortindex
)
self
.
assertRaises
(
CatalogError
,
self
.
badsortindex
)
...
@@ -313,7 +313,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -313,7 +313,7 @@ class TestCatalogObject(unittest.TestCase):
# set is much larger than the sort index.
# set is much larger than the sort index.
a
=
self
.
_catalog
(
sort_on
=
'att1'
)
a
=
self
.
_catalog
(
sort_on
=
'att1'
)
self
.
assertEqual
(
len
(
a
),
self
.
upper
)
self
.
assertEqual
(
len
(
a
),
self
.
upper
)
class
objRS
(
ExtensionClass
.
Base
):
class
objRS
(
ExtensionClass
.
Base
):
...
@@ -330,16 +330,16 @@ class testRS(unittest.TestCase):
...
@@ -330,16 +330,16 @@ class testRS(unittest.TestCase):
self
.
_catalog
.
addIndex
(
'number'
,
index
)
self
.
_catalog
.
addIndex
(
'number'
,
index
)
self
.
_catalog
.
addColumn
(
'number'
)
self
.
_catalog
.
addColumn
(
'number'
)
for
i
in
range
(
5000
):
for
i
in
range
(
5000
):
obj
=
objRS
(
whrandom
.
randint
(
0
,
20000
))
obj
=
objRS
(
whrandom
.
randint
(
0
,
20000
))
self
.
_catalog
.
catalogObject
(
obj
,
i
)
self
.
_catalog
.
catalogObject
(
obj
,
i
)
self
.
_catalog
.
aq_parent
=
objRS
(
200
)
self
.
_catalog
.
aq_parent
=
objRS
(
200
)
def
testRangeSearch
(
self
):
def
testRangeSearch
(
self
):
for
i
in
range
(
10000
):
for
i
in
range
(
10000
):
m
=
whrandom
.
randint
(
0
,
20000
)
m
=
whrandom
.
randint
(
0
,
20000
)
n
=
m
+
1000
n
=
m
+
1000
for
r
in
self
.
_catalog
.
searchResults
(
for
r
in
self
.
_catalog
.
searchResults
(
...
...
lib/python/Products/ZGadflyDA/DA.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
database_type
=
'Gadfly'
database_type
=
'Gadfly'
__doc__
=
'''%s Database Connection
__doc__
=
'''%s Database Connection
$Id: DA.py,v 1.1
4 2002/05/27 12:27:25 chrisw
Exp $'''
%
database_type
$Id: DA.py,v 1.1
5 2002/08/14 22:25:17 mj
Exp $'''
%
database_type
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
from
db
import
DB
,
manage_DataSources
from
db
import
DB
,
manage_DataSources
import
sys
,
DABase
,
Globals
import
sys
,
DABase
,
Globals
...
@@ -31,7 +31,7 @@ def manage_addZGadflyConnection(
...
@@ -31,7 +31,7 @@ def manage_addZGadflyConnection(
self
,
id
,
title
,
connection
,
check
=
None
,
REQUEST
=
None
):
self
,
id
,
title
,
connection
,
check
=
None
,
REQUEST
=
None
):
"""Add a DB connection to a folder"""
"""Add a DB connection to a folder"""
# Note - type checking is taken care of by _setObject
# Note - type checking is taken care of by _setObject
# and the Connection object constructor.
# and the Connection object constructor.
self
.
_setObject
(
id
,
Connection
(
self
.
_setObject
(
id
,
Connection
(
id
,
title
,
connection
,
check
))
id
,
title
,
connection
,
check
))
...
@@ -51,13 +51,13 @@ class Connection(DABase.Connection):
...
@@ -51,13 +51,13 @@ class Connection(DABase.Connection):
if
hasattr
(
self
,
'_v_database_connection'
):
if
hasattr
(
self
,
'_v_database_connection'
):
return
self
.
_v_database_connection
.
opened
return
self
.
_v_database_connection
.
opened
return
''
return
''
def
title_and_id
(
self
):
def
title_and_id
(
self
):
s
=
_Connection
.
inheritedAttribute
(
'title_and_id'
)(
self
)
s
=
_Connection
.
inheritedAttribute
(
'title_and_id'
)(
self
)
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
self
.
_v_database_connection
.
opened
):
self
.
_v_database_connection
.
opened
):
s
=
"%s, which is connected"
%
s
s
=
"%s, which is connected"
%
s
else
:
else
:
s
=
"%s, which is <font color=red> not connected</font>"
%
s
s
=
"%s, which is <font color=red> not connected</font>"
%
s
return
s
return
s
...
@@ -66,7 +66,7 @@ class Connection(DABase.Connection):
...
@@ -66,7 +66,7 @@ class Connection(DABase.Connection):
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
self
.
_v_database_connection
.
opened
):
self
.
_v_database_connection
.
opened
):
s
=
"%s (connected)"
%
s
s
=
"%s (connected)"
%
s
else
:
else
:
s
=
"%s (<font color=red> not connected</font>)"
%
s
s
=
"%s (<font color=red> not connected</font>)"
%
s
return
s
return
s
...
@@ -78,7 +78,7 @@ class Connection(DABase.Connection):
...
@@ -78,7 +78,7 @@ class Connection(DABase.Connection):
c
=
self
.
_v_database_connection
=
c
[
s
]
c
=
self
.
_v_database_connection
=
c
[
s
]
if
not
c
.
opened
:
c
.
open
()
if
not
c
.
opened
:
c
.
open
()
return
self
return
self
try
:
try
:
try
:
try
:
self
.
_v_database_connection
=
c
[
s
]
=
DB
(
s
)
self
.
_v_database_connection
=
c
[
s
]
=
DB
(
s
)
...
@@ -90,8 +90,7 @@ class Connection(DABase.Connection):
...
@@ -90,8 +90,7 @@ class Connection(DABase.Connection):
'<!--
\
n
%s
\
n
%s
\
n
-->
\
n
'
'<!--
\
n
%s
\
n
%s
\
n
-->
\
n
'
%
(
s
,
t
,
v
)),
tb
%
(
s
,
t
,
v
)),
tb
finally
:
tb
=
None
finally
:
tb
=
None
return
self
return
self
finally
:
finally
:
_connections_lock
.
release
()
_connections_lock
.
release
()
lib/python/Products/ZGadflyDA/DABase.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Database Connection
__doc__
=
'''Database Connection
$Id: DABase.py,v 1.1
1 2001/11/28 15:51:10 matt
Exp $'''
$Id: DABase.py,v 1.1
2 2002/08/14 22:25:17 mj
Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
from
db
import
manage_DataSources
from
db
import
manage_DataSources
import
Shared.DC.ZRDB.Connection
,
sys
import
Shared.DC.ZRDB.Connection
,
sys
...
@@ -33,7 +33,7 @@ class Connection(Shared.DC.ZRDB.Connection.Connection):
...
@@ -33,7 +33,7 @@ class Connection(Shared.DC.ZRDB.Connection.Connection):
manage_browse
=
HTMLFile
(
'dtml/browse'
,
globals
())
manage_browse
=
HTMLFile
(
'dtml/browse'
,
globals
())
info
=
None
info
=
None
def
tpValues
(
self
):
def
tpValues
(
self
):
#if hasattr(self, '_v_tpValues'): return self._v_tpValues
#if hasattr(self, '_v_tpValues'): return self._v_tpValues
r
=
[]
r
=
[]
...
@@ -104,7 +104,7 @@ class TableBrowser(Browser, Acquisition.Implicit):
...
@@ -104,7 +104,7 @@ class TableBrowser(Browser, Acquisition.Implicit):
b
.
TABLE_NAME
=
tname
b
.
TABLE_NAME
=
tname
r
.
append
(
b
)
r
.
append
(
b
)
return
r
return
r
def
tpId
(
self
):
return
self
.
_d
[
'TABLE_NAME'
]
def
tpId
(
self
):
return
self
.
_d
[
'TABLE_NAME'
]
def
tpURL
(
self
):
return
"Table/%s"
%
self
.
_d
[
'TABLE_NAME'
]
def
tpURL
(
self
):
return
"Table/%s"
%
self
.
_d
[
'TABLE_NAME'
]
def
Name
(
self
):
return
self
.
_d
[
'TABLE_NAME'
]
def
Name
(
self
):
return
self
.
_d
[
'TABLE_NAME'
]
...
@@ -144,8 +144,8 @@ class TableBrowser(Browser, Acquisition.Implicit):
...
@@ -144,8 +144,8 @@ class TableBrowser(Browser, Acquisition.Implicit):
raise
ValueError
,
(
raise
ValueError
,
(
'no default was given for <em>%s</em>'
%
n
)
'no default was given for <em>%s</em>'
%
n
)
class
ColumnBrowser
(
Browser
):
class
ColumnBrowser
(
Browser
):
icon
=
'field'
icon
=
'field'
...
...
lib/python/Products/ZGadflyDA/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Generic Database Adapter Package Registration
__doc__
=
'''Generic Database Adapter Package Registration
$Id: __init__.py,v 1.1
3 2001/11/28 15:51:10 matt
Exp $'''
$Id: __init__.py,v 1.1
4 2002/08/14 22:25:17 mj
Exp $'''
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
import
Globals
,
os
import
Globals
,
os
...
@@ -57,7 +57,7 @@ def manage_addZGadflyConnectionForm(self, REQUEST, *args, **kw):
...
@@ -57,7 +57,7 @@ def manage_addZGadflyConnectionForm(self, REQUEST, *args, **kw):
self
,
self
,
REQUEST
,
self
,
self
,
REQUEST
,
database_type
=
database_type
,
database_type
=
database_type
,
data_sources
=
DA
.
data_sources
)
data_sources
=
DA
.
data_sources
)
def
manage_addZGadflyConnection
(
def
manage_addZGadflyConnection
(
self
,
id
,
title
,
connection
,
check
=
None
,
REQUEST
=
None
):
self
,
id
,
title
,
connection
,
check
=
None
,
REQUEST
=
None
):
" "
" "
...
...
lib/python/Products/ZGadflyDA/db.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
'''$Id: db.py,v 1.1
2 2001/11/28 15:51:10 matt
Exp $'''
'''$Id: db.py,v 1.1
3 2002/08/14 22:25:17 mj
Exp $'''
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
os
import
os
from
string
import
strip
,
split
from
string
import
strip
,
split
...
@@ -23,7 +23,7 @@ from DateTime import DateTime
...
@@ -23,7 +23,7 @@ from DateTime import DateTime
data_dir
=
os
.
path
.
join
(
Globals
.
data_dir
,
'gadfly'
)
data_dir
=
os
.
path
.
join
(
Globals
.
data_dir
,
'gadfly'
)
def
manage_DataSources
():
def
manage_DataSources
():
if
not
os
.
path
.
exists
(
data_dir
):
if
not
os
.
path
.
exists
(
data_dir
):
try
:
try
:
os
.
mkdir
(
data_dir
)
os
.
mkdir
(
data_dir
)
...
@@ -42,7 +42,7 @@ def manage_DataSources():
...
@@ -42,7 +42,7 @@ def manage_DataSources():
existence of the directory, <code>%s</code>. This
existence of the directory, <code>%s</code>. This
exists, but is not a directory.
exists, but is not a directory.
"""
%
data_dir
)
"""
%
data_dir
)
return
map
(
return
map
(
lambda
d
:
(
d
,
''
),
lambda
d
:
(
d
,
''
),
filter
(
lambda
f
,
i
=
os
.
path
.
isdir
,
d
=
data_dir
,
j
=
os
.
path
.
join
:
filter
(
lambda
f
,
i
=
os
.
path
.
isdir
,
d
=
data_dir
,
j
=
os
.
path
.
join
:
...
@@ -112,7 +112,7 @@ class DB(Shared.DC.ZRDB.THUNK.THUNKED_TM):
...
@@ -112,7 +112,7 @@ class DB(Shared.DC.ZRDB.THUNK.THUNKED_TM):
'Multiple incompatible selects in '
'Multiple incompatible selects in '
'multiple sql-statement query'
'multiple sql-statement query'
)
)
if
not
result
:
result
=
c
.
fetchmany
(
max_rows
)
if
not
result
:
result
=
c
.
fetchmany
(
max_rows
)
elif
len
(
result
)
<
max_rows
:
elif
len
(
result
)
<
max_rows
:
result
=
result
+
c
.
fetchmany
(
max_rows
-
len
(
result
))
result
=
result
+
c
.
fetchmany
(
max_rows
-
len
(
result
))
...
@@ -134,7 +134,7 @@ class DB(Shared.DC.ZRDB.THUNK.THUNKED_TM):
...
@@ -134,7 +134,7 @@ class DB(Shared.DC.ZRDB.THUNK.THUNKED_TM):
'null'
:
null_ok
,
'null'
:
null_ok
,
})
})
return
items
,
result
return
items
,
result
# Gadfly needs the extra checkpoint call.
# Gadfly needs the extra checkpoint call.
def
_abort
(
self
):
def
_abort
(
self
):
self
.
db
.
rollback
()
self
.
db
.
rollback
()
...
...
lib/python/Products/ZSQLMethods/SQL.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''SQL Methods
__doc__
=
'''SQL Methods
$Id: SQL.py,v 1.2
0 2001/11/28 15:51:10 matt
Exp $'''
$Id: SQL.py,v 1.2
1 2002/08/14 22:25:18 mj
Exp $'''
__version__
=
'$Revision: 1.2
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
import
Shared.DC.ZRDB.DA
import
Shared.DC.ZRDB.DA
from
Globals
import
DTMLFile
from
Globals
import
DTMLFile
...
@@ -75,7 +75,7 @@ def manage_addZSQLMethod(self, id, title,
...
@@ -75,7 +75,7 @@ def manage_addZSQLMethod(self, id, title,
u
=
"%s/%s/manage_testForm"
%
(
u
,
id
)
u
=
"%s/%s/manage_testForm"
%
(
u
,
id
)
else
:
else
:
u
=
u
+
'/manage_main'
u
=
u
+
'/manage_main'
REQUEST
.
RESPONSE
.
redirect
(
u
)
REQUEST
.
RESPONSE
.
redirect
(
u
)
return
''
return
''
...
@@ -102,7 +102,7 @@ class SQL(Shared.DC.ZRDB.DA.DA):
...
@@ -102,7 +102,7 @@ class SQL(Shared.DC.ZRDB.DA.DA):
and result data.
and result data.
For more information, see the searchable-object interface
For more information, see the searchable-object interface
specification.
specification.
- Containment
- Containment
...
@@ -119,7 +119,7 @@ class SQL(Shared.DC.ZRDB.DA.DA):
...
@@ -119,7 +119,7 @@ class SQL(Shared.DC.ZRDB.DA.DA):
"""
"""
__implements__
=
(
WriteLockInterface
,)
__implements__
=
(
WriteLockInterface
,)
meta_type
=
'Z SQL Method'
meta_type
=
'Z SQL Method'
manage
=
manage_main
=
DTMLFile
(
'dtml/edit'
,
globals
())
manage
=
manage_main
=
DTMLFile
(
'dtml/edit'
,
globals
())
manage_main
.
_setName
(
'manage_main'
)
manage_main
.
_setName
(
'manage_main'
)
...
...
lib/python/Products/ZSQLMethods/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''SQL Method Product
__doc__
=
'''SQL Method Product
$Id: __init__.py,v 1.1
7 2001/11/28 15:51:10 matt
Exp $'''
$Id: __init__.py,v 1.1
8 2002/08/14 22:25:18 mj
Exp $'''
__version__
=
'$Revision: 1.1
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
import
Shared.DC.ZRDB.Search
,
Shared
.
DC
.
ZRDB
.
Aqueduct
,
SQL
import
Shared.DC.ZRDB.Search
,
Shared
.
DC
.
ZRDB
.
Aqueduct
,
SQL
import
Shared.DC.ZRDB.RDB
import
Shared.DC.ZRDB.RDB
import
Shared.DC.ZRDB.sqlvar
,
Shared
.
DC
.
ZRDB
.
sqlgroup
,
Shared
.
DC
.
ZRDB
.
sqltest
import
Shared.DC.ZRDB.sqlvar
,
Shared
.
DC
.
ZRDB
.
sqlgroup
,
Shared
.
DC
.
ZRDB
.
sqltest
...
...
lib/python/Products/ZSQLMethods/help/ZSQLMethod.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
def
manage_addZSQLMethod
(
id
,
title
,
def
manage_addZSQLMethod
(
id
,
title
,
...
@@ -26,7 +26,7 @@ def manage_addZSQLMethod(id, title,
...
@@ -26,7 +26,7 @@ def manage_addZSQLMethod(id, title,
The 'template' argument is a string containing the source for the
The 'template' argument is a string containing the source for the
SQL Template.
SQL Template.
"""
"""
...
@@ -47,7 +47,7 @@ class ZSQLMethod:
...
@@ -47,7 +47,7 @@ class ZSQLMethod:
and result data.
and result data.
For more information, see the searchable-object interface
For more information, see the searchable-object interface
specification.
specification.
Database methods support URL traversal to access and invoke
Database methods support URL traversal to access and invoke
methods on individual record objects. For example, suppose you
methods on individual record objects. For example, suppose you
...
@@ -81,7 +81,7 @@ class ZSQLMethod:
...
@@ -81,7 +81,7 @@ class ZSQLMethod:
The returned value is a sequence of record objects.
The returned value is a sequence of record objects.
"""
"""
def
manage_edit
(
title
,
connection_id
,
arguments
,
template
):
def
manage_edit
(
title
,
connection_id
,
arguments
,
template
):
"""
"""
...
@@ -100,15 +100,3 @@ class ZSQLMethod:
...
@@ -100,15 +100,3 @@ class ZSQLMethod:
the SQL Template.
the SQL Template.
"""
"""
lib/python/Products/ZopeTutorial/TutorialTopic.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
OFS.Folder
import
OFS.Folder
from
HelpSys.HelpTopic
import
TextTopic
from
HelpSys.HelpTopic
import
TextTopic
...
@@ -32,7 +32,7 @@ class TutorialTopic(TextTopic):
...
@@ -32,7 +32,7 @@ class TutorialTopic(TextTopic):
self
.
title
=
title
self
.
title
=
title
text
=
str
(
StructuredText
.
HTML
(
text
))
text
=
str
(
StructuredText
.
HTML
(
text
))
self
.
obj
=
HTML
(
pre_pat
.
sub
(
clean_pre
,
text
))
self
.
obj
=
HTML
(
pre_pat
.
sub
(
clean_pre
,
text
))
index_html
=
DTMLFile
(
'dtml/lessonView'
,
globals
())
index_html
=
DTMLFile
(
'dtml/lessonView'
,
globals
())
def
checkInstallation
(
self
,
REQUEST
):
def
checkInstallation
(
self
,
REQUEST
):
...
@@ -56,7 +56,7 @@ class TutorialTopic(TextTopic):
...
@@ -56,7 +56,7 @@ class TutorialTopic(TextTopic):
if
not
ok
:
if
not
ok
:
REQUEST
.
set
(
'hide_next'
,
1
)
REQUEST
.
set
(
'hide_next'
,
1
)
return
ok
return
ok
def
lessonURL
(
self
,
id
,
REQUEST
):
def
lessonURL
(
self
,
id
,
REQUEST
):
"""
"""
URL of the examples for a lesson
URL of the examples for a lesson
...
@@ -65,7 +65,7 @@ class TutorialTopic(TextTopic):
...
@@ -65,7 +65,7 @@ class TutorialTopic(TextTopic):
return
'%s/lesson%d'
%
(
REQUEST
[
'tutorialExamplesURL'
],
id
)
return
'%s/lesson%d'
%
(
REQUEST
[
'tutorialExamplesURL'
],
id
)
except
KeyError
:
except
KeyError
:
return
""
return
""
def
tutorialShowLesson
(
self
,
id
,
REQUEST
):
def
tutorialShowLesson
(
self
,
id
,
REQUEST
):
"""
"""
Navigate management frame to a given lesson's screen.
Navigate management frame to a given lesson's screen.
...
@@ -87,7 +87,7 @@ follow along manually, or reinstall the tutorial examples.
...
@@ -87,7 +87,7 @@ follow along manually, or reinstall the tutorial examples.
Note: make sure that you have cookies turned on in your browser.
Note: make sure that you have cookies turned on in your browser.
</p>
</p>
"""
"""
return
"""
\
return
"""
\
<SCRIPT LANGUAGE="javascript">
<SCRIPT LANGUAGE="javascript">
<!--
<!--
...
@@ -115,7 +115,7 @@ class GlossaryTopic(TutorialTopic):
...
@@ -115,7 +115,7 @@ class GlossaryTopic(TutorialTopic):
self
.
obj
=
HTML
(
text
)
self
.
obj
=
HTML
(
text
)
index_html
=
DTMLFile
(
'dtml/glossaryView'
,
globals
())
index_html
=
DTMLFile
(
'dtml/glossaryView'
,
globals
())
def
formatted_content
(
self
,
REQUEST
):
def
formatted_content
(
self
,
REQUEST
):
"""
"""
Custom stx formatting for tutorial topics
Custom stx formatting for tutorial topics
...
@@ -168,11 +168,11 @@ def addTutorial(self, id, REQUEST=None, RESPONSE=None):
...
@@ -168,11 +168,11 @@ def addTutorial(self, id, REQUEST=None, RESPONSE=None):
except
:
except
:
folder
.
_p_jar
=
self
.
Destination
().
_p_jar
folder
.
_p_jar
=
self
.
Destination
().
_p_jar
folder
.
manage_importObject
(
tutorialExamplesFile
)
folder
.
manage_importObject
(
tutorialExamplesFile
)
# acquire REQUEST if necessary
# acquire REQUEST if necessary
if
REQUEST
is
None
:
if
REQUEST
is
None
:
REQUEST
=
self
.
REQUEST
REQUEST
=
self
.
REQUEST
# Set local roles on examples
# Set local roles on examples
changeOwner
(
folder
,
REQUEST
[
'AUTHENTICATED_USER'
])
changeOwner
(
folder
,
REQUEST
[
'AUTHENTICATED_USER'
])
...
@@ -197,11 +197,11 @@ def changeOwner(obj, owner):
...
@@ -197,11 +197,11 @@ def changeOwner(obj, owner):
for
user
,
roles
in
obj
.
get_local_roles
():
for
user
,
roles
in
obj
.
get_local_roles
():
if
'Owner'
in
roles
:
if
'Owner'
in
roles
:
obj
.
manage_delLocalRoles
([
user
])
obj
.
manage_delLocalRoles
([
user
])
break
break
obj
.
manage_setLocalRoles
(
owner
.
getUserName
(),
[
'Owner'
])
obj
.
manage_setLocalRoles
(
owner
.
getUserName
(),
[
'Owner'
])
for
subobj
in
obj
.
objectValues
():
for
subobj
in
obj
.
objectValues
():
changeOwner
(
subobj
,
owner
)
changeOwner
(
subobj
,
owner
)
def
clean_pre
(
match
):
def
clean_pre
(
match
):
"""
"""
Reformat a pre tag to get rid of extra indentation
Reformat a pre tag to get rid of extra indentation
...
@@ -215,20 +215,20 @@ def clean_pre(match):
...
@@ -215,20 +215,20 @@ def clean_pre(match):
indent
=
len
(
line
)
-
len
(
line
.
lstrip
())
indent
=
len
(
line
)
-
len
(
line
.
lstrip
())
if
min_indent
is
None
or
indent
<
min_indent
:
if
min_indent
is
None
or
indent
<
min_indent
:
if
line
.
strip
():
if
line
.
strip
():
min_indent
=
indent
min_indent
=
indent
for
line
in
lines
:
for
line
in
lines
:
nlines
.
append
(
line
[
min_indent
:])
nlines
.
append
(
line
[
min_indent
:])
while
1
:
while
1
:
if
not
nlines
[
0
].
strip
():
if
not
nlines
[
0
].
strip
():
nlines
.
pop
(
0
)
nlines
.
pop
(
0
)
else
:
else
:
break
break
while
1
:
while
1
:
if
not
nlines
[
-
1
].
strip
():
if
not
nlines
[
-
1
].
strip
():
nlines
.
pop
()
nlines
.
pop
()
else
:
else
:
break
break
return
"<PRE>%s</PRE>"
%
'
\
n
'
.
join
(
nlines
)
return
"<PRE>%s</PRE>"
%
'
\
n
'
.
join
(
nlines
)
lib/python/Products/ZopeTutorial/__init__.py
View file @
2639fcb7
##############################################################################
##############################################################################
#
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
TutorialTopic
import
TutorialTopic
import
App.Common
import
App.Common
...
@@ -41,15 +41,15 @@ def initialize(context):
...
@@ -41,15 +41,15 @@ def initialize(context):
help
.
lastRegistered
>=
DateTime
(
os
.
stat
(
lesson_path
)[
stat
.
ST_MTIME
]):
help
.
lastRegistered
>=
DateTime
(
os
.
stat
(
lesson_path
)[
stat
.
ST_MTIME
]):
return
return
help
.
lastRegistered
=
DateTime
()
help
.
lastRegistered
=
DateTime
()
# delete old help topics
# delete old help topics
for
id
in
help
.
objectIds
(
'Help Topic'
):
for
id
in
help
.
objectIds
(
'Help Topic'
):
help
.
_delObject
(
id
)
help
.
_delObject
(
id
)
# create glossary
# create glossary
text
=
open
(
glossary_path
).
read
()
text
=
open
(
glossary_path
).
read
()
text
=
term_pat
.
sub
(
defineTerm
,
text
)
text
=
term_pat
.
sub
(
defineTerm
,
text
)
glossary
=
TutorialTopic
.
GlossaryTopic
(
'tutorialGlossary'
,
glossary
=
TutorialTopic
.
GlossaryTopic
(
'tutorialGlossary'
,
'Zope Tutorial Glossary'
,
text
)
'Zope Tutorial Glossary'
,
text
)
context
.
registerHelpTopic
(
'tutorialGlossary'
,
glossary
)
context
.
registerHelpTopic
(
'tutorialGlossary'
,
glossary
)
...
@@ -58,7 +58,7 @@ def initialize(context):
...
@@ -58,7 +58,7 @@ def initialize(context):
f
=
open
(
lesson_path
)
f
=
open
(
lesson_path
)
lines
=
[]
lines
=
[]
id
=
0
id
=
0
while
1
:
while
1
:
line
=
f
.
readline
()
line
=
f
.
readline
()
if
(
line
.
strip
()
and
line
.
find
(
' '
)
!=
0
)
or
line
==
''
:
if
(
line
.
strip
()
and
line
.
find
(
' '
)
!=
0
)
or
line
==
''
:
...
@@ -69,7 +69,7 @@ def initialize(context):
...
@@ -69,7 +69,7 @@ def initialize(context):
text
=
''
.
join
(
lines
[
1
:])
text
=
''
.
join
(
lines
[
1
:])
text
=
term_pat
.
sub
(
glossaryTerm
,
text
)
text
=
term_pat
.
sub
(
glossaryTerm
,
text
)
topic
=
TutorialTopic
.
TutorialTopic
(
topic_id
,
lines
[
0
].
strip
(),
spacestrip
(
text
))
topic
=
TutorialTopic
.
TutorialTopic
(
topic_id
,
lines
[
0
].
strip
(),
spacestrip
(
text
))
context
.
registerHelpTopic
(
topic_id
,
topic
)
context
.
registerHelpTopic
(
topic_id
,
topic
)
lines
=
[
line
]
lines
=
[
line
]
else
:
else
:
lines
.
append
(
line
)
lines
.
append
(
line
)
...
@@ -81,12 +81,12 @@ def initialize(context):
...
@@ -81,12 +81,12 @@ def initialize(context):
def
spacestrip
(
txt
):
def
spacestrip
(
txt
):
""" dedent text by 2 spaces !
""" dedent text by 2 spaces !
We need this to workaround a nasty bug in STXNG.
We need this to workaround a nasty bug in STXNG.
STXNG creates empty <pre>..</pre> when then text start
STXNG creates empty <pre>..</pre> when then text start
if a level > 1. This fix is lame. The problem should be fixed
if a level > 1. This fix is lame. The problem should be fixed
inside STXNG
inside STXNG
"""
"""
l
=
[]
l
=
[]
for
x
in
txt
.
split
(
"
\
n
"
):
for
x
in
txt
.
split
(
"
\
n
"
):
if
len
(
x
)
>
2
and
x
[:
2
]
==
' '
:
if
len
(
x
)
>
2
and
x
[:
2
]
==
' '
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment