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
7b8e55c4
Commit
7b8e55c4
authored
Oct 30, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add back ZCacheable templates.
parent
52983a88
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
222 additions
and
5 deletions
+222
-5
src/OFS/Cache.py
src/OFS/Cache.py
+50
-2
src/OFS/DTMLMethod.py
src/OFS/DTMLMethod.py
+8
-3
src/OFS/dtml/cacheNamespaceKeys.dtml
src/OFS/dtml/cacheNamespaceKeys.dtml
+11
-0
src/OFS/dtml/cacheable.dtml
src/OFS/dtml/cacheable.dtml
+40
-0
src/OFS/dtml/cmassoc.dtml
src/OFS/dtml/cmassoc.dtml
+112
-0
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+1
-0
No files found.
src/OFS/Cache.py
View file @
7b8e55c4
...
...
@@ -27,6 +27,7 @@ from Acquisition import aq_base
from
Acquisition
import
aq_get
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_parent
from
App.special_dtml
import
DTMLFile
ZCM_MANAGERS
=
'__ZCacheManager_ids__'
...
...
@@ -84,11 +85,18 @@ class Cacheable(object):
'''Mix-in for cacheable objects.
'''
manage_options
=
()
manage_options
=
(
{
'label'
:
'Cache'
,
'action'
:
'ZCacheable_manage'
,
'filter'
:
filterCacheTab
},
)
security
=
ClassSecurityInfo
()
security
.
setPermissionDefault
(
ChangeCacheSettingsPermission
,
(
'Manager'
,))
security
.
declareProtected
(
ViewManagementScreensPermission
,
'ZCacheable_manage'
)
ZCacheable_manage
=
DTMLFile
(
'dtml/cacheable'
,
globals
())
_v_ZCacheable_cache
=
None
_v_ZCacheable_manager_timestamp
=
0
__manager_id
=
None
...
...
@@ -199,6 +207,11 @@ class Cacheable(object):
exc
=
None
else
:
message
=
'This object is not associated with a cache manager.'
if
REQUEST
is
not
None
:
return
self
.
ZCacheable_manage
(
self
,
REQUEST
,
management_view
=
'Cache'
,
manage_tabs_message
=
message
)
return
message
security
.
declarePrivate
(
'ZCacheable_getModTime'
)
...
...
@@ -270,6 +283,11 @@ class Cacheable(object):
self
.
__manager_id
=
manager_id
self
.
_v_ZCacheable_cache
=
None
if
REQUEST
is
not
None
:
return
self
.
ZCacheable_manage
(
self
,
REQUEST
,
management_view
=
'Cache'
,
manage_tabs_message
=
'Cache settings changed.'
)
security
.
declareProtected
(
ViewManagementScreensPermission
,
'ZCacheable_enabled'
)
def
ZCacheable_enabled
(
self
):
...
...
@@ -283,6 +301,18 @@ class Cacheable(object):
'''Changes the enabled flag.'''
self
.
__enabled
=
enabled
and
1
or
0
if
REQUEST
is
not
None
:
return
self
.
ZCacheable_manage
(
self
,
REQUEST
,
management_view
=
'Cache'
,
manage_tabs_message
=
'Cache settings changed.'
)
security
.
declareProtected
(
ViewManagementScreensPermission
,
'ZCacheable_configHTML'
)
def
ZCacheable_configHTML
(
self
):
'''Override to provide configuration of caching
behavior that can only be specific to the cacheable object.
'''
return
''
InitializeClass
(
Cacheable
)
...
...
@@ -385,7 +415,9 @@ class CacheManager(object):
_isCacheManager
=
1
manage_options
=
()
manage_options
=
(
{
'label'
:
'Associate'
,
'action'
:
'ZCacheManager_associate'
},
)
def
manage_afterAdd
(
self
,
item
,
container
):
# Adds self to the list of cache managers in the container.
...
...
@@ -411,6 +443,10 @@ class CacheManager(object):
global
manager_timestamp
manager_timestamp
=
time
.
time
()
security
.
declareProtected
(
ChangeCacheSettingsPermission
,
'ZCacheManager_associate'
)
ZCacheManager_associate
=
DTMLFile
(
'dtml/cmassoc'
,
globals
())
security
.
declareProtected
(
ChangeCacheSettingsPermission
,
'ZCacheManager_locate'
)
def
ZCacheManager_locate
(
self
,
require_assoc
,
subfolders
,
...
...
@@ -425,6 +461,11 @@ class CacheManager(object):
meta_types
=
[]
findCacheables
(
ob
,
manager_id
,
require_assoc
,
subfolders
,
meta_types
,
rval
,
())
if
REQUEST
is
not
None
:
return
self
.
ZCacheManager_associate
(
self
,
REQUEST
,
show_results
=
1
,
results
=
rval
,
management_view
=
"Associate"
)
return
rval
security
.
declareProtected
(
ChangeCacheSettingsPermission
,
...
...
@@ -459,4 +500,11 @@ class CacheManager(object):
ob
.
ZCacheable_setManagerId
(
None
)
remcount
=
remcount
+
1
if
REQUEST
is
not
None
:
return
self
.
ZCacheManager_associate
(
self
,
REQUEST
,
management_view
=
"Associate"
,
manage_tabs_message
=
'%d association(s) made, %d removed.'
%
(
addcount
,
remcount
)
)
InitializeClass
(
CacheManager
)
src/OFS/DTMLMethod.py
View file @
7b8e55c4
...
...
@@ -39,7 +39,6 @@ from OFS.role import RoleManager
from
OFS.SimpleItem
import
Item_w__name__
from
ZPublisher.Iterators
import
IStreamIterator
if
sys
.
version_info
>=
(
3
,
):
basestring
=
str
...
...
@@ -55,8 +54,8 @@ class DTMLMethod(RestrictedDTML,
HTML
,
Implicit
,
RoleManager
,
Cacheable
,
Item_w__name__
):
Item_w__name__
,
Cacheable
):
""" DocumentTemplate.HTML objects that act as methods of their containers.
"""
meta_type
=
'DTML Method'
...
...
@@ -190,6 +189,9 @@ class DTMLMethod(RestrictedDTML,
kw
[
key
]
=
val
self
.
ZCacheable_set
(
result
,
keywords
=
kw
)
security
.
declareProtected
(
change_dtml_methods
,
'ZCacheable_configHTML'
)
ZCacheable_configHTML
=
DTMLFile
(
'dtml/cacheNamespaceKeys'
,
globals
())
security
.
declareProtected
(
change_dtml_methods
,
'getCacheNamespaceKeys'
)
def
getCacheNamespaceKeys
(
self
):
# Return the cacheNamespaceKeys.
...
...
@@ -205,6 +207,9 @@ class DTMLMethod(RestrictedDTML,
ks
.
append
(
key
)
self
.
_cache_namespace_keys
=
tuple
(
ks
)
if
REQUEST
is
not
None
:
return
self
.
ZCacheable_manage
(
self
,
REQUEST
)
security
.
declareProtected
(
View
,
'get_size'
)
def
get_size
(
self
):
return
len
(
self
.
raw
)
...
...
src/OFS/dtml/cacheNamespaceKeys.dtml
0 → 100644
View file @
7b8e55c4
<p class="form-text">
Names from the DTML namespace to use as cache keys:
</p>
<textarea name="keys:lines" cols="40" rows="5"><dtml-in
getCacheNamespaceKeys>&dtml-sequence-item;
</dtml-in></textarea>
<br>
<div class="form-element">
<input class="form-element" type="submit"
name="setCacheNamespaceKeys:method" value="Save Changes">
</div>
src/OFS/dtml/cacheable.dtml
0 → 100644
View file @
7b8e55c4
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<form action="&dtml-absolute_url;" method="POST">
<div class="form-element">
<span class="form-label">
Cache this object using:
</span>
<select name="manager_id">
<option value="">(None)</option>
<dtml-in ZCacheable_getManagerIds mapping>
<option value="&dtml-id;" <dtml-if
expr="id == ZCacheable_getManagerId()"
>selected="selected"</dtml-if>>&dtml-id;
<dtml-if title>(&dtml-title;)</dtml-if></option>
</dtml-in>
</select>
<br />
<input class="form-element" type="submit"
name="ZCacheable_setManagerId:method" value="Save Changes">
</div>
<dtml-if ZCacheable_getManagerURL>
<p class="form-text">
<a href="&dtml-ZCacheable_getManagerURL;/manage_main">Cache Settings</a>
</p>
<div class="form-element">
<input class="form-element" type="submit"
name="ZCacheable_invalidate:method" value="Invalidate">
</div>
</dtml-if>
<dtml-var ZCacheable_configHTML>
</form>
<dtml-var manage_page_footer>
src/OFS/dtml/cmassoc.dtml
0 → 100644
View file @
7b8e55c4
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<form action="&dtml-URL1;" name="objectItems" method="POST">
<dtml-if show_results>
<dtml-if results>
<p class="form-help">
Select which objects should be cached using this cache manager. Only
those objects for which you have the "Change cache settings" permission
are shown.
</p>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-in results mapping sort=sortkey>
<dtml-if sequence-odd>
<tr class="row-normal">
<dtml-else>
<tr class="row-hilite">
</dtml-if>
<td align="left" valign="top">
<input type="checkbox" name="associate_&dtml-path;:int" value="1"<dtml-if
associated> checked="checked"</dtml-if>>
<input type="hidden" name="associate_&dtml-path;:int:default" value="0">
</td>
<td align="left" valign="top">
<div class="form-text">
<a href="../&dtml-path;/manage_main">&dtml-path;</a><dtml-if
title>(&dtml-title;)</dtml-if>
</div>
</td>
</tr>
</dtml-in>
<tr>
<td></td>
<td align="left" valign="top">
<div class="form-element">
<input type="submit" name="ZCacheManager_setAssociations:method"
value="Save Changes">
</div>
</td>
</tr>
</table>
</form>
<dtml-else>
<p class="form-text">
No objects matched your query.
</p>
</dtml-if>
<hr>
</dtml-if>
<form target="&dtml-URL1;" method="post">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Locate cacheable objects:
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
<input type="radio" name="require_assoc:int" value="0"
checked="checked"> All
<input type="radio" name="require_assoc:int" value="1">
Associated with this cache manager
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Of the type(s):
</div>
</td>
<td align="left" valign="top">
<div class="form-element">
<select multiple="multiple" name="meta_types:list" size="5">
<option value="" selected>All</option>
<dtml-in all_meta_types mapping sort=name>
<option value="&dtml-name;">&dtml-name;</option>
</dtml-in>
</select>
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-text">
<input type="checkbox" name="subfolders:int" value="1" checked="checked">
<input type="hidden" name="subfolders:int" value="0">
Search subfolders
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<br>
<input type="submit" name="ZCacheManager_locate:method" value="Locate">
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
src/OFS/tests/testFileAndImage.py
View file @
7b8e55c4
...
...
@@ -53,6 +53,7 @@ def aputrequest(file, content_type):
class
DummyCache
(
object
):
def
__init__
(
self
):
self
.
clear
()
...
...
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