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
4be8d559
Commit
4be8d559
authored
Feb 07, 2002
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced string module calls by string methods
parent
f84b5394
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
89 additions
and
104 deletions
+89
-104
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+4
-5
lib/python/OFS/Cache.py
lib/python/OFS/Cache.py
+3
-4
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+2
-2
lib/python/OFS/DTMLDocument.py
lib/python/OFS/DTMLDocument.py
+1
-2
lib/python/OFS/DTMLMethod.py
lib/python/OFS/DTMLMethod.py
+6
-8
lib/python/OFS/DefaultObservable.py
lib/python/OFS/DefaultObservable.py
+3
-4
lib/python/OFS/FindSupport.py
lib/python/OFS/FindSupport.py
+6
-6
lib/python/OFS/History.py
lib/python/OFS/History.py
+13
-13
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+9
-9
lib/python/OFS/Moniker.py
lib/python/OFS/Moniker.py
+1
-2
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+3
-3
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+1
-2
lib/python/OFS/PropertySheets.py
lib/python/OFS/PropertySheets.py
+18
-20
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+5
-6
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+5
-6
lib/python/OFS/Uninstalled.py
lib/python/OFS/Uninstalled.py
+2
-2
lib/python/OFS/XMLExportImport.py
lib/python/OFS/XMLExportImport.py
+2
-2
lib/python/OFS/ZDOM.py
lib/python/OFS/ZDOM.py
+1
-2
lib/python/OFS/content_types.py
lib/python/OFS/content_types.py
+3
-4
lib/python/OFS/ndiff.py
lib/python/OFS/ndiff.py
+1
-2
No files found.
lib/python/OFS/Application.py
View file @
4be8d559
...
...
@@ -12,12 +12,11 @@
##############################################################################
__doc__
=
'''Application support
$Id: Application.py,v 1.1
79 2002/01/09 19:14:03
andreasjung Exp $'''
__version__
=
'$Revision: 1.1
79
$'
[
11
:
-
2
]
$Id: Application.py,v 1.1
80 2002/02/07 17:20:59
andreasjung Exp $'''
__version__
=
'$Revision: 1.1
80
$'
[
11
:
-
2
]
import
Globals
,
Folder
,
os
,
sys
,
App
.
Product
,
App
.
ProductRegistry
,
misc_
import
time
,
traceback
,
os
,
string
,
Products
from
string
import
strip
,
lower
,
find
,
rfind
,
join
import
time
,
traceback
,
os
,
Products
from
DateTime
import
DateTime
from
AccessControl.User
import
UserFolder
from
App.ApplicationManager
import
ApplicationManager
...
...
@@ -83,7 +82,7 @@ class Application(Globals.ApplicationDefaultPermissions,
def
PrincipiaRedirect
(
self
,
destination
,
URL1
):
"""Utility function to allow user-controlled redirects"""
if
find
(
destination
,
'//'
)
>=
0
:
raise
'Redirect'
,
destination
if
destination
.
find
(
'//'
)
>=
0
:
raise
'Redirect'
,
destination
raise
'Redirect'
,
(
"%s/%s"
%
(
URL1
,
destination
))
Redirect
=
ZopeRedirect
=
PrincipiaRedirect
...
...
lib/python/OFS/Cache.py
View file @
4be8d559
...
...
@@ -12,12 +12,11 @@
##############################################################################
__doc__
=
"""Cacheable object and cache management base classes.
$Id: Cache.py,v 1.
8 2001/11/28 15:50:57 matt
Exp $"""
$Id: Cache.py,v 1.
9 2002/02/07 17:20:59 andreasjung
Exp $"""
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
time
,
sys
from
string
import
join
import
Globals
from
Globals
import
DTMLFile
from
Acquisition
import
aq_get
,
aq_acquire
,
aq_inner
,
aq_parent
,
aq_base
...
...
@@ -373,7 +372,7 @@ def findCacheables(ob, manager_id, require_assoc, subfolders,
icon
=
getattr
(
aq_base
(
subob
),
'icon'
,
''
)
info
=
{
'sortkey'
:
subpath
,
'path'
:
join
(
subpath
,
'/'
),
'path'
:
'/'
.
join
(
subpath
),
'title'
:
getattr
(
aq_base
(
subob
),
'title'
,
''
),
'icon'
:
icon
,
'associated'
:
associated
,}
...
...
lib/python/OFS/CopySupport.py
View file @
4be8d559
...
...
@@ -11,9 +11,9 @@
#
##############################################################################
__doc__
=
"""Copy interface"""
__version__
=
'$Revision: 1.7
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.7
8
$'
[
11
:
-
2
]
import
sys
,
string
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
import
sys
,
Globals
,
Moniker
,
tempfile
,
ExtensionClass
from
marshal
import
loads
,
dumps
from
urllib
import
quote
,
unquote
from
zlib
import
compress
,
decompress
...
...
lib/python/OFS/DTMLDocument.py
View file @
4be8d559
...
...
@@ -12,7 +12,7 @@
##############################################################################
"""DTML Document objects."""
__version__
=
'$Revision: 1.4
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
6
$'
[
11
:
-
2
]
from
ZPublisher.Converters
import
type_converters
from
Globals
import
HTML
,
DTMLFile
,
MessageDialog
...
...
@@ -23,7 +23,6 @@ from webdav.common import rfc1123_date
from
webdav.Lockable
import
ResourceLockedError
from
webdav.WriteLockInterface
import
WriteLockInterface
from
sgmllib
import
SGMLParser
from
string
import
find
from
urllib
import
quote
import
Globals
from
AccessControl
import
getSecurityManager
...
...
lib/python/OFS/DTMLMethod.py
View file @
4be8d559
...
...
@@ -12,11 +12,10 @@
##############################################################################
"""DTML Method objects."""
__version__
=
'$Revision: 1.7
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.7
4
$'
[
11
:
-
2
]
import
History
from
Globals
import
HTML
,
DTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
from
SimpleItem
import
Item_w__name__
,
pretty_tb
from
OFS.content_types
import
guess_content_type
from
PropertyManager
import
PropertyManager
...
...
@@ -188,7 +187,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
'''
ks
=
[]
for
key
in
keys
:
key
=
str
ip
(
str
(
key
)
)
key
=
str
(
key
).
strip
(
)
if
key
:
ks
.
append
(
key
)
self
.
_cache_namespace_keys
=
tuple
(
ks
)
...
...
@@ -222,8 +221,8 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
def
_er
(
self
,
data
,
title
,
SUBMIT
,
dtpref_cols
,
dtpref_rows
,
REQUEST
):
dr
,
dc
=
self
.
_size_changes
[
SUBMIT
]
rows
=
max
(
1
,
atoi
(
dtpref_rows
)
+
dr
)
cols
=
max
(
40
,
atoi
(
dtpref_cols
)
+
dc
)
rows
=
max
(
1
,
int
(
dtpref_rows
)
+
dr
)
cols
=
max
(
40
,
int
(
dtpref_cols
)
+
dc
)
e
=
(
DateTime
(
'GMT'
)
+
365
).
rfc822
()
resp
=
REQUEST
[
'RESPONSE'
]
resp
.
setCookie
(
'dtpref_rows'
,
str
(
rows
),
path
=
'/'
,
expires
=
e
)
...
...
@@ -338,7 +337,6 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
))
import
re
from
string
import
find
,
strip
token
=
"[a-zA-Z0-9!#$%&'*+
\
-.
\
\
\
\
^_`|~]+
"
hdr_start = re.compile(r'(%s):(.*)' % token).match
...
...
@@ -355,9 +353,9 @@ def decapitate(html, RESPONSE=None):
headers.append(header)
spos = m.end() + 1
while spos < len(html) and html[spos] in '
\
t
':
eol =
find(html,
'
\
n
', spos)
eol =
html.find(
'
\
n
', spos)
if eol < 0: return html
header.append(
strip(html[spos:eol]
))
header.append(
html[spos:eol].strip(
))
spos = eol + 1
if RESPONSE is not None:
for header in headers:
...
...
lib/python/OFS/DefaultObservable.py
View file @
4be8d559
...
...
@@ -15,11 +15,10 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification)
This class is intended to be used as a mixin (note that it doesn't derive
from any Zope persistence classes, for instance).
$Id: DefaultObservable.py,v 1.
4 2001/11/28 15:50:57 matt
Exp $"""
$Id: DefaultObservable.py,v 1.
5 2002/02/07 17:20:59 andreasjung
Exp $"""
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
string
from
types
import
StringType
class
DefaultObservable
:
...
...
@@ -63,7 +62,7 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
# Assert that observer is a string or a sequence of strings.
if
type
(
observer
)
!=
StringType
:
observer
=
string
.
join
(
observer
,
'/'
)
observer
=
'/'
.
join
(
observer
)
return
observer
...
...
lib/python/OFS/FindSupport.py
View file @
4be8d559
...
...
@@ -11,16 +11,16 @@
#
##############################################################################
__doc__
=
"""Find support"""
__version__
=
'$Revision: 1.2
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
9
$'
[
11
:
-
2
]
import
sys
,
os
,
string
,
time
,
Globals
,
ExtensionClass
import
sys
,
os
,
time
,
Globals
,
ExtensionClass
from
DocumentTemplate.DT_Util
import
Eval
from
AccessControl.Permission
import
name_trans
from
Globals
import
DTMLFile
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DateTime
import
DateTime
from
string
import
find
from
string
import
translate
from
AccessControl.DTML
import
RestrictedDTML
class
FindSupport
(
ExtensionClass
.
Base
):
...
...
@@ -114,7 +114,7 @@ class FindSupport(ExtensionClass.Base):
and
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
find
(
ob
.
PrincipiaSearchSource
(),
obj_searchterm
)
>=
0
ob
.
PrincipiaSearchSource
().
find
(
obj_searchterm
)
>=
0
))
and
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
...
...
@@ -213,7 +213,7 @@ class FindSupport(ExtensionClass.Base):
and
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
find
(
ob
.
PrincipiaSearchSource
(),
obj_searchterm
)
>=
0
ob
.
PrincipiaSearchSource
().
find
(
obj_searchterm
)
>=
0
))
and
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
...
...
@@ -306,6 +306,6 @@ def absattr(attr):
def
p_name
(
name
):
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
return
'_'
+
translate
(
name
,
name_trans
)
+
'_Permission'
lib/python/OFS/History.py
View file @
4be8d559
...
...
@@ -12,12 +12,11 @@
##############################################################################
"""Object Histories"""
__version__
=
'$Revision: 1.1
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
import
Globals
,
ndiff
,
ExtensionClass
from
DateTime
import
DateTime
from
Acquisition
import
Implicit
,
aq_base
from
string
import
join
,
split
,
atoi
,
strip
from
struct
import
pack
,
unpack
from
cgi
import
escape
...
...
@@ -59,7 +58,7 @@ class Historian(Implicit):
def
__getitem__
(
self
,
key
):
self
=
self
.
aq_parent
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
atoi
,
split
(
key
,
'.'
))))
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
int
,
key
.
split
(
'.'
))))
if
serial
==
self
.
_p_serial
:
return
self
...
...
@@ -117,7 +116,7 @@ class Historical(ExtensionClass.Base):
for
d
in
r
:
d
[
'time'
]
=
DateTime
(
d
[
'time'
])
d
[
'key'
]
=
join
(
map
(
str
,
unpack
(
">HHHH"
,
d
[
'serial'
])),
'.'
)
d
[
'key'
]
=
'.'
.
join
(
map
(
str
,
unpack
(
">HHHH"
,
d
[
'serial'
]))
)
return
r
...
...
@@ -135,7 +134,7 @@ class Historical(ExtensionClass.Base):
"copied to the present.<p>"
)
key
=
keys
[
0
]
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
atoi
,
split
(
key
,
'.'
))))
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
int
,
key
.
split
(
'.'
))))
if
serial
!=
self
.
_p_serial
:
self
.
manage_beforeHistoryCopy
()
...
...
@@ -175,12 +174,12 @@ class Historical(ExtensionClass.Base):
raise
HistorySelectionError
,
(
"Only two historical revision can be compared<p>"
)
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
atoi
,
split
(
keys
[
-
1
],
'.'
))))
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
int
,
keys
[
-
1
].
split
(
'.'
))))
rev1
=
historicalRevision
(
self
,
serial
)
if
len
(
keys
)
==
2
:
serial
=
apply
(
pack
,
(
'>HHHH'
,)
+
tuple
(
map
(
atoi
,
split
(
keys
[
0
],
'.'
))))
(
'>HHHH'
,)
+
tuple
(
map
(
int
,
keys
[
0
].
split
(
'.'
))))
rev2
=
historicalRevision
(
self
,
serial
)
else
:
...
...
@@ -200,7 +199,7 @@ def dump(tag, x, lo, hi, r):
"<td><pre>
\
n
%s
\
n
</pre></td>
\
n
"
"<td><pre>
\
n
%s
\
n
</pre></td>
\
n
"
"</tr>
\
n
"
%
(
join
(
r1
,
'
\
n
'
),
escape
(
join
(
r2
,
'
\
n
'
))))
%
(
'
\
n
'
.
join
(
r1
),
escape
(
'
\
n
'
.
join
(
r2
))))
def
replace
(
x
,
xlo
,
xhi
,
y
,
ylo
,
yhi
,
r
):
...
...
@@ -221,12 +220,13 @@ def replace(x, xlo, xhi, y, ylo, yhi, r):
"<td><pre>
\
n
%s
\
n
%s
\
n
</pre></td>
\
n
"
"<td><pre>
\
n
%s
\
n
%s
\
n
</pre></td>
\
n
"
"</tr>
\
n
"
%
(
join
(
rx1
,
'
\
n
'
),
join
(
ry1
,
'
\
n
'
),
escape
(
join
(
rx2
,
'
\
n
'
)),
escape
(
join
(
ry2
,
'
\
n
'
))))
%
(
'
\
n
'
.
join
(
rx1
),
'
\
n
'
.
join
(
ry1
),
escape
(
'
\
n
'
.
join
(
rx2
)),
escape
(
'
\
n
'
.
join
(
ry2
))))
def
html_diff
(
s1
,
s2
):
a
=
split
(
s1
,
'
\
n
'
)
b
=
split
(
s2
,
'
\
n
'
)
from
string
import
split
a
=
s1
.
split
(
'
\
n
'
)
b
=
s2
.
split
(
'
\
n
'
)
cruncher
=
ndiff
.
SequenceMatcher
(
isjunk
=
split
,
a
=
a
,
b
=
b
)
r
=
[
'<table border=1>'
]
...
...
@@ -243,4 +243,4 @@ def html_diff(s1, s2):
raise
ValueError
,
'unknown tag '
+
`tag`
r
.
append
(
'</table>'
)
return
join
(
r
,
'
\
n
'
)
return
'
\
n
'
.
join
(
r
)
lib/python/OFS/Image.py
View file @
4be8d559
...
...
@@ -12,9 +12,9 @@
##############################################################################
"""Image object"""
__version__
=
'$Revision: 1.13
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.13
5
$'
[
11
:
-
2
]
import
Globals
,
str
ing
,
str
uct
import
Globals
,
struct
from
OFS.content_types
import
guess_content_type
from
Globals
import
DTMLFile
from
PropertyManager
import
PropertyManager
...
...
@@ -133,7 +133,7 @@ class File(Persistent, Implicit, PropertyManager,
# HTTP If-Modified-Since header handling.
header
=
REQUEST
.
get_header
(
'If-Modified-Since'
,
None
)
if
header
is
not
None
:
header
=
string
.
split
(
header
,
';'
)[
0
]
header
=
header
.
split
(
';'
)[
0
]
# Some proxies seem to send invalid date strings for this
# header. If the date string is not valid, we ignore it
# rather than raise an error to be generally consistent
...
...
@@ -192,7 +192,7 @@ class File(Persistent, Implicit, PropertyManager,
ranges
=
None
else
:
# Date
date
=
string
.
split
(
if_range
,
';'
)[
0
]
date
=
if_range
.
split
(
';'
)[
0
]
try
:
mod_since
=
long
(
DateTime
(
date
).
timeTime
())
except
:
mod_since
=
None
if
mod_since
is
not
None
:
...
...
@@ -745,7 +745,7 @@ class Image(File):
if
width
:
result
=
'%s width="%s"'
%
(
result
,
width
)
if
not
'border'
in
map
(
string
.
lower
,
args
.
keys
())
:
if
not
'border'
in
[
x
.
lower
()
for
x
in
args
.
keys
()]
:
result
=
'%s border="0"'
%
result
if
css_class
is
not
None
:
...
...
@@ -762,9 +762,9 @@ def cookId(id, title, file):
if
not
id
and
hasattr
(
file
,
'filename'
):
filename
=
file
.
filename
title
=
title
or
filename
id
=
filename
[
max
(
string
.
rfind
(
filename
,
'/'
),
string
.
rfind
(
filename
,
'
\
\
'
),
string
.
rfind
(
filename
,
':'
),
id
=
filename
[
max
(
filename
.
rfind
(
'/'
),
filename
.
rfind
(
'
\
\
'
),
filename
.
rfind
(
':'
),
)
+
1
:]
return
id
,
title
...
...
@@ -793,7 +793,7 @@ class Pdata(Persistent, Implicit):
r
.
append
(
self
.
data
)
next
=
self
.
next
return
string
.
join
(
r
,
''
)
return
''
.
join
(
r
)
...
...
lib/python/OFS/Moniker.py
View file @
4be8d559
...
...
@@ -18,11 +18,10 @@
and aquisition relationships via a simple interface.
"""
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
import
Globals
import
string
class
Moniker
:
"""An object moniker is an intelligent reference to a
...
...
lib/python/OFS/ObjectManager.py
View file @
4be8d559
...
...
@@ -12,9 +12,9 @@
##############################################################################
__doc__
=
"""Object Manager
$Id: ObjectManager.py,v 1.14
5 2001/11/28 15:50:57 matt
Exp $"""
$Id: ObjectManager.py,v 1.14
6 2002/02/07 17:20:59 andreasjung
Exp $"""
__version__
=
'$Revision: 1.14
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.14
6
$'
[
11
:
-
2
]
import
App.Management
,
Acquisition
,
Globals
,
CopySupport
,
Products
import
os
,
App
.
FactoryDispatcher
,
re
,
Products
...
...
@@ -31,7 +31,7 @@ import marshal
import
App.Common
from
AccessControl
import
getSecurityManager
from
zLOG
import
LOG
,
ERROR
import
sys
,
string
,
fnmatch
,
copy
import
sys
,
fnmatch
,
copy
import
XMLExportImport
customImporters
=
{
...
...
lib/python/OFS/PropertyManager.py
View file @
4be8d559
...
...
@@ -12,14 +12,13 @@
##############################################################################
"""Property management"""
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
import
ExtensionClass
,
Globals
import
ZDOM
from
PropertySheets
import
DefaultPropertySheets
,
vps
from
ZPublisher.Converters
import
type_converters
from
Globals
import
DTMLFile
,
MessageDialog
from
string
import
find
,
join
,
lower
,
split
from
Acquisition
import
Implicit
,
aq_base
from
Globals
import
Persistent
...
...
lib/python/OFS/PropertySheets.py
View file @
4be8d559
...
...
@@ -12,13 +12,12 @@
##############################################################################
"""Property sheets"""
__version__
=
'$Revision: 1.8
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.8
2
$'
[
11
:
-
2
]
import
time
,
string
,
App
.
Management
,
Globals
import
time
,
App
.
Management
,
Globals
from
webdav.WriteLockInterface
import
WriteLockInterface
from
ZPublisher.Converters
import
type_converters
from
Globals
import
DTMLFile
,
MessageDialog
from
string
import
find
,
join
,
lower
,
split
,
rfind
from
Acquisition
import
Implicit
,
Explicit
from
App.Common
import
rfc1123_date
,
iso8601_date
from
webdav.common
import
urlbase
...
...
@@ -52,7 +51,7 @@ class View(App.Management.Tabs, Base):
else
:
pre
=
r
[
'URL'
]
for
i
in
(
1
,
2
,
3
):
l
=
rfind
(
pre
,
'/'
)
l
=
pre
.
rfind
(
'/'
)
if
l
>=
0
:
pre
=
pre
[:
l
]
pre
=
pre
+
'/'
...
...
@@ -70,10 +69,10 @@ class View(App.Management.Tabs, Base):
return
r
def
tabs_path_info
(
self
,
script
,
path
):
l
=
rfind
(
path
,
'/'
)
l
=
path
.
rfind
(
'/'
)
if
l
>=
0
:
path
=
path
[:
l
]
l
=
rfind
(
path
,
'/'
)
l
=
path
.
rfind
(
'/'
)
if
l
>=
0
:
path
=
path
[:
l
]
return
View
.
inheritedAttribute
(
'tabs_path_info'
)(
self
,
script
,
path
)
...
...
@@ -285,7 +284,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
' %s
\
n
'
\
' </d:responsedescription>
\
n
'
def
dav__allprop
(
self
,
propstat
=
propstat
,
join
=
string
.
join
):
def
dav__allprop
(
self
,
propstat
=
propstat
):
# DAV helper method - return one or more propstat elements
# indicating property names and values for all properties.
result
=
[]
...
...
@@ -294,14 +293,14 @@ class PropertySheet(Traversable, Persistent, Implicit):
value
=
self
.
getProperty
(
name
)
if
type
==
'tokens'
:
value
=
join
(
str
(
value
),
' '
)
value
=
' '
.
join
(
str
(
value
)
)
elif
type
==
'lines'
:
value
=
join
(
str
(
value
),
'
\
n
'
)
value
=
'
\
n
'
.
join
(
str
(
value
)
)
# check for xml property
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
join
(
attrs
,
''
)
attrs
=
''
.
join
(
attrs
)
else
:
# Quote non-xml items here?
attrs
=
''
...
...
@@ -313,24 +312,23 @@ class PropertySheet(Traversable, Persistent, Implicit):
result
.
append
(
prop
)
if
not
result
:
return
''
result
=
join
(
result
,
'
\
n
'
)
result
=
'
\
n
'
.
join
(
result
)
return
propstat
%
(
self
.
xml_namespace
(),
result
,
'200 OK'
,
''
)
def
dav__propnames
(
self
,
propstat
=
propstat
,
join
=
string
.
join
):
def
dav__propnames
(
self
,
propstat
=
propstat
):
# DAV helper method - return a propstat element indicating
# property names for all properties in this PropertySheet.
result
=
[]
for
name
in
self
.
propertyIds
():
result
.
append
(
' <n:%s/>'
%
name
)
if
not
result
:
return
''
result
=
join
(
result
,
'
\
n
'
)
result
=
'
\
n
'
.
join
(
result
)
return
propstat
%
(
self
.
xml_namespace
(),
result
,
'200 OK'
,
''
)
def
dav__propstat
(
self
,
name
,
result
,
propstat
=
propstat
,
propdesc
=
propdesc
,
join
=
string
.
join
):
propstat
=
propstat
,
propdesc
=
propdesc
):
# DAV helper method - return a propstat element indicating
# property name and value for the requested property.
xml_id
=
self
.
xml_namespace
()
...
...
@@ -347,14 +345,14 @@ class PropertySheet(Traversable, Persistent, Implicit):
name
,
type
=
item
[
'id'
],
item
.
get
(
'type'
,
'string'
)
value
=
self
.
getProperty
(
name
)
if
type
==
'tokens'
:
value
=
join
(
str
(
value
),
' '
)
value
=
' '
.
join
(
str
(
value
)
)
elif
type
==
'lines'
:
value
=
join
(
str
(
value
),
'
\
n
'
)
value
=
'
\
n
'
.
join
(
str
(
value
)
)
# allow for xml properties
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
join
(
attrs
,
''
)
attrs
=
''
.
join
(
attrs
)
else
:
# quote non-xml items here?
attrs
=
''
...
...
@@ -664,7 +662,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
else
:
pre
=
r
[
'URL'
]
for
i
in
(
1
,
2
):
l
=
rfind
(
pre
,
'/'
)
l
=
pre
.
rfind
(
'/'
)
if
l
>=
0
:
pre
=
pre
[:
l
]
pre
=
pre
+
'/'
...
...
@@ -675,7 +673,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
return
r
def
tabs_path_info
(
self
,
script
,
path
):
l
=
rfind
(
path
,
'/'
)
l
=
path
.
rfind
(
'/'
)
if
l
>=
0
:
path
=
path
[:
l
]
return
PropertySheets
.
inheritedAttribute
(
'tabs_path_info'
)(
self
,
script
,
path
)
...
...
lib/python/OFS/SimpleItem.py
View file @
4be8d559
...
...
@@ -17,15 +17,14 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.9
2 2001/11/28 15:50:57 matt
Exp $'''
__version__
=
'$Revision: 1.9
2
$'
[
11
:
-
2
]
$Id: SimpleItem.py,v 1.9
3 2002/02/07 17:20:59 andreasjung
Exp $'''
__version__
=
'$Revision: 1.9
3
$'
[
11
:
-
2
]
import
re
,
sys
,
Globals
,
App
.
Management
,
Acquisition
,
App
.
Undo
import
AccessControl.Role
,
AccessControl
.
Owned
,
App
.
Common
from
webdav.Resource
import
Resource
from
ExtensionClass
import
Base
from
CopySupport
import
CopySource
from
string
import
join
,
lower
,
find
,
split
from
types
import
InstanceType
,
StringType
from
ComputedAttribute
import
ComputedAttribute
from
AccessControl
import
getSecurityManager
...
...
@@ -162,7 +161,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
raise
error_type
,
error_value
,
tb
self
.
_v_eek
=
1
if
lower
(
str
(
error_type
)
)
in
(
'redirect'
,):
if
str
(
error_type
).
lower
(
)
in
(
'redirect'
,):
raise
error_type
,
error_value
,
tb
if
not
error_message
:
...
...
@@ -342,12 +341,12 @@ def format_exception(etype,value,tb,limit=None):
except
:
pass
tb
=
tb
.
tb_next
n
=
n
+
1
result
.
append
(
join
(
traceback
.
format_exception_only
(
etype
,
value
),
' '
))
result
.
append
(
' '
.
join
(
traceback
.
format_exception_only
(
etype
,
value
)
))
return
result
def
pretty_tb
(
t
,
v
,
tb
):
tb
=
format_exception
(
t
,
v
,
tb
,
200
)
tb
=
join
(
tb
,
'
\
n
'
)
tb
=
'
\
n
'
.
join
(
tb
)
return
tb
class
SimpleItem
(
Item
,
Globals
.
Persistent
,
...
...
lib/python/OFS/Traversable.py
View file @
4be8d559
...
...
@@ -12,14 +12,13 @@
##############################################################################
'''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.1
3 2001/11/28 15:50:57 matt
Exp $'''
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
$Id: Traversable.py,v 1.1
4 2002/02/07 17:20:59 andreasjung
Exp $'''
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
from
Acquisition
import
Acquired
,
aq_inner
,
aq_parent
,
aq_base
from
AccessControl
import
getSecurityManager
from
AccessControl
import
Unauthorized
from
string
import
split
,
join
from
urllib
import
quote
_marker
=
[]
...
...
@@ -44,8 +43,8 @@ class Traversable:
path
=
map
(
quote
,
spp
[
i
:])
if
relative
:
# This is useful for physical path relative to a VirtualRoot
return
join
(
path
,
'/'
)
return
join
([
req
[
'SERVER_URL'
]]
+
req
.
_script
+
path
,
'/'
)
return
'/'
.
join
(
path
)
return
'/'
.
join
([
req
[
'SERVER_URL'
]]
+
req
.
_script
+
path
)
getPhysicalRoot__roles__
=
()
# Private
getPhysicalRoot
=
Acquired
...
...
@@ -75,7 +74,7 @@ class Traversable:
N
=
None
M
=
_marker
if
type
(
path
)
is
StringType
:
path
=
split
(
path
,
'/'
)
if
type
(
path
)
is
StringType
:
path
=
path
.
split
(
'/'
)
else
:
path
=
list
(
path
)
REQUEST
=
{
'TraversalRequestNameStack'
:
path
}
...
...
lib/python/OFS/Uninstalled.py
View file @
4be8d559
...
...
@@ -13,7 +13,7 @@
"""
Objects for packages that have been uninstalled.
"""
import
string
,
SimpleItem
,
Globals
,
Acquisition
import
SimpleItem
,
Globals
,
Acquisition
from
Acquisition
import
Acquired
import
Persistence
from
thread
import
allocate_lock
...
...
@@ -59,7 +59,7 @@ def Broken(self, oid, pair):
exec
(
"class %s(BrokenClass): ' '; __module__=%s"
%
(
klassname
,
`module`
))
in
d
klass
=
broken_klasses
[
pair
]
=
d
[
klassname
]
module
=
string
.
split
(
module
,
'.'
)
module
=
module
.
split
(
'.'
)
if
len
(
module
)
>
2
and
module
[
0
]
==
'Products'
:
klass
.
product_name
=
module
[
1
]
klass
.
title
=
(
...
...
lib/python/OFS/XMLExportImport.py
View file @
4be8d559
...
...
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
Shared.DC.xml.ppml
,
string
import
Shared.DC.xml.ppml
ppml
=
Shared
.
DC
.
xml
.
ppml
from
base64
import
encodestring
from
cStringIO
import
StringIO
...
...
@@ -89,7 +89,7 @@ def save_record(parser, tag, data):
file
.
seek
(
pos
)
a
=
data
[
1
]
if
a
.
has_key
(
'id'
):
oid
=
a
[
'id'
]
oid
=
ppml
.
p64
(
string
.
atoi
(
oid
))
oid
=
ppml
.
p64
(
int
(
oid
))
v
=
''
for
x
in
data
[
2
:]:
v
=
v
+
x
...
...
lib/python/OFS/ZDOM.py
View file @
4be8d559
...
...
@@ -15,7 +15,6 @@ DOM implementation in ZOPE : Read-Only methods
All standard Zope objects support DOM to a limited extent.
"""
import
string
import
Acquisition
...
...
@@ -250,7 +249,7 @@ class DOMImplementation:
will cause the method to return true. Return Value true if the
feature is implemented in the specified version, false otherwise.
"""
feature
=
string
.
lower
(
feature
)
feature
=
feature
.
lower
(
)
if
feature
==
'html'
:
return
0
if
feature
==
'xml'
:
if
version
is
None
:
return
1
...
...
lib/python/OFS/content_types.py
View file @
4be8d559
...
...
@@ -11,9 +11,8 @@
#
##############################################################################
"""A utility module for content-type handling."""
__version__
=
'$Revision: 1.1
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
7
$'
[
11
:
-
2
]
from
string
import
split
,
strip
,
lower
,
find
import
re
,
mimetypes
...
...
@@ -21,7 +20,7 @@ find_binary=re.compile('[\0-\7]').search
def
text_type
(
s
):
# Yuk. See if we can figure out the type by content.
if
(
lower
(
strip
(
s
)[:
6
])
==
'<html>'
or
find
(
s
,
'</'
)
>
0
):
if
(
s
.
strip
().
lower
()[:
6
]
==
'<html>'
or
s
.
find
(
'</'
)
>
0
):
return
'text/html'
elif
s
.
strip
().
startswith
(
'<?xml'
):
...
...
@@ -92,7 +91,7 @@ def guess_content_type(name='', body='', default=None):
else
:
type
=
default
or
'text/x-unknown-content-type'
return
lower
(
type
),
enc
and
lower
(
enc
)
or
None
return
type
.
lower
(),
enc
and
enc
.
lower
(
)
or
None
if
__name__
==
'__main__'
:
items
=
mimetypes
.
types_map
.
items
()
...
...
lib/python/OFS/ndiff.py
View file @
4be8d559
...
...
@@ -97,7 +97,6 @@ __version__ = 1, 4, 0
# is sent to stdout. Or you can call main(args), passing what would
# have been in sys.argv[1:] had the cmd-line form been used.
import
string
TRACE
=
0
# define what "junk" means
...
...
@@ -515,7 +514,7 @@ def fancy_replace(a, alo, ahi, b, blo, bhi):
btags
=
btags
+
' '
*
(
la
-
lb
)
combined
=
map
(
lambda
x
,
y
:
_combine
[
x
+
y
],
atags
,
btags
)
print
'-'
,
aelt
,
'+'
,
belt
,
'?'
,
\
string
.
rstrip
(
string
.
join
(
combined
,
''
)
)
''
.
string
.
join
(
combined
).
rstrip
(
)
else
:
# the synch pair is identical
print
' '
,
aelt
,
...
...
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