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