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
137c575a
Commit
137c575a
authored
Jan 24, 2001
by
Shane Hathaway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled caching of DTML documents.
parent
58a948e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
lib/python/OFS/DTMLDocument.py
lib/python/OFS/DTMLDocument.py
+24
-7
No files found.
lib/python/OFS/DTMLDocument.py
View file @
137c575a
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
##############################################################################
##############################################################################
"""DTML Document objects."""
"""DTML Document objects."""
__version__
=
'$Revision: 1.4
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
ZPublisher.Converters
import
type_converters
from
ZPublisher.Converters
import
type_converters
from
Globals
import
HTML
,
DTMLFile
,
MessageDialog
from
Globals
import
HTML
,
DTMLFile
,
MessageDialog
...
@@ -100,6 +100,7 @@ from AccessControl import getSecurityManager
...
@@ -100,6 +100,7 @@ from AccessControl import getSecurityManager
done
=
'done'
done
=
'done'
_marker
=
[]
# Create a new marker object.
class
DTMLDocument
(
PropertyManager
,
DTMLMethod
):
class
DTMLDocument
(
PropertyManager
,
DTMLMethod
):
"""DTML Document objects are DocumentTemplate.HTML objects that act
"""DTML Document objects are DocumentTemplate.HTML objects that act
...
@@ -141,6 +142,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
...
@@ -141,6 +142,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
self
.
title
=
str
(
title
)
self
.
title
=
str
(
title
)
if
type
(
data
)
is
not
type
(
''
):
data
=
data
.
read
()
if
type
(
data
)
is
not
type
(
''
):
data
=
data
.
read
()
self
.
munge
(
data
)
self
.
munge
(
data
)
self
.
ZCacheable_invalidate
()
if
REQUEST
:
if
REQUEST
:
message
=
"Content changed."
message
=
"Content changed."
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
...
@@ -150,6 +152,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
...
@@ -150,6 +152,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
self
.
_validateProxy
(
REQUEST
)
self
.
_validateProxy
(
REQUEST
)
if
type
(
file
)
is
not
type
(
''
):
file
=
file
.
read
()
if
type
(
file
)
is
not
type
(
''
):
file
=
file
.
read
()
self
.
munge
(
file
)
self
.
munge
(
file
)
self
.
ZCacheable_invalidate
()
if
REQUEST
:
if
REQUEST
:
message
=
"Content uploaded."
message
=
"Content uploaded."
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
...
@@ -157,6 +160,13 @@ class DTMLDocument(PropertyManager, DTMLMethod):
...
@@ -157,6 +160,13 @@ class DTMLDocument(PropertyManager, DTMLMethod):
def
__call__
(
self
,
client
=
None
,
REQUEST
=
{},
RESPONSE
=
None
,
**
kw
):
def
__call__
(
self
,
client
=
None
,
REQUEST
=
{},
RESPONSE
=
None
,
**
kw
):
"""Render the document given a client object, REQUEST mapping,
"""Render the document given a client object, REQUEST mapping,
Response, and key word arguments."""
Response, and key word arguments."""
if
not
self
.
_cache_namespace_keys
:
data
=
self
.
ZCacheable_get
(
default
=
_marker
)
if
data
is
not
_marker
:
# Return cached results.
return
data
kw
[
'document_id'
]
=
self
.
getId
()
kw
[
'document_id'
]
=
self
.
getId
()
kw
[
'document_title'
]
=
self
.
title
kw
[
'document_title'
]
=
self
.
title
if
hasattr
(
self
,
'aq_explicit'
):
if
hasattr
(
self
,
'aq_explicit'
):
...
@@ -170,12 +180,17 @@ class DTMLDocument(PropertyManager, DTMLMethod):
...
@@ -170,12 +180,17 @@ class DTMLDocument(PropertyManager, DTMLMethod):
if
client
is
None
:
if
client
is
None
:
# Called as subtemplate, so don't need error propigation!
# Called as subtemplate, so don't need error propigation!
r
=
apply
(
HTML
.
__call__
,
(
self
,
bself
,
REQUEST
),
kw
)
r
=
apply
(
HTML
.
__call__
,
(
self
,
bself
,
REQUEST
),
kw
)
if
RESPONSE
is
None
:
return
r
if
RESPONSE
is
None
:
result
=
r
return
decapitate
(
r
,
RESPONSE
)
else
:
result
=
decapitate
(
r
,
RESPONSE
)
if
not
self
.
_cache_namespace_keys
:
self
.
ZCacheable_set
(
result
)
return
result
r
=
apply
(
HTML
.
__call__
,
(
self
,
(
client
,
bself
),
REQUEST
),
kw
)
r
=
apply
(
HTML
.
__call__
,
(
self
,
(
client
,
bself
),
REQUEST
),
kw
)
if
type
(
r
)
is
not
type
(
''
):
return
r
if
type
(
r
)
is
not
type
(
''
)
or
RESPONSE
is
None
:
if
RESPONSE
is
None
:
return
r
if
not
self
.
_cache_namespace_keys
:
self
.
ZCacheable_set
(
r
)
return
r
finally
:
security
.
removeContext
(
self
)
finally
:
security
.
removeContext
(
self
)
...
@@ -186,8 +201,10 @@ class DTMLDocument(PropertyManager, DTMLMethod):
...
@@ -186,8 +201,10 @@ class DTMLDocument(PropertyManager, DTMLMethod):
else
:
else
:
c
,
e
=
guess_content_type
(
self
.
__name__
,
r
)
c
,
e
=
guess_content_type
(
self
.
__name__
,
r
)
RESPONSE
.
setHeader
(
'Content-Type'
,
c
)
RESPONSE
.
setHeader
(
'Content-Type'
,
c
)
return
decapitate
(
r
,
RESPONSE
)
result
=
decapitate
(
r
,
RESPONSE
)
if
not
self
.
_cache_namespace_keys
:
self
.
ZCacheable_set
(
result
)
return
result
Globals
.
default__class_init__
(
DTMLDocument
)
Globals
.
default__class_init__
(
DTMLDocument
)
...
...
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