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
6205dfa9
Commit
6205dfa9
authored
Mar 12, 2010
by
Leonardo Rochael Almeida
Browse files
Options
Browse Files
Download
Plain Diff
forward port r109929: fix for lp #534653
parents
7abf6411
548c8b32
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
2 deletions
+180
-2
src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
...ucts/StandardCacheManagers/AcceleratedHTTPCacheManager.py
+5
-1
src/Products/StandardCacheManagers/RAMCacheManager.py
src/Products/StandardCacheManagers/RAMCacheManager.py
+5
-1
src/Products/StandardCacheManagers/configure.zcml
src/Products/StandardCacheManagers/configure.zcml
+13
-0
src/Products/StandardCacheManagers/subscribers.py
src/Products/StandardCacheManagers/subscribers.py
+24
-0
src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
.../StandardCacheManagers/tests/test_CacheManagerLocation.py
+133
-0
No files found.
src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
View file @
6205dfa9
...
...
@@ -166,12 +166,16 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
self
.
_settings
=
{
'anonymous_only'
:
1
,
'interval'
:
3600
,
'notify_urls'
:()}
self
.
_
_cacheid
=
'%s_%f'
%
(
id
(
self
),
time
.
time
()
)
self
.
_
resetCacheId
(
)
def
getId
(
self
):
' '
return
self
.
id
security
.
declarePrivate
(
'_resetCacheId'
)
def
_resetCacheId
(
self
):
self
.
__cacheid
=
'%s_%f'
%
(
id
(
self
),
time
.
time
())
security
.
declarePrivate
(
'ZCacheManager_getCache'
)
def
ZCacheManager_getCache
(
self
):
cacheid
=
self
.
__cacheid
...
...
src/Products/StandardCacheManagers/RAMCacheManager.py
View file @
6205dfa9
...
...
@@ -374,12 +374,16 @@ class RAMCacheManager (CacheManager, SimpleItem):
'request_vars'
:
(
'AUTHENTICATED_USER'
,),
'max_age'
:
3600
,
}
self
.
_
_cacheid
=
'%s_%f'
%
(
id
(
self
),
time
.
time
()
)
self
.
_
resetCacheId
(
)
def
getId
(
self
):
' '
return
self
.
id
security
.
declarePrivate
(
'_resetCacheId'
)
def
_resetCacheId
(
self
):
self
.
__cacheid
=
'%s_%f'
%
(
id
(
self
),
time
.
time
())
ZCacheManager_getCache__roles__
=
()
def
ZCacheManager_getCache
(
self
):
cacheid
=
self
.
__cacheid
...
...
src/Products/StandardCacheManagers/configure.zcml
0 → 100644
View file @
6205dfa9
<configure xmlns="http://namespaces.zope.org/zope">
<subscriber
for="Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" />
<subscriber
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" />
</configure>
src/Products/StandardCacheManagers/subscribers.py
0 → 100644
View file @
6205dfa9
##############################################################################
#
# Copyright (c) 2010 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
""" subscribers to events affecting StandardCacheManagers
"""
def
cloned
(
obj
,
event
):
"""
Reset the Id of the module level cache so the clone gets a different cache
than its source object
"""
obj
.
_resetCacheId
()
src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
0 → 100644
View file @
6205dfa9
##############################################################################
#
# Copyright (c) 2010 Zope Foundation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
""" Unit tests for AcceleratedCacheManager module.
$Id$
"""
import
unittest
import
transaction
import
zope.component
from
zope.component
import
testing
as
componenttesting
from
zope.component
import
eventtesting
from
AccessControl
import
SecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
OFS.Folder
import
Folder
from
OFS.tests.testCopySupport
import
CopySupportTestBase
from
OFS.tests.testCopySupport
import
UnitTestSecurityPolicy
from
OFS.tests.testCopySupport
import
UnitTestUser
from
Products.Five
import
zcml
from
Products.StandardCacheManagers.RAMCacheManager
import
RAMCacheManager
from
Products.StandardCacheManagers.AcceleratedHTTPCacheManager
\
import
AcceleratedHTTPCacheManager
import
Products.StandardCacheManagers
CACHE_META_TYPES
=
tuple
(
dict
(
name
=
instance_class
.
meta_type
,
action
=
'unused_constructor_name'
,
permission
=
"Add %ss"
%
instance_class
.
meta_type
)
for
instance_class
in
(
RAMCacheManager
,
AcceleratedHTTPCacheManager
)
)
class
CacheManagerLocationTests
(
CopySupportTestBase
):
_targetClass
=
None
def
_makeOne
(
self
,
*
args
,
**
kw
):
return
self
.
_targetClass
(
*
args
,
**
kw
)
def
setUp
(
self
):
componenttesting
.
setUp
()
eventtesting
.
setUp
()
zcml
.
load_config
(
'meta.zcml'
,
zope
.
component
)
zcml
.
load_config
(
'configure.zcml'
,
Products
.
StandardCacheManagers
)
folder1
,
folder2
=
self
.
_initFolders
()
folder1
.
all_meta_types
=
folder2
.
all_meta_types
=
CACHE_META_TYPES
self
.
folder1
=
folder1
self
.
folder2
=
folder2
self
.
policy
=
UnitTestSecurityPolicy
()
self
.
oldPolicy
=
SecurityManager
.
setSecurityPolicy
(
self
.
policy
)
cm_id
=
'cache'
manager
=
self
.
_makeOne
(
cm_id
)
self
.
folder1
.
_setObject
(
cm_id
,
manager
)
self
.
cachemanager
=
self
.
folder1
[
cm_id
]
transaction
.
savepoint
(
optimistic
=
True
)
newSecurityManager
(
None
,
UnitTestUser
().
__of__
(
self
.
root
)
)
CopySupportTestBase
.
setUp
(
self
)
def
tearDown
(
self
):
noSecurityManager
()
SecurityManager
.
setSecurityPolicy
(
self
.
oldPolicy
)
del
self
.
oldPolicy
del
self
.
policy
del
self
.
folder2
del
self
.
folder1
self
.
_cleanApp
()
componenttesting
.
tearDown
()
CopySupportTestBase
.
tearDown
(
self
)
def
test_cache_differs_on_copy
(
self
):
# ensure copies don't hit the same cache
cache
=
self
.
cachemanager
.
ZCacheManager_getCache
()
cachemanager_copy
=
self
.
folder2
.
manage_clone
(
self
.
cachemanager
,
'cache_copy'
)
cache_copy
=
cachemanager_copy
.
ZCacheManager_getCache
()
self
.
assertNotEqual
(
cache
,
cache_copy
)
def
test_cache_remains_on_move
(
self
):
# test behaviour of cache on move.
# NOTE: This test verifies current behaviour, but there is no actual
# need for cache managers to maintain the same cache on move.
# if physical path starts being used as a cache key, this test might
# need to be fixed.
cache
=
self
.
cachemanager
.
ZCacheManager_getCache
()
cut
=
self
.
folder1
.
manage_cutObjects
([
'cache'
])
self
.
folder2
.
manage_pasteObjects
(
cut
)
cachemanager_moved
=
self
.
folder2
[
'cache'
]
cache_moved
=
cachemanager_moved
.
ZCacheManager_getCache
()
self
.
assertEqual
(
cache
,
cache_moved
)
# XXX test cache is removed if cachemanager is deleted to prevent leaks?
class
AcceleratedHTTPCacheManagerLocationTests
(
CacheManagerLocationTests
):
_targetClass
=
AcceleratedHTTPCacheManager
class
RamCacheManagerLocationTests
(
CacheManagerLocationTests
):
_targetClass
=
RAMCacheManager
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
AcceleratedHTTPCacheManagerLocationTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
RamCacheManagerLocationTests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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