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
e81982f8
Commit
e81982f8
authored
Jul 24, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix caching
parent
832932e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
lib/python/Products/PageTemplates/PageTemplate.py
lib/python/Products/PageTemplates/PageTemplate.py
+2
-2
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+35
-10
No files found.
lib/python/Products/PageTemplates/PageTemplate.py
View file @
e81982f8
...
...
@@ -87,7 +87,7 @@
HTML- and XML-based template objects using TAL, TALES, and METAL.
"""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
os
,
sys
,
traceback
,
pprint
from
TAL.TALParser
import
TALParser
...
...
@@ -117,7 +117,7 @@ class PageTemplate:
macros
=
MacroCollection
()
def
pt_edit
(
self
,
text
,
content_type
):
if
content_type
and
content_type
!=
self
.
content_type
:
if
content_type
:
self
.
content_type
=
str
(
content_type
)
if
hasattr
(
text
,
'read'
):
text
=
text
.
read
()
...
...
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
e81982f8
...
...
@@ -87,7 +87,7 @@
Zope object encapsulating a Page Template.
"""
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
import
os
,
AccessControl
,
Acquisition
,
sys
from
Globals
import
DTMLFile
,
MessageDialog
,
package_home
...
...
@@ -101,6 +101,7 @@ from AccessControl import getSecurityManager
from
OFS.History
import
Historical
,
html_diff
from
OFS.Cache
import
Cacheable
from
OFS.Traversable
import
Traversable
from
OFS.PropertyManager
import
PropertyManager
from
PageTemplate
import
PageTemplate
try
:
...
...
@@ -111,7 +112,7 @@ except ImportError:
SUPPORTS_WEBDAV_LOCKS
=
0
class
ZopePageTemplate
(
Script
,
PageTemplate
,
Historical
,
Cacheable
,
Traversable
):
Traversable
,
PropertyManager
):
"Zope wrapper for Page Template using TAL, TALES, and METAL"
if
SUPPORTS_WEBDAV_LOCKS
:
...
...
@@ -129,8 +130,15 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
manage_options
=
(
{
'label'
:
'Edit'
,
'action'
:
'pt_editForm'
},
{
'label'
:
'Test'
,
'action'
:
'ZScriptHTML_tryForm'
},
)
+
Historical
.
manage_options
+
SimpleItem
.
manage_options
+
\
Cacheable
.
manage_options
)
+
PropertyManager
.
manage_options
\
+
Historical
.
manage_options
\
+
SimpleItem
.
manage_options
\
+
Cacheable
.
manage_options
_properties
=
({
'id'
:
'title'
,
'type'
:
'string'
},
{
'id'
:
'content_type'
,
'type'
:
'string'
},
{
'id'
:
'expand'
,
'type'
:
'boolean'
},
)
def
__init__
(
self
,
id
,
text
=
None
,
content_type
=
None
):
self
.
id
=
str
(
id
)
...
...
@@ -139,6 +147,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
text
=
open
(
self
.
_default_content_fn
).
read
()
self
.
pt_edit
(
text
,
content_type
)
def
_setPropValue
(
self
,
id
,
value
):
Cache
.
_setPropValue
(
self
,
id
,
value
)
self
.
ZCacheable_invalidate
()
security
=
AccessControl
.
ClassSecurityInfo
()
security
.
declareObjectProtected
(
'View'
)
...
...
@@ -167,10 +179,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
return
self
.
pt_editForm
(
manage_tabs_message
=
message
)
def
pt_setTitle
(
self
,
title
):
title
=
str
(
title
)
if
self
.
title
!=
title
:
self
.
title
=
title
self
.
ZCacheable_invalidate
()
self
.
_setPropValue
(
'title'
,
str
(
title
))
def
pt_upload
(
self
,
REQUEST
,
file
=
''
):
"""Replace the document with the text in file."""
...
...
@@ -236,12 +245,28 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
self
.
content_type
)
except
AttributeError
:
pass
# Execute the template in a new security context.
security
=
getSecurityManager
()
bound_names
[
'user'
]
=
security
.
getUser
()
# Retrieve the value from the cache.
keyset
=
None
if
self
.
ZCacheable_isCachingEnabled
():
# Prepare a cache key.
keyset
=
{
'here'
:
self
.
_getContext
(),
'bound_names'
:
bound_names
}
result
=
self
.
ZCacheable_get
(
keywords
=
keyset
)
if
result
is
not
None
:
# Got a cached value.
return
result
# Execute the template in a new security context.
security
.
addContext
(
self
)
try
:
return
self
.
pt_render
(
extra_context
=
bound_names
)
result
=
self
.
pt_render
(
extra_context
=
bound_names
)
if
keyset
is
not
None
:
# Store the result in the cache.
self
.
ZCacheable_set
(
result
,
keywords
=
keyset
)
return
result
finally
:
security
.
removeContext
(
self
)
...
...
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