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
22f2299a
Commit
22f2299a
authored
Jul 27, 2007
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No longer need to rely on Acquisition to get to stuff (and to validate security),
so let's simply reuse Zope3's ViewPageTemplateFIle
parent
fc3930c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
64 deletions
+10
-64
lib/python/Products/Five/browser/pagetemplatefile.py
lib/python/Products/Five/browser/pagetemplatefile.py
+10
-64
No files found.
lib/python/Products/Five/browser/pagetemplatefile.py
View file @
22f2299a
...
...
@@ -15,79 +15,25 @@
$Id$
"""
import
os
,
sys
from
Acquisition
import
aq_inner
,
aq_acquire
from
Globals
import
package_home
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
import
zope.app.pagetemplate
from
Products.PageTemplates.Expressions
import
SecureModuleImporter
from
Products.PageTemplates.Expressions
import
createTrustedZopeEngine
from
zope.app.pagetemplate.viewpagetemplatefile
import
ViewMapper
_engine
=
createTrustedZopeEngine
()
def
getEngine
():
return
_engine
class
ZopeTwoPageTemplateFile
(
PageTemplateFile
):
"""A strange hybrid between Zope 2 and Zope 3 page template.
Uses Zope 2's engine, but with security disabled and with some
initialization and API from Zope 3.
"""
def
__init__
(
self
,
filename
,
_prefix
=
None
,
content_type
=
None
):
# XXX doesn't use content_type yet
self
.
ZBindings_edit
(
self
.
_default_bindings
)
path
=
self
.
get_path_from_prefix
(
_prefix
)
self
.
filename
=
os
.
path
.
join
(
path
,
filename
)
if
not
os
.
path
.
isfile
(
self
.
filename
):
raise
ValueError
(
"No such file"
,
self
.
filename
)
basepath
,
ext
=
os
.
path
.
splitext
(
self
.
filename
)
self
.
__name__
=
os
.
path
.
basename
(
basepath
)
super
(
PageTemplateFile
,
self
).
__init__
(
self
.
filename
,
_prefix
)
def
get_path_from_prefix
(
self
,
_prefix
):
if
isinstance
(
_prefix
,
str
):
path
=
_prefix
else
:
if
_prefix
is
None
:
_prefix
=
sys
.
_getframe
(
2
).
f_globals
path
=
package_home
(
_prefix
)
return
path
class
ViewPageTemplateFile
(
zope
.
app
.
pagetemplate
.
ViewPageTemplateFile
):
def
pt_getEngine
(
self
):
return
getEngine
()
def
pt_getContext
(
self
):
try
:
root
=
aq_acquire
(
self
.
context
,
'getPhysicalRoot'
)()
except
AttributeError
:
root
=
None
view
=
self
.
_getContext
()
here
=
aq_inner
(
self
.
context
)
try
:
request
=
aq_acquire
(
root
,
'REQUEST'
)
except
AttributeError
:
request
=
None
c
=
{
'template'
:
self
,
'here'
:
here
,
'context'
:
here
,
'container'
:
here
,
'nothing'
:
None
,
'options'
:
{},
'root'
:
root
,
'request'
:
request
,
'modules'
:
SecureModuleImporter
,
}
if
view
is
not
None
:
c
[
'view'
]
=
view
c
[
'views'
]
=
ViewMapper
(
here
,
request
)
return
c
def
pt_getContext
(
self
,
instance
,
request
,
**
kw
):
context
=
super
(
ViewPageTemplateFile
,
self
).
pt_getContext
(
instance
,
request
,
**
kw
)
context
[
'modules'
]
=
SecureModuleImporter
context
[
'options'
]
=
''
return
context
ViewPageTemplateFile
=
ZopeTwoPageTemplateFile
# BBB
ZopeTwoPageTemplateFile
=
ViewPageTemplateFile
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