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
f7a15140
Commit
f7a15140
authored
Apr 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'modules' TALES variable.
parent
ae062a14
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
lib/python/Products/PageTemplates/PageTemplate.py
lib/python/Products/PageTemplates/PageTemplate.py
+15
-3
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+12
-1
No files found.
lib/python/Products/PageTemplates/PageTemplate.py
View file @
f7a15140
...
...
@@ -87,9 +87,9 @@
HTML- and XML-based template objects using TAL, TALES, and METAL.
"""
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
os
,
sys
,
traceback
import
os
,
sys
,
traceback
,
pprint
from
TAL.TALParser
import
TALParser
from
TAL.HTMLTALParser
import
HTMLTALParser
from
TAL.TALGenerator
import
TALGenerator
...
...
@@ -127,6 +127,7 @@ class PageTemplate:
'options'
:
{},
'nothing'
:
None
,
'request'
:
None
,
'modules'
:
ModuleImporter
,
}
parent
=
getattr
(
self
,
'aq_parent'
,
None
)
if
parent
is
not
None
:
...
...
@@ -145,7 +146,8 @@ class PageTemplate:
output
=
StringIO
()
c
=
self
.
pt_getContext
()
c
.
update
(
extra_context
)
#__traceback_info__ = c
if
__debug__
:
__traceback_info__
=
pprint
.
pformat
(
c
)
TALInterpreter
(
self
.
_v_program
,
self
.
_v_macros
,
getEngine
().
getContext
(
c
),
...
...
@@ -218,3 +220,13 @@ class PageTemplate:
def
html
(
self
):
return
self
.
content_type
==
'text/html'
class
_ModuleImporter
:
def
__getitem__
(
self
,
module
):
mod
=
__import__
(
module
)
path
=
split
(
module
,
'.'
)
for
name
in
path
[
1
:]:
mod
=
getattr
(
mod
,
name
)
return
mod
ModuleImporter
=
_ModuleImporter
()
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
f7a15140
...
...
@@ -87,7 +87,7 @@
Zope object encapsulating a Page Template.
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
os
,
AccessControl
,
Acquisition
,
sys
from
Globals
import
DTMLFile
,
MessageDialog
,
package_home
...
...
@@ -221,6 +221,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'options'
:
{},
'root'
:
root
,
'request'
:
getattr
(
root
,
'REQUEST'
,
None
),
'modules'
:
SecureModuleImporter
,
}
return
c
...
...
@@ -304,6 +305,16 @@ class Src(Acquisition.Explicit):
d
=
ZopePageTemplate
.
__dict__
d
[
'source.xml'
]
=
d
[
'source.html'
]
=
Src
()
from
Products.PythonScripts.Guarded
import
safebin
class
_SecureModuleImporter
:
__allow_access_to_unprotected_subobjects__
=
1
def
__getitem__
(
self
,
module
):
mod
=
safebin
[
'__import__'
](
module
)
path
=
split
(
module
,
'.'
)
for
name
in
path
[
1
:]:
mod
=
getattr
(
mod
,
name
)
return
mod
SecureModuleImporter
=
_SecureModuleImporter
()
# Product registration and Add support
from
urllib
import
quote
...
...
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