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
cff7b4d2
Commit
cff7b4d2
authored
Jan 27, 2016
by
Philip Bauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pt_editForm after the help-system was removed
parent
c843a701
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
21 deletions
+23
-21
CHANGES.rst
CHANGES.rst
+3
-0
src/Products/PageTemplates/ZopePageTemplate.py
src/Products/PageTemplates/ZopePageTemplate.py
+20
-21
No files found.
CHANGES.rst
View file @
cff7b4d2
...
...
@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/
Bugs Fixed
++++++++++
- Fix pt_editForm after the help-system was removed.
[pbauer]
- Skipped ipv6 test on Travis, because Travis no longer supports this.
- LP #789863: Ensure that Request objects cannot be published / traversed
...
...
src/Products/PageTemplates/ZopePageTemplate.py
View file @
cff7b4d2
...
...
@@ -32,7 +32,7 @@ from OFS.History import Historical, html_diff
from
OFS.Cache
import
Cacheable
from
OFS.Traversable
import
Traversable
from
OFS.PropertyManager
import
PropertyManager
from
Shared.DC.Scripts.Script
import
Script
from
Shared.DC.Scripts.Script
import
Script
from
Shared.DC.Scripts.Signature
import
FuncCode
from
webdav.Lockable
import
ResourceLockedError
...
...
@@ -83,8 +83,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
'www'
,
'default.html'
)
manage_options
=
(
{
'label'
:
'Edit'
,
'action'
:
'pt_editForm'
,
'help'
:
(
'PageTemplates'
,
'PageTemplate_Edit.stx'
)},
{
'label'
:
'Edit'
,
'action'
:
'pt_editForm'
},
{
'label'
:
'Test'
,
'action'
:
'ZScriptHTML_tryForm'
},
)
+
PropertyManager
.
manage_options
\
+
Historical
.
manage_options
\
...
...
@@ -106,10 +105,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
security
.
declareProtected
(
view_management_screens
,
'read'
,
'ZScriptHTML_tryForm'
)
def
__init__
(
self
,
id
,
text
=
None
,
content_type
=
'text/html'
,
strict
=
True
,
def
__init__
(
self
,
id
,
text
=
None
,
content_type
=
'text/html'
,
strict
=
True
,
output_encoding
=
'utf-8'
):
self
.
id
=
id
self
.
expand
=
0
self
.
expand
=
0
self
.
ZBindings_edit
(
self
.
_default_bindings
)
self
.
output_encoding
=
output_encoding
# default content
...
...
@@ -123,7 +122,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def
pt_edit
(
self
,
text
,
content_type
,
keep_output_encoding
=
False
):
text
=
text
.
strip
()
is_unicode
=
isinstance
(
text
,
unicode
)
encoding
=
None
output_encoding
=
None
...
...
@@ -162,7 +161,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
preferred_encodings
)
output_encoding
=
encoding
# for content updated through WebDAV, FTP
# for content updated through WebDAV, FTP
if
not
keep_output_encoding
:
self
.
output_encoding
=
output_encoding
...
...
@@ -191,7 +190,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
# The ZMI edit view uses utf-8! So we can safely assume
# that 'title' and 'text' are utf-8 encoded strings - hopefully
self
.
pt_setTitle
(
title
,
'utf-8'
)
self
.
pt_setTitle
(
title
,
'utf-8'
)
text
=
unicode
(
text
,
'utf-8'
)
self
.
pt_edit
(
text
,
content_type
,
True
)
...
...
@@ -226,12 +225,12 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
filename
=
None
text
=
file
else
:
if
not
file
:
if
not
file
:
raise
ValueError
(
'File not specified'
)
filename
=
file
.
filename
text
=
file
.
read
()
content_type
=
guess_type
(
filename
,
text
)
content_type
=
guess_type
(
filename
,
text
)
# if not content_type in ('text/html', 'text/xml'):
# raise ValueError('Unsupported mimetype: %s' % content_type)
...
...
@@ -293,7 +292,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def
write
(
self
,
text
):
if
not
isinstance
(
text
,
unicode
):
text
,
encoding
=
convertToUnicode
(
text
,
text
,
encoding
=
convertToUnicode
(
text
,
self
.
content_type
,
preferred_encodings
)
self
.
output_encoding
=
encoding
...
...
@@ -350,7 +349,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
self
.
dav__init
(
REQUEST
,
RESPONSE
)
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
text
=
REQUEST
.
get
(
'BODY'
,
''
)
content_type
=
guess_type
(
''
,
text
)
content_type
=
guess_type
(
''
,
text
)
self
.
pt_edit
(
text
,
content_type
)
RESPONSE
.
setStatus
(
204
)
return
RESPONSE
...
...
@@ -368,7 +367,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
security
.
declareProtected
(
view_management_screens
,
'html'
)
def
html
(
self
):
return
self
.
content_type
==
'text/html'
security
.
declareProtected
(
view_management_screens
,
'get_size'
)
def
get_size
(
self
):
return
len
(
self
.
read
())
...
...
@@ -403,16 +402,16 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def
__setstate__
(
self
,
state
):
# Perform on-the-fly migration to unicode.
# Perhaps it might be better to work with the 'generation' module
# Perhaps it might be better to work with the 'generation' module
# here?
_text
=
state
.
get
(
'_text'
)
if
_text
is
not
None
and
not
isinstance
(
state
[
'_text'
],
unicode
):
text
,
encoding
=
convertToUnicode
(
state
[
'_text'
],
state
.
get
(
'content_type'
,
'text/html'
),
text
,
encoding
=
convertToUnicode
(
state
[
'_text'
],
state
.
get
(
'content_type'
,
'text/html'
),
preferred_encodings
)
state
[
'_text'
]
=
text
state
[
'output_encoding'
]
=
encoding
self
.
__dict__
.
update
(
state
)
self
.
__dict__
.
update
(
state
)
def
pt_render
(
self
,
source
=
False
,
extra_context
=
{}):
...
...
@@ -449,7 +448,7 @@ def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8',
if
headers
and
headers
.
has_key
(
'content_type'
):
content_type
=
headers
[
'content_type'
]
else
:
content_type
=
guess_type
(
filename
,
text
)
content_type
=
guess_type
(
filename
,
text
)
else
:
...
...
@@ -460,7 +459,7 @@ def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8',
if
headers
and
headers
.
has_key
(
'content_type'
):
content_type
=
headers
[
'content_type'
]
else
:
content_type
=
guess_type
(
filename
,
text
)
content_type
=
guess_type
(
filename
,
text
)
# ensure that we pass unicode to the constructor to
# avoid further hassles with pt_edit()
...
...
@@ -473,12 +472,12 @@ def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8',
self
.
_setObject
(
id
,
zpt
)
zpt
=
getattr
(
self
,
id
)
if
RESPONSE
:
if
RESPONSE
:
if
submit
==
" Add and Edit "
:
RESPONSE
.
redirect
(
zpt
.
absolute_url
()
+
'/pt_editForm'
)
else
:
RESPONSE
.
redirect
(
self
.
absolute_url
()
+
'/manage_main'
)
else
:
else
:
return
zpt
...
...
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