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
006ee05c
Commit
006ee05c
authored
8 years ago
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flake8
parent
ae2c1d38
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
307 additions
and
322 deletions
+307
-322
setup.cfg
setup.cfg
+3
-0
src/App/CacheManager.py
src/App/CacheManager.py
+17
-16
src/App/Common.py
src/App/Common.py
+34
-30
src/App/Extensions.py
src/App/Extensions.py
+18
-17
src/App/FactoryDispatcher.py
src/App/FactoryDispatcher.py
+29
-27
src/App/FindHomes.py
src/App/FindHomes.py
+3
-3
src/App/ImageFile.py
src/App/ImageFile.py
+13
-13
src/App/Management.py
src/App/Management.py
+39
-42
src/App/ProductContext.py
src/App/ProductContext.py
+42
-41
src/App/Undo.py
src/App/Undo.py
+11
-14
src/App/ZApplication.py
src/App/ZApplication.py
+12
-11
src/App/__init__.py
src/App/__init__.py
+0
-12
src/App/class_init.py
src/App/class_init.py
+14
-4
src/App/special_dtml.py
src/App/special_dtml.py
+47
-35
src/App/tests/__init__.py
src/App/tests/__init__.py
+0
-1
src/App/tests/testImageFile.py
src/App/tests/testImageFile.py
+4
-8
src/App/tests/testManagement.py
src/App/tests/testManagement.py
+0
-6
src/App/tests/testUndo.py
src/App/tests/testUndo.py
+0
-6
src/App/tests/test_cachemanager.py
src/App/tests/test_cachemanager.py
+1
-4
src/App/tests/test_class_init.py
src/App/tests/test_class_init.py
+13
-18
src/App/tests/test_setConfiguration.py
src/App/tests/test_setConfiguration.py
+1
-7
src/Products/Five/browser/tests/test_defaultview.py
src/Products/Five/browser/tests/test_defaultview.py
+1
-0
src/Products/PageTemplates/ZopePageTemplate.py
src/Products/PageTemplates/ZopePageTemplate.py
+0
-2
src/ZPublisher/tests/testPublish.py
src/ZPublisher/tests/testPublish.py
+1
-1
src/ZTUtils/Tree.py
src/ZTUtils/Tree.py
+1
-1
src/ZTUtils/__init__.py
src/ZTUtils/__init__.py
+3
-3
No files found.
setup.cfg
0 → 100644
View file @
006ee05c
[flake8]
ignore = N801,N802,N803,N805,N806,N812,E301
exclude = bootstrap.py
This diff is collapsed.
Click to expand it.
src/App/CacheManager.py
View file @
006ee05c
...
...
@@ -19,7 +19,8 @@ from AccessControl.class_init import InitializeClass
from
App.special_dtml
import
DTMLFile
from
DateTime.DateTime
import
DateTime
class
CacheManager
:
class
CacheManager
(
object
):
"""Cache management mix-in
"""
_cache_age
=
60
...
...
@@ -47,46 +48,46 @@ class CacheManager:
def
cache_age
(
self
):
return
self
.
_cache_age
def
manage_cache_age
(
self
,
value
,
REQUEST
):
def
manage_cache_age
(
self
,
value
,
REQUEST
):
"set cache age"
db
=
self
.
_getDB
()
self
.
_cache_age
=
value
db
.
setCacheDeactivateAfter
(
value
)
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
def
cache_size
(
self
):
db
=
self
.
_getDB
()
return
db
.
getCacheSize
()
def
manage_cache_size
(
self
,
value
,
REQUEST
):
def
manage_cache_size
(
self
,
value
,
REQUEST
):
"set cache size"
db
=
self
.
_getDB
()
db
.
setCacheSize
(
value
)
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
def
manage_full_sweep
(
self
,
value
,
REQUEST
):
def
manage_full_sweep
(
self
,
value
,
REQUEST
):
"Perform a full sweep through the cache"
db
=
self
.
_getDB
()
db
.
cacheFullSweep
(
value
)
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheGC'
)
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheGC'
)
def
manage_minimize
(
self
,
value
=
1
,
REQUEST
=
None
):
def
manage_minimize
(
self
,
value
=
1
,
REQUEST
=
None
):
"Perform a full sweep through the cache"
# XXX Add a deprecation warning about value?
self
.
_getDB
().
cacheMinimize
()
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheGC'
)
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheGC'
)
def
cache_detail
(
self
,
REQUEST
=
None
):
"""
...
...
@@ -129,7 +130,7 @@ class CacheManager:
else
:
state
=
'G'
# ghost
res
.
append
(
'%d %-34s %6d %s %s%s'
%
(
dict
[
'conn_no'
],
`dict['oid']`
,
dict
[
'rc'
],
dict
[
'conn_no'
],
repr
(
dict
[
'oid'
])
,
dict
[
'rc'
],
state
,
dict
[
'klass'
],
idinfo
))
REQUEST
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/plain'
)
return
'
\
n
'
.
join
(
res
)
...
...
@@ -158,7 +159,7 @@ class CacheManager:
am
=
self
.
_getActivityMonitor
()
length
=
int
(
length
)
if
length
<
0
:
raise
ValueError
,
'length can not be negative'
raise
ValueError
(
'length can not be negative'
)
if
am
is
not
None
:
am
.
setHistoryLength
(
length
)
self
.
_history_length
=
length
# Restore on startup
...
...
This diff is collapsed.
Click to expand it.
src/App/Common.py
View file @
006ee05c
...
...
@@ -16,9 +16,11 @@ import os
import
sys
import
time
# Legacy API for this module; 3rd party code may use this.
from
os.path
import
realpath
from
Acquisition
import
aq_base
# BBB
from
os.path
import
realpath
# NOQA
attrget
=
getattr
# These are needed because the various date formats below must
# be in english per the RFCs. That means we can't use strftime,
...
...
@@ -34,13 +36,16 @@ def iso8601_date(ts=None):
# Return an ISO 8601 formatted date string, required
# for certain DAV properties.
# '2000-11-10T16:21:09-08:00
if
ts
is
None
:
ts
=
time
.
time
()
if
ts
is
None
:
ts
=
time
.
time
()
return
time
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
,
time
.
gmtime
(
ts
))
def
rfc850_date
(
ts
=
None
):
# Return an HTTP-date formatted date string.
# 'Friday, 10-Nov-00 16:21:09 GMT'
if
ts
is
None
:
ts
=
time
.
time
()
if
ts
is
None
:
ts
=
time
.
time
()
year
,
month
,
day
,
hh
,
mm
,
ss
,
wd
,
y
,
z
=
time
.
gmtime
(
ts
)
return
"%s, %02d-%3s-%2s %02d:%02d:%02d GMT"
%
(
weekday_full
[
wd
],
...
...
@@ -48,17 +53,21 @@ def rfc850_date(ts=None):
str
(
year
)[
2
:],
hh
,
mm
,
ss
)
def
rfc1123_date
(
ts
=
None
):
# Return an RFC 1123 format date string, required for
# use in HTTP Date headers per the HTTP 1.1 spec.
# 'Fri, 10 Nov 2000 16:21:09 GMT'
if
ts
is
None
:
ts
=
time
.
time
()
if
ts
is
None
:
ts
=
time
.
time
()
year
,
month
,
day
,
hh
,
mm
,
ss
,
wd
,
y
,
z
=
time
.
gmtime
(
ts
)
return
"%s, %02d %3s %4d %02d:%02d:%02d GMT"
%
(
weekday_abbr
[
wd
],
return
"%s, %02d %3s %4d %02d:%02d:%02d GMT"
%
(
weekday_abbr
[
wd
],
day
,
monthname
[
month
],
year
,
hh
,
mm
,
ss
)
def
absattr
(
attr
,
callable
=
callable
):
# Return the absolute value of an attribute,
# calling the attr if it is callable.
...
...
@@ -66,9 +75,6 @@ def absattr(attr, callable=callable):
return
attr
()
return
attr
def
aq_base
(
ob
,
getattr
=
getattr
):
# Return the aq_base of an object.
return
getattr
(
ob
,
'aq_base'
,
ob
)
def
is_acquired
(
ob
,
hasattr
=
hasattr
,
aq_base
=
aq_base
,
absattr
=
absattr
):
# Return true if this object is not considered to be
...
...
@@ -108,18 +114,16 @@ def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr):
def
package_home
(
globals_dict
):
__name__
=
globals_dict
[
'__name__'
]
m
=
sys
.
modules
[
__name__
]
if
hasattr
(
m
,
'__path__'
):
r
=
m
.
__path__
[
0
]
__name__
=
globals_dict
[
'__name__'
]
m
=
sys
.
modules
[
__name__
]
if
hasattr
(
m
,
'__path__'
):
r
=
m
.
__path__
[
0
]
elif
"."
in
__name__
:
r
=
sys
.
modules
[
__name__
[:
__name__
.
rfind
(
'.'
)]].
__path__
[
0
]
r
=
sys
.
modules
[
__name__
[:
__name__
.
rfind
(
'.'
)]].
__path__
[
0
]
else
:
r
=
__name__
r
=
__name__
return
os
.
path
.
abspath
(
r
)
# We really only want the 3-argument version of getattr:
attrget
=
getattr
def
Dictionary
(
**
kw
):
return
kw
# Sorry Guido
def
Dictionary
(
**
kw
):
return
kw
# Sorry Guido
This diff is collapsed.
Click to expand it.
src/App/Extensions.py
View file @
006ee05c
...
...
@@ -46,8 +46,8 @@ def _getPath(home, prefix, name, suffixes):
fn
=
os
.
path
.
join
(
dir
,
name
)
if
fn
==
name
:
# Paranoia
raise
ValueError
(
'The file name, %s, should be a simple file name'
%
name
)
raise
ValueError
(
'The file name, %s, should be a simple file name'
%
name
)
for
suffix
in
suffixes
:
if
suffix
:
...
...
@@ -87,8 +87,8 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
"""
dir
,
ignored
=
os
.
path
.
split
(
name
)
if
dir
:
raise
ValueError
(
'The file name, %s, should be a simple file name'
%
name
)
raise
ValueError
(
'The file name, %s, should be a simple file name'
%
name
)
if
checkProduct
:
dot
=
name
.
find
(
'.'
)
...
...
@@ -120,12 +120,13 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
try
:
dot
=
name
.
rfind
(
'.'
)
if
dot
>
0
:
realName
=
name
[
dot
+
1
:]
realName
=
name
[
dot
+
1
:]
toplevel
=
name
[:
dot
]
rdot
=
toplevel
.
rfind
(
'.'
)
if
rdot
>
-
1
:
module
=
__import__
(
toplevel
,
globals
(),
{},
toplevel
[
rdot
+
1
:])
module
=
__import__
(
toplevel
,
globals
(),
{},
toplevel
[
rdot
+
1
:])
else
:
module
=
__import__
(
toplevel
)
...
...
@@ -138,7 +139,7 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
fn
=
prefix
if
os
.
path
.
exists
(
fn
):
return
fn
except
:
except
Exception
:
pass
...
...
@@ -163,15 +164,15 @@ def getObject(module, name, reload=0,
else
:
prefix
=
module
path
=
getPath
(
'Extensions'
,
prefix
,
suffixes
=
(
''
,
'py'
,
'pyc'
))
path
=
getPath
(
'Extensions'
,
prefix
,
suffixes
=
(
''
,
'py'
,
'pyc'
))
if
path
is
None
:
raise
NotFound
(
"The specified module, '%s', couldn't be found."
%
module
)
raise
NotFound
(
"The specified module, '%s', couldn't be found."
%
module
)
__traceback_info__
=
path
,
module
__traceback_info__
=
path
,
module
base
,
ext
=
os
.
path
.
splitext
(
path
)
if
ext
==
'.pyc'
:
if
ext
==
'.pyc'
:
file
=
open
(
path
,
'rb'
)
binmod
=
imp
.
load_compiled
(
'Extension'
,
path
,
file
)
file
.
close
()
...
...
This diff is collapsed.
Click to expand it.
src/App/FactoryDispatcher.py
View file @
006ee05c
...
...
@@ -51,13 +51,13 @@ class Product(Base):
security
=
ClassSecurityInfo
()
meta_type
=
'Product'
version
=
''
meta_type
=
'Product'
version
=
''
thisIsAnInstalledProduct
=
True
title
=
'This is a non-persistent product wrapper.'
def
__init__
(
self
,
id
):
self
.
id
=
id
self
.
id
=
id
security
.
declarePublic
(
'Destination'
)
def
Destination
(
self
):
...
...
@@ -70,7 +70,7 @@ InitializeClass(Product)
class
ProductDispatcher
(
Implicit
):
" "
# Allow access to factory dispatchers
__allow_access_to_unprotected_subobjects__
=
1
__allow_access_to_unprotected_subobjects__
=
1
def
__getitem__
(
self
,
name
):
return
self
.
__bobo_traverse__
(
None
,
name
)
...
...
@@ -84,34 +84,36 @@ class ProductDispatcher(Implicit):
_packages
=
_product_packages
()
package
=
_packages
.
get
(
name
,
None
)
dispatcher_class
=
getattr
(
dispatcher_class
=
getattr
(
package
,
'__FactoryDispatcher__'
,
FactoryDispatcher
)
product
=
Product
(
name
)
dispatcher
=
dispatcher_class
(
product
,
self
.
aq_parent
,
REQUEST
)
dispatcher
=
dispatcher_class
(
product
,
self
.
aq_parent
,
REQUEST
)
return
dispatcher
.
__of__
(
self
)
class
FactoryDispatcher
(
Implicit
):
"""Provide a namespace for product "methods"
"""
security
=
ClassSecurityInfo
()
_owner
=
UnownableOwner
_owner
=
UnownableOwner
def
__init__
(
self
,
product
,
dest
,
REQUEST
=
None
):
product
=
aq_base
(
product
)
self
.
_product
=
product
self
.
_d
=
dest
self
.
_product
=
product
self
.
_d
=
dest
if
REQUEST
is
not
None
:
try
:
v
=
REQUEST
[
'URL'
]
except
KeyError
:
pass
v
=
REQUEST
[
'URL'
]
except
KeyError
:
pass
else
:
v
=
v
[:
v
.
rfind
(
'/'
)]
self
.
_u
=
v
[:
v
.
rfind
(
'/'
)]
v
=
v
[:
v
.
rfind
(
'/'
)]
self
.
_u
=
v
[:
v
.
rfind
(
'/'
)]
security
.
declarePublic
(
'Destination'
)
def
Destination
(
self
):
...
...
@@ -119,45 +121,45 @@ class FactoryDispatcher(Implicit):
return
self
.
__dict__
[
'_d'
]
# we don't want to wrap the result!
security
.
declarePublic
(
'this'
)
this
=
Destination
this
=
Destination
security
.
declarePublic
(
'DestinationURL'
)
def
DestinationURL
(
self
):
"Return the URL for the destination for factory output"
url
=
getattr
(
self
,
'_u'
,
None
)
url
=
getattr
(
self
,
'_u'
,
None
)
if
url
is
None
:
url
=
self
.
Destination
().
absolute_url
()
url
=
self
.
Destination
().
absolute_url
()
return
url
def
__getattr__
(
self
,
name
):
p
=
self
.
__dict__
[
'_product'
]
d
=
p
.
__dict__
if
hasattr
(
p
,
name
)
and
name
in
d
:
m
=
d
[
name
]
w
=
getattr
(
m
,
'_permissionMapper'
,
None
)
p
=
self
.
__dict__
[
'_product'
]
d
=
p
.
__dict__
if
hasattr
(
p
,
name
)
and
name
in
d
:
m
=
d
[
name
]
w
=
getattr
(
m
,
'_permissionMapper'
,
None
)
if
w
is
not
None
:
m
=
aqwrap
(
m
,
aq_base
(
w
),
self
)
m
=
aqwrap
(
m
,
aq_base
(
w
),
self
)
return
m
# Waaa
m
=
'Products.%s'
%
p
.
id
if
m
in
sys
.
modules
and
sys
.
modules
[
m
].
_m
.
has_key
(
name
):
if
m
in
sys
.
modules
and
sys
.
modules
[
m
].
_m
.
has_key
(
name
):
# NOQA
return
sys
.
modules
[
m
].
_m
[
name
]
raise
AttributeError
,
name
raise
AttributeError
(
name
)
# Provide acquired indicators for critical OM methods:
_setObject
=
_getOb
=
Acquired
# Make sure factory methods are unowned:
_owner
=
UnownableOwner
_owner
=
UnownableOwner
# Provide a replacement for manage_main that does a redirection:
def
manage_main
(
trueself
,
self
,
REQUEST
,
update_menu
=
0
):
"""Implement a contents view by redirecting to the true view
"""
d
=
update_menu
and
'/manage_main?update_menu=1'
or
'/manage_main'
REQUEST
[
'RESPONSE'
].
redirect
(
self
.
DestinationURL
()
+
d
)
REQUEST
[
'RESPONSE'
].
redirect
(
self
.
DestinationURL
()
+
d
)
InitializeClass
(
FactoryDispatcher
)
This diff is collapsed.
Click to expand it.
src/App/FindHomes.py
View file @
006ee05c
...
...
@@ -60,8 +60,8 @@ if ppathpat is not None:
psep
=
os
.
pathsep
if
ppathpat
.
find
(
'%('
)
>=
0
:
newppath
=
(
ppathpat
%
{
'PRODUCTS_PATH'
:
psep
.
join
(
ppath
),
'SOFTWARE_PRODUCTS'
:
psep
.
join
(
ppath
[
ippart
:]
),
'PRODUCTS_PATH'
:
psep
.
join
(
ppath
),
'SOFTWARE_PRODUCTS'
:
psep
.
join
(
ppath
[
ippart
:]),
'INSTANCE_PRODUCTS'
:
ip
,
}).
split
(
psep
)
else
:
...
...
This diff is collapsed.
Click to expand it.
src/App/ImageFile.py
View file @
006ee05c
...
...
@@ -50,11 +50,11 @@ class ImageFile(Explicit):
_prefix
=
PREFIX
if
not
os
.
path
.
isabs
(
path
):
warnings
.
warn
(
NON_PREFIX_WARNING
,
UserWarning
,
2
)
elif
type
(
_prefix
)
is
not
type
(
''
):
_prefix
=
package_home
(
_prefix
)
elif
not
isinstance
(
_prefix
,
str
):
_prefix
=
package_home
(
_prefix
)
# _prefix is ignored if path is absolute
path
=
os
.
path
.
join
(
_prefix
,
path
)
self
.
path
=
path
self
.
path
=
path
if
getConfiguration
().
debug_mode
:
# In development mode, a shorter time is handy
max_age
=
60
# One minute
...
...
@@ -64,7 +64,7 @@ class ImageFile(Explicit):
self
.
cch
=
'public,max-age=%d'
%
max_age
# First try to get the content_type by name
content_type
,
enc
=
guess_content_type
(
path
,
default
=
'failed'
)
content_type
,
enc
=
guess_content_type
(
path
,
default
=
'failed'
)
if
content_type
==
'failed'
:
# This failed, lets look into the file content
...
...
@@ -72,10 +72,10 @@ class ImageFile(Explicit):
data
=
img
.
read
(
1024
)
# 1k should be enough
img
.
close
()
content_type
,
enc
=
guess_content_type
(
path
,
data
)
content_type
,
enc
=
guess_content_type
(
path
,
data
)
if
content_type
:
self
.
content_type
=
content_type
self
.
content_type
=
content_type
else
:
ext
=
os
.
path
.
splitext
(
path
)[
-
1
].
replace
(
'.'
,
''
)
self
.
content_type
=
'image/%s'
%
ext
...
...
@@ -97,7 +97,7 @@ class ImageFile(Explicit):
RESPONSE
.
setHeader
(
'Content-Length'
,
str
(
self
.
size
).
replace
(
'L'
,
''
))
header
=
REQUEST
.
get_header
(
'If-Modified-Since'
,
None
)
if
header
is
not
None
:
header
=
header
.
split
(
';'
)[
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
...
...
@@ -105,14 +105,14 @@ class ImageFile(Explicit):
# understand the screwy date string as a lucky side effect
# of the way they parse it).
try
:
mod_since
=
long
(
DateTime
(
header
).
timeTime
())
mod_since
=
int
(
DateTime
(
header
).
timeTime
())
except
:
mod_since
=
None
if
mod_since
is
not
None
:
if
getattr
(
self
,
'lmt'
,
None
):
last_mod
=
long
(
self
.
lmt
)
last_mod
=
int
(
self
.
lmt
)
else
:
last_mod
=
long
(
0
)
last_mod
=
int
(
0
)
if
last_mod
>
0
and
last_mod
<=
mod_since
:
RESPONSE
.
setStatus
(
304
)
return
''
...
...
This diff is collapsed.
Click to expand it.
src/App/Management.py
View file @
006ee05c
...
...
@@ -33,31 +33,28 @@ class Tabs(Base):
security
=
ClassSecurityInfo
()
security
.
declarePublic
(
'manage_tabs'
)
manage_tabs
=
DTMLFile
(
'dtml/manage_tabs'
,
globals
())
manage_tabs
=
DTMLFile
(
'dtml/manage_tabs'
,
globals
())
manage_options
=
()
manage_options
=
()
security
.
declarePublic
(
'filtered_manage_options'
)
def
filtered_manage_options
(
self
,
REQUEST
=
None
):
result
=
[]
result
=
[]
try
:
options
=
tuple
(
self
.
manage_options
)
options
=
tuple
(
self
.
manage_options
)
except
TypeError
:
options
=
tuple
(
self
.
manage_options
())
options
=
tuple
(
self
.
manage_options
())
for
d
in
options
:
filter
=
d
.
get
(
'filter'
,
None
)
filter
=
d
.
get
(
'filter'
,
None
)
if
filter
is
not
None
and
not
filter
(
self
):
continue
path
=
d
.
get
(
'path'
,
None
)
path
=
d
.
get
(
'path'
,
None
)
if
path
is
None
:
path
=
d
[
'action'
]
path
=
d
[
'action'
]
o
=
self
.
restrictedTraverse
(
path
,
None
)
o
=
self
.
restrictedTraverse
(
path
,
None
)
if
o
is
None
:
continue
...
...
@@ -65,23 +62,22 @@ class Tabs(Base):
return
result
manage_workspace__roles__
=
(
'Authenticated'
,)
manage_workspace__roles__
=
(
'Authenticated'
,)
def
manage_workspace
(
self
,
REQUEST
):
"""Dispatch to first interface in manage_options
"""
options
=
self
.
filtered_manage_options
(
REQUEST
)
options
=
self
.
filtered_manage_options
(
REQUEST
)
try
:
m
=
options
[
0
][
'action'
]
if
m
==
'manage_workspace'
:
m
=
options
[
0
][
'action'
]
if
m
==
'manage_workspace'
:
raise
TypeError
except
(
IndexError
,
KeyError
):
raise
Unauthorized
,
(
raise
Unauthorized
(
'You are not authorized to view this object.'
)
if
m
.
find
(
'/'
):
raise
Redirect
,
(
"%s/%s"
%
(
REQUEST
[
'URL1'
],
m
))
raise
Redirect
(
"%s/%s"
%
(
REQUEST
[
'URL1'
],
m
))
return
getattr
(
self
,
m
)(
self
,
REQUEST
)
...
...
@@ -101,7 +97,8 @@ class Tabs(Base):
script
=
'%s/%s'
%
(
script
,
step
)
out
.
append
(
linkpat
%
(
escape
(
script
,
1
),
escape
(
unquote
(
step
))))
script
=
'%s/%s'
%
(
script
,
last
)
out
.
append
(
'<a class="strong-link" href="%s/manage_workspace">%s</a>'
%
out
.
append
(
'<a class="strong-link" href="%s/manage_workspace">%s</a>'
%
(
escape
(
script
,
1
),
escape
(
unquote
(
last
))))
return
'%s%s'
%
(
url
,
'/'
.
join
(
out
))
...
...
@@ -109,25 +106,25 @@ class Tabs(Base):
# Static vars
quote
=
urllib
.
quote
,
):
out
=
[]
while
path
[:
1
]
==
'/'
:
out
=
[]
while
path
[:
1
]
==
'/'
:
path
=
path
[
1
:]
while
path
[
-
1
:]
==
'/'
:
while
path
[
-
1
:]
==
'/'
:
path
=
path
[:
-
1
]
while
script
[:
1
]
==
'/'
:
while
script
[:
1
]
==
'/'
:
script
=
script
[
1
:]
while
script
[
-
1
:]
==
'/'
:
while
script
[
-
1
:]
==
'/'
:
script
=
script
[:
-
1
]
path
=
path
.
split
(
'/'
)[:
-
1
]
path
=
path
.
split
(
'/'
)[:
-
1
]
if
script
:
path
=
[
script
]
+
path
if
not
path
:
return
''
script
=
''
last
=
path
[
-
1
]
script
=
''
last
=
path
[
-
1
]
del
path
[
-
1
]
for
p
in
path
:
script
=
"%s/%s"
%
(
script
,
quote
(
p
))
script
=
"%s/%s"
%
(
script
,
quote
(
p
))
out
.
append
(
'<a href="%s/manage_workspace">%s</a>'
%
(
script
,
p
))
out
.
append
(
last
)
return
'/'
.
join
(
out
)
...
...
@@ -143,33 +140,33 @@ class Navigation(Base):
security
=
ClassSecurityInfo
()
security
.
declareProtected
(
view_management_screens
,
'manage'
)
manage
=
DTMLFile
(
'dtml/manage'
,
globals
())
manage
=
DTMLFile
(
'dtml/manage'
,
globals
())
security
.
declareProtected
(
view_management_screens
,
'manage_menu'
)
manage_menu
=
DTMLFile
(
'dtml/menu'
,
globals
())
manage_menu
=
DTMLFile
(
'dtml/menu'
,
globals
())
security
.
declareProtected
(
view_management_screens
,
'manage_page_header'
)
manage_page_header
=
DTMLFile
(
'dtml/manage_page_header'
,
globals
())
manage_page_header
=
DTMLFile
(
'dtml/manage_page_header'
,
globals
())
security
.
declareProtected
(
view_management_screens
,
'manage_page_footer'
)
manage_page_footer
=
DTMLFile
(
'dtml/manage_page_footer'
,
globals
())
manage_page_footer
=
DTMLFile
(
'dtml/manage_page_footer'
,
globals
())
security
.
declarePublic
(
'manage_form_title'
)
manage_form_title
=
DTMLFile
(
'dtml/manage_form_title'
,
globals
(),
manage_form_title
=
DTMLFile
(
'dtml/manage_form_title'
,
globals
(),
form_title
=
'Add Form'
,
help_product
=
None
,
help_topic
=
None
)
manage_form_title
.
_setFuncSignature
(
varnames
=
(
'form_title'
,
'help_product'
,
'help_topic'
)
)
varnames
=
(
'form_title'
,
'help_product'
,
'help_topic'
))
security
.
declarePublic
(
'manage_zmi_logout'
)
def
manage_zmi_logout
(
self
,
REQUEST
,
RESPONSE
):
"""Logout current user"""
p
=
getattr
(
REQUEST
,
'_logout_path'
,
None
)
if
p
is
not
None
:
return
apply
(
self
.
restrictedTraverse
(
p
)
)
return
self
.
restrictedTraverse
(
*
p
)
realm
=
RESPONSE
.
realm
realm
=
RESPONSE
.
realm
RESPONSE
.
setStatus
(
401
)
RESPONSE
.
setHeader
(
'WWW-Authenticate'
,
'basic realm="%s"'
%
realm
,
1
)
RESPONSE
.
setBody
(
"""<html>
...
...
This diff is collapsed.
Click to expand it.
src/App/ProductContext.py
View file @
006ee05c
...
...
@@ -27,14 +27,15 @@ from App.FactoryDispatcher import FactoryDispatcher
# Waaaa
import
Products
if
not
hasattr
(
Products
,
'meta_types'
):
Products
.
meta_types
=
()
Products
.
meta_types
=
()
if
not
hasattr
(
Products
,
'meta_classes'
):
Products
.
meta_classes
=
{}
Products
.
meta_class_info
=
{}
Products
.
meta_classes
=
{}
Products
.
meta_class_info
=
{}
_marker
=
[]
# Create a new marker object
LOG
=
getLogger
(
'ProductContext'
)
class
ProductContext
:
def
__init__
(
self
,
product
,
app
,
package
):
...
...
@@ -45,8 +46,7 @@ class ProductContext:
permission
=
None
,
constructors
=
(),
icon
=
None
,
permissions
=
None
,
legacy
=
(),
visibility
=
"Global"
,
interfaces
=
_marker
,
container_filter
=
None
):
container_filter
=
None
):
"""Register a constructor
Keyword arguments are used to provide meta data:
...
...
@@ -94,18 +94,19 @@ class ProductContext:
before calling an object's constructor.
"""
pack
=
self
.
__pack
initial
=
constructors
[
0
]
productObject
=
self
.
__prod
pid
=
productObject
.
id
pack
=
self
.
__pack
initial
=
constructors
[
0
]
productObject
=
self
.
__prod
pid
=
productObject
.
id
if
permissions
:
if
isinstance
(
permissions
,
basestring
):
# You goofed it!
raise
TypeError
,
(
'Product context permissions should be a '
raise
TypeError
(
'Product context permissions should be a '
'list of permissions not a string'
,
permissions
)
for
p
in
permissions
:
if
isinstance
(
p
,
tuple
):
p
,
default
=
p
p
,
default
=
p
registerPermissions
(((
p
,
(),
default
),))
else
:
registerPermissions
(((
p
,
()),))
...
...
@@ -113,14 +114,14 @@ class ProductContext:
############################################################
# Constructor permission setup
if
permission
is
None
:
permission
=
"Add %ss"
%
(
meta_type
or
instance_class
.
meta_type
)
permission
=
"Add %ss"
%
(
meta_type
or
instance_class
.
meta_type
)
if
isinstance
(
permission
,
tuple
):
permission
,
default
=
permission
else
:
default
=
(
'Manager'
,)
pr
=
PermissionRole
(
permission
,
default
)
pr
=
PermissionRole
(
permission
,
default
)
registerPermissions
(((
permission
,
(),
default
),))
############################################################
...
...
@@ -131,17 +132,17 @@ class ProductContext:
name
,
method
=
method
aliased
=
1
else
:
name
=
method
.
__name__
name
=
method
.
__name__
aliased
=
0
if
name
not
in
OM
.
__dict__
:
setattr
(
OM
,
name
,
method
)
setattr
(
OM
,
name
+
'__roles__'
,
pr
)
setattr
(
OM
,
name
+
'__roles__'
,
pr
)
if
aliased
:
# Set the unaliased method name and its roles
# to avoid security holes. XXX: All "legacy"
# methods need to be eliminated.
setattr
(
OM
,
method
.
__name__
,
method
)
setattr
(
OM
,
method
.
__name__
+
'__roles__'
,
pr
)
setattr
(
OM
,
method
.
__name__
+
'__roles__'
,
pr
)
if
isinstance
(
initial
,
tuple
):
name
,
initial
=
initial
...
...
@@ -166,8 +167,8 @@ class ProductContext:
else
:
interfaces
=
tuple
(
implementedBy
(
instance_class
))
Products
.
meta_types
=
Products
.
meta_types
+
(
{
'name'
:
meta_type
or
instance_class
.
meta_type
,
Products
.
meta_types
=
Products
.
meta_types
+
(
{
'name'
:
meta_type
or
instance_class
.
meta_type
,
# 'action': The action in the add drop down in the ZMI. This is
# currently also required by the _verifyObjectPaste
# method of CopyContainers like Folders.
...
...
@@ -185,17 +186,17 @@ class ProductContext:
'container_filter'
:
container_filter
},)
m
[
name
]
=
initial
m
[
name
+
'__roles__'
]
=
pr
m
[
name
]
=
initial
m
[
name
+
'__roles__'
]
=
pr
for
method
in
constructors
[
1
:]:
if
isinstance
(
method
,
tuple
):
name
,
method
=
method
else
:
name
=
os
.
path
.
split
(
method
.
__name__
)[
-
1
]
name
=
os
.
path
.
split
(
method
.
__name__
)[
-
1
]
if
name
not
in
productObject
.
__dict__
:
m
[
name
]
=
method
m
[
name
+
'__roles__'
]
=
pr
m
[
name
]
=
method
m
[
name
+
'__roles__'
]
=
pr
def
registerHelp
(
self
,
directory
=
None
,
clear
=
None
,
title_re
=
None
):
pass
...
...
This diff is collapsed.
Click to expand it.
src/App/Undo.py
View file @
006ee05c
...
...
@@ -13,6 +13,8 @@
"""Undo support.
"""
import
binascii
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_parent
from
AccessControl
import
getSecurityManager
...
...
@@ -34,7 +36,7 @@ class UndoSupport(ExtensionClass.Base):
security
=
ClassSecurityInfo
()
manage_options
=
(
manage_options
=
(
{
'label'
:
'Undo'
,
'action'
:
'manage_UndoForm'
},
)
...
...
@@ -49,8 +51,8 @@ class UndoSupport(ExtensionClass.Base):
def
_get_request_var_or_attr
(
self
,
name
,
default
):
if
hasattr
(
self
,
'REQUEST'
):
REQUEST
=
self
.
REQUEST
if
REQUEST
.
has_key
(
name
)
:
REQUEST
=
self
.
REQUEST
if
name
in
REQUEST
:
return
REQUEST
[
name
]
if
hasattr
(
self
,
name
):
v
=
getattr
(
self
,
name
)
...
...
@@ -81,7 +83,7 @@ class UndoSupport(ExtensionClass.Base):
if
last_transaction
is
None
:
last_transaction
=
self
.
_get_request_var_or_attr
(
'last_transaction'
,
first_transaction
+
PrincipiaUndoBatchSize
)
first_transaction
+
PrincipiaUndoBatchSize
)
spec
=
{}
...
...
@@ -151,11 +153,8 @@ class UndoSupport(ExtensionClass.Base):
InitializeClass
(
UndoSupport
)
########################################################################
# Blech, need this cause binascii.b2a_base64 is too pickly
import
binascii
def
encode64
(
s
,
b2a
=
binascii
.
b2a_base64
):
if
len
(
s
)
<
58
:
...
...
@@ -163,12 +162,10 @@ def encode64(s, b2a=binascii.b2a_base64):
r
=
[]
a
=
r
.
append
for
i
in
range
(
0
,
len
(
s
),
57
):
a
(
b2a
(
s
[
i
:
i
+
57
])[:
-
1
])
a
(
b2a
(
s
[
i
:
i
+
57
])[:
-
1
])
return
''
.
join
(
r
)
def
decode64
(
s
,
a2b
=
binascii
.
a2b_base64
):
__traceback_info__
=
len
(
s
),
`s`
return
a2b
(
s
+
'
\
n
'
)
del
binascii
__traceback_info__
=
len
(
s
),
repr
(
s
)
return
a2b
(
s
+
'
\
n
'
)
This diff is collapsed.
Click to expand it.
src/App/ZApplication.py
View file @
006ee05c
...
...
@@ -21,18 +21,19 @@ import transaction
connection_open_hooks
=
[]
class
ZApplicationWrapper
:
def
__init__
(
self
,
db
,
name
,
klass
=
None
,
klass_args
=
()):
def
__init__
(
self
,
db
,
name
,
klass
=
None
,
klass_args
=
()):
self
.
_stuff
=
db
,
name
if
klass
is
not
None
:
conn
=
db
.
open
()
root
=
conn
.
root
()
if
n
ot
root
.
has_key
(
name
)
:
root
[
name
]
=
klass
()
conn
=
db
.
open
()
root
=
conn
.
root
()
if
n
ame
not
in
root
:
root
[
name
]
=
klass
()
transaction
.
commit
()
conn
.
close
()
self
.
_klass
=
klass
self
.
_klass
=
klass
# This hack is to overcome a bug in Bobo!
def
__getattr__
(
self
,
name
):
...
...
@@ -52,25 +53,25 @@ class ZApplicationWrapper:
conn
.
setDebugInfo
(
REQUEST
.
environ
,
REQUEST
.
other
)
v
=
conn
.
root
()[
aname
]
v
=
conn
.
root
()[
aname
]
if
name
is
not
None
:
if
hasattr
(
v
,
'__bobo_traverse__'
):
return
v
.
__bobo_traverse__
(
REQUEST
,
name
)
if
hasattr
(
v
,
name
):
return
getattr
(
v
,
name
)
if
hasattr
(
v
,
name
):
return
getattr
(
v
,
name
)
return
v
[
name
]
return
v
def
__call__
(
self
,
connection
=
None
):
db
,
aname
=
self
.
_stuff
if
connection
is
None
:
connection
=
db
.
open
()
connection
=
db
.
open
()
elif
isinstance
(
connection
,
basestring
):
connection
=
db
.
open
(
connection
)
connection
=
db
.
open
(
connection
)
return
connection
.
root
()[
aname
]
...
...
This diff is collapsed.
Click to expand it.
src/App/__init__.py
View file @
006ee05c
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
This diff is collapsed.
Click to expand it.
src/App/class_init.py
View file @
006ee05c
...
...
@@ -13,7 +13,17 @@
"""Class initialization.
"""
# BBB
from
AccessControl.Permission
import
ApplicationDefaultPermissions
from
AccessControl.class_init
import
InitializeClass
default__class_init__
=
InitializeClass
# BBB: old name
from
zope.deferredimport
import
deprecated
# BBB Zope 5.0
deprecated
(
'Please import from AccessControl.Permission.'
,
ApplicationDefaultPermissions
=
(
'AccessControl.Permission:ApplicationDefaultPermissions'
),
)
deprecated
(
'Please import from AccessControl.class_init.'
,
default__class_init__
=
'AccessControl.class_init:InitializeClass'
,
InitializeClass
=
'AccessControl.class_init:InitializeClass'
,
)
This diff is collapsed.
Click to expand it.
src/App/special_dtml.py
View file @
006ee05c
...
...
@@ -21,19 +21,27 @@ import MethodObject
import
Persistence
from
App
import
Common
from
App.config
import
getConfiguration
import
Zope2
from
Shared.DC.Scripts.Bindings
import
Bindings
from
Acquisition
import
Explicit
,
aq_inner
,
aq_parent
from
DocumentTemplate.DT_String
import
_marker
,
DTReturn
,
render_blocks
from
DocumentTemplate.DT_Util
import
TemplateDict
,
InstanceDict
from
AccessControl
import
getSecurityManager
from
ComputedAttribute
import
ComputedAttribute
LOG
=
getLogger
(
'special_dtml'
)
import
Zope2
PREFIX
=
os
.
path
.
realpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
Zope2
.
__file__
),
os
.
path
.
pardir
)
)
)
class
HTML
(
DocumentTemplate
.
HTML
,
Persistence
.
Persistent
,
):
class
HTML
(
DocumentTemplate
.
HTML
,
Persistence
.
Persistent
):
"Persistent HTML Document Templates"
class
ClassicHTMLFile
(
DocumentTemplate
.
HTMLFile
,
MethodObject
.
Method
,):
class
ClassicHTMLFile
(
DocumentTemplate
.
HTMLFile
,
MethodObject
.
Method
):
"Persistent HTML Document Templates read from files"
class
func_code
:
...
...
@@ -48,26 +56,31 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
def
__init__
(
self
,
name
,
_prefix
=
None
,
**
kw
):
if
_prefix
is
None
:
_prefix
=
PREFIX
elif
type
(
_prefix
)
is
not
type
(
''
):
elif
not
isinstance
(
_prefix
,
str
):
_prefix
=
Common
.
package_home
(
_prefix
)
args
=
(
self
,
os
.
path
.
join
(
_prefix
,
name
+
'.dtml'
))
args
=
(
self
,
os
.
path
.
join
(
_prefix
,
name
+
'.dtml'
))
if
'__name__'
not
in
kw
:
kw
[
'__name__'
]
=
os
.
path
.
split
(
name
)[
-
1
]
apply
(
ClassicHTMLFile
.
inheritedAttribute
(
'__init__'
),
args
,
kw
)
ClassicHTMLFile
.
inheritedAttribute
(
'__init__'
)(
*
args
,
**
kw
)
def
_cook_check
(
self
):
if
getConfiguration
().
debug_mode
:
__traceback_info__
=
self
.
raw
try
:
mtime
=
os
.
stat
(
self
.
raw
)[
8
]
except
:
mtime
=
0
__traceback_info__
=
self
.
raw
try
:
mtime
=
os
.
stat
(
self
.
raw
)[
8
]
except
Exception
:
mtime
=
0
if
mtime
!=
self
.
_v_last_read
:
self
.
cook
()
self
.
_v_last_read
=
mtime
elif
not
hasattr
(
self
,
'_v_cooked'
):
try
:
changed
=
self
.
__changed__
()
except
:
changed
=
1
self
.
_v_last_read
=
mtime
elif
not
hasattr
(
self
,
'_v_cooked'
):
try
:
changed
=
self
.
__changed__
()
except
Exception
:
changed
=
1
self
.
cook
()
if
not
changed
:
self
.
__changed__
(
0
)
if
not
changed
:
self
.
__changed__
(
0
)
def
_setName
(
self
,
name
):
self
.
__name__
=
name
...
...
@@ -75,8 +88,8 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
def
__call__
(
self
,
*
args
,
**
kw
):
self
.
_cook_check
()
return
apply
(
HTMLFile
.
inheritedAttribute
(
'__call__'
),
(
self
,)
+
args
[
1
:],
kw
)
return
HTMLFile
.
inheritedAttribute
(
'__call__'
)(
*
(
self
,)
+
args
[
1
:],
**
kw
)
defaultBindings
=
{
'name_context'
:
'context'
,
'name_container'
:
'container'
,
...
...
@@ -84,21 +97,16 @@ defaultBindings = {'name_context': 'context',
'name_ns'
:
'caller_namespace'
,
'name_subpath'
:
'traverse_subpath'
}
from
Shared.DC.Scripts.Bindings
import
Bindings
from
Acquisition
import
Explicit
,
aq_inner
,
aq_parent
from
DocumentTemplate.DT_String
import
_marker
,
DTReturn
,
render_blocks
from
DocumentTemplate.DT_Util
import
TemplateDict
,
InstanceDict
from
AccessControl
import
getSecurityManager
from
ComputedAttribute
import
ComputedAttribute
class
DTMLFile
(
Bindings
,
Explicit
,
ClassicHTMLFile
):
"HTMLFile with bindings and support for __render_with_namespace__"
func_code
=
__code__
=
None
func_defaults
=
__defaults__
=
None
_need__name__
=
1
_need__name__
=
1
_Bindings_ns_class
=
TemplateDict
def
_get__roles__
(
self
):
imp
=
getattr
(
aq_parent
(
aq_inner
(
self
)),
'%s__roles__'
%
self
.
__name__
)
...
...
@@ -112,11 +120,9 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
_Bindings_client
=
'container'
def
__init__
(
self
,
name
,
_prefix
=
None
,
**
kw
):
self
.
ZBindings_edit
(
defaultBindings
)
self
.
_setFuncSignature
()
apply
(
DTMLFile
.
inheritedAttribute
(
'__init__'
),
(
self
,
name
,
_prefix
),
kw
)
DTMLFile
.
inheritedAttribute
(
'__init__'
)(
self
,
name
,
_prefix
,
**
kw
)
def
getOwner
(
self
,
info
=
0
):
'''
...
...
@@ -155,14 +161,16 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
if
old_kw
:
kw_bind
=
old_kw
.
copy
()
kw_bind
.
update
(
kw
)
except
:
pass
except
Exception
:
pass
else
:
# We're first, so get the REQUEST.
try
:
req
=
self
.
aq_acquire
(
'REQUEST'
)
if
hasattr
(
req
,
'taintWrapper'
):
req
=
req
.
taintWrapper
()
except
:
pass
except
Exception
:
pass
bound_data
[
'REQUEST'
]
=
req
ns
.
this
=
bound_data
[
'context'
]
# Bind 'keyword_args' to the complete set of keyword arguments.
...
...
@@ -189,13 +197,16 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
try
:
value
=
self
.
ZDocumentTemplate_beforeRender
(
ns
,
_marker
)
if
value
is
_marker
:
try
:
result
=
render_blocks
(
self
.
_v_blocks
,
ns
)
except
DTReturn
,
v
:
result
=
v
.
v
try
:
result
=
render_blocks
(
self
.
_v_blocks
,
ns
)
except
DTReturn
as
v
:
result
=
v
.
v
except
AttributeError
:
if
type
(
sys
.
exc_value
)
==
InstanceType
and
sys
.
exc_value
.
args
[
0
]
==
"_v_blocks"
:
if
(
type
(
sys
.
exc_value
)
==
InstanceType
and
sys
.
exc_value
.
args
[
0
]
==
"_v_blocks"
):
LOG
.
warn
(
"DTML file '%s' could not be read"
%
self
.
raw
)
raise
ValueError
,
(
"DTML file error: "
"
Check logfile for details"
)
raise
ValueError
(
"DTML file error:
Check logfile for details"
)
else
:
raise
...
...
@@ -206,7 +217,8 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
finally
:
security
.
removeContext
(
self
)
# Clear the namespace, breaking circular references.
while
len
(
ns
):
ns
.
_pop
()
while
len
(
ns
):
ns
.
_pop
()
from
Shared.DC.Scripts.Signature
import
_setFuncSignature
...
...
This diff is collapsed.
Click to expand it.
src/App/tests/__init__.py
View file @
006ee05c
# Needed to make this a Python package.
This diff is collapsed.
Click to expand it.
src/App/tests/testImageFile.py
View file @
006ee05c
...
...
@@ -25,7 +25,7 @@ class TestImageFile(unittest.TestCase):
def
test_no_warn_on_absolute_path
(
self
):
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
App
.
__file__
),
'www'
,
'zopelogo.png'
)
'www'
,
'zopelogo.png'
)
App
.
ImageFile
.
ImageFile
(
path
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
...
...
@@ -35,11 +35,7 @@ class TestImageFile(unittest.TestCase):
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_no_warn_on_namespace_as_prefix
(
self
):
prefix
=
App
.
__dict__
# same as calling globals() inside the App module
# same as calling globals() inside the App module
prefix
=
App
.
__dict__
App
.
ImageFile
.
ImageFile
(
'www/zopelogo.png'
,
prefix
)
self
.
assertFalse
(
self
.
warningshook
.
warnings
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
TestImageFile
),
))
This diff is collapsed.
Click to expand it.
src/App/tests/testManagement.py
View file @
006ee05c
...
...
@@ -9,9 +9,3 @@ class TestNavigation(unittest.TestCase):
from
zope.interface.verify
import
verifyClass
verifyClass
(
INavigation
,
Navigation
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
TestNavigation
),
))
This diff is collapsed.
Click to expand it.
src/App/tests/testUndo.py
View file @
006ee05c
...
...
@@ -9,9 +9,3 @@ class TestUndoSupport(unittest.TestCase):
from
zope.interface.verify
import
verifyClass
verifyClass
(
IUndoSupport
,
UndoSupport
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
TestUndoSupport
),
))
This diff is collapsed.
Click to expand it.
src/App/tests/test_cachemanager.py
View file @
006ee05c
...
...
@@ -42,6 +42,7 @@ class CacheManagerTestCase(unittest.TestCase):
def
_getManagerClass
(
self
):
from
App.CacheManager
import
CacheManager
class
TestCacheManager
(
CacheManager
):
# Derived CacheManager that fakes enough of the DatabaseManager to
# make it possible to test at least some parts of the CacheManager.
...
...
@@ -56,7 +57,3 @@ class CacheManagerTestCase(unittest.TestCase):
self
.
assertEqual
(
manager
.
cache_size
(),
42
)
db
.
_set_sizes
(
12
)
self
.
assertEqual
(
manager
.
cache_size
(),
12
)
def
test_suite
():
return
unittest
.
makeSuite
(
CacheManagerTestCase
)
This diff is collapsed.
Click to expand it.
src/App/tests/test_class_init.py
View file @
006ee05c
...
...
@@ -14,27 +14,22 @@
"""Tests class initialization.
"""
def
test_InitializeClass
():
"""Test that InitializeClass (default__class_init__)
works in specific corner cases.
import
unittest
Check when the class has an ExtensionClass as attribute.
from
AccessControl.class_init
import
InitializeClass
import
ExtensionClass
>>> import ExtensionClass
>>> from AccessControl.class_init import InitializeClass
>>> class AnotherClass(ExtensionClass.Base):
... _need__name__ = 1
>>> class C:
... foo = AnotherClass
class
TestInitializeClass
(
unittest
.
TestCase
):
>>> InitializeClass(C)
"""
def
test_extension_class
(
self
):
# Test that InitializeClass works in specific corner cases.
# Check when the class has an ExtensionClass as attribute.
from
doctest
import
DocTestSuite
import
unittest
class
AnotherClass
(
ExtensionClass
.
Base
):
_need__name__
=
1
class
C
:
foo
=
AnotherClass
def
test_suite
():
return
unittest
.
TestSuite
((
DocTestSuite
(),
))
InitializeClass
(
C
)
This diff is collapsed.
Click to expand it.
src/App/tests/test_setConfiguration.py
View file @
006ee05c
...
...
@@ -73,9 +73,3 @@ class SetConfigTests(unittest.TestCase):
self
.
assertEqual
(
Globals
.
DevelopmentMode
,
True
)
self
.
setconfig
(
debug_mode
=
False
)
self
.
assertEqual
(
Globals
.
DevelopmentMode
,
False
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
SetConfigTests
))
return
suite
This diff is collapsed.
Click to expand it.
src/Products/Five/browser/tests/test_defaultview.py
View file @
006ee05c
...
...
@@ -84,6 +84,7 @@ def test_default_view():
>>> tearDown()
"""
def
test_default_method_args_marshalling
():
"""
\
Test the default call method of a view, with respect to possible
...
...
This diff is collapsed.
Click to expand it.
src/Products/PageTemplates/ZopePageTemplate.py
View file @
006ee05c
...
...
@@ -122,7 +122,6 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
content_type
=
'text/html'
self
.
pt_edit
(
text
,
content_type
)
security
.
declareProtected
(
change_page_templates
,
'pt_edit'
)
def
pt_edit
(
self
,
text
,
content_type
,
keep_output_encoding
=
False
):
text
=
text
.
strip
()
...
...
@@ -402,7 +401,6 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
# acquisition context, so we don't know where it is. :-(
return
None
def
__setstate__
(
self
,
state
):
# Perform on-the-fly migration to unicode.
# Perhaps it might be better to work with the 'generation' module
...
...
This diff is collapsed.
Click to expand it.
src/ZPublisher/tests/testPublish.py
View file @
006ee05c
...
...
@@ -3,7 +3,6 @@ import doctest
from
zope.interface
import
implements
from
zope.publisher.interfaces.browser
import
IDefaultBrowserLayer
from
zope.publisher.interfaces.browser
import
IBrowserRequest
from
zope.publisher.skinnable
import
setDefaultSkin
from
ZPublisher
import
Retry
from
ZODB.POSException
import
ConflictError
...
...
@@ -293,6 +292,7 @@ def testPublisher():
>>> tracer.reset()
>>> request = RequestWithSkinCheck()
>>> from zope.publisher.skinnable import setDefaultSkin
>>> setDefaultSkin(request)
>>> response = publish(request, module_name, after_list)
>>> tracer.showTracedPath()
...
...
This diff is collapsed.
Click to expand it.
src/ZTUtils/Tree.py
View file @
006ee05c
...
...
@@ -161,7 +161,7 @@ class TreeMaker:
child_exp
=
expanded
if
not
simple_type
(
expanded
):
# Assume a mapping
expanded
=
expanded
.
has_key
(
node
.
id
)
expanded
=
node
.
id
in
expanded
child_exp
=
child_exp
.
get
(
node
.
id
)
expanded
=
expanded
or
(
not
subtree
and
self
.
_expand_root
)
...
...
This diff is collapsed.
Click to expand it.
src/ZTUtils/__init__.py
View file @
006ee05c
...
...
@@ -16,10 +16,10 @@ from AccessControl.SecurityInfo import ModuleSecurityInfo
security
=
ModuleSecurityInfo
(
'ZTUtils'
)
security
.
declarePublic
(
'encodeExpansion'
,
'decodeExpansion'
,
'a2b'
,
'b2a'
)
from
Tree
import
encodeExpansion
,
decodeExpansion
,
a2b
,
b2a
from
Tree
import
encodeExpansion
,
decodeExpansion
,
a2b
,
b2a
# NOQA
security
.
declarePublic
(
'Batch'
,
'TreeMaker'
,
'SimpleTreeMaker'
,
'LazyFilter'
)
from
ZTUtils.Zope
import
Batch
,
TreeMaker
,
SimpleTreeMaker
,
LazyFilter
from
ZTUtils.Zope
import
Batch
,
TreeMaker
,
SimpleTreeMaker
,
LazyFilter
# NOQA
security
.
declarePublic
(
'url_query'
,
'make_query'
,
'make_hidden_input'
)
from
ZTUtils.Zope
import
url_query
,
make_query
,
make_hidden_input
from
ZTUtils.Zope
import
url_query
,
make_query
,
make_hidden_input
# NOQA
This diff is collapsed.
Click to expand it.
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