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
150adf04
Commit
150adf04
authored
Jun 12, 2004
by
Stuart Bishop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge -r25111:25112 $ZOPESVN/branches/stub-unicode-zpt
parent
3f36c64e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-7
lib/python/Products/PageTemplates/PageTemplate.py
lib/python/Products/PageTemplates/PageTemplate.py
+8
-2
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+20
-5
lib/python/Products/PageTemplates/www/ptEdit.zpt
lib/python/Products/PageTemplates/www/ptEdit.zpt
+11
-0
No files found.
lib/python/Products/PageTemplates/PageTemplate.py
View file @
150adf04
...
@@ -17,7 +17,7 @@ HTML- and XML-based template objects using TAL, TALES, and METAL.
...
@@ -17,7 +17,7 @@ HTML- and XML-based template objects using TAL, TALES, and METAL.
__version__
=
'$Revision: 1.31 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.31 $'
[
11
:
-
2
]
import
sys
import
sys
,
types
from
TAL.TALParser
import
TALParser
from
TAL.TALParser
import
TALParser
from
TAL.HTMLTALParser
import
HTMLTALParser
from
TAL.HTMLTALParser
import
HTMLTALParser
...
@@ -57,6 +57,12 @@ class PageTemplate(Base):
...
@@ -57,6 +57,12 @@ class PageTemplate(Base):
self
.
content_type
=
str
(
content_type
)
self
.
content_type
=
str
(
content_type
)
if
hasattr
(
text
,
'read'
):
if
hasattr
(
text
,
'read'
):
text
=
text
.
read
()
text
=
text
.
read
()
charset
=
getattr
(
self
,
'management_page_charset'
,
None
)
if
charset
and
type
(
text
)
==
types
.
StringType
:
try
:
unicode
(
text
,
'us-ascii'
)
except
UnicodeDecodeError
:
text
=
unicode
(
text
,
charset
)
self
.
write
(
text
)
self
.
write
(
text
)
def
pt_getContext
(
self
):
def
pt_getContext
(
self
):
...
@@ -130,7 +136,7 @@ class PageTemplate(Base):
...
@@ -130,7 +136,7 @@ class PageTemplate(Base):
return
None
# Unknown.
return
None
# Unknown.
def
write
(
self
,
text
):
def
write
(
self
,
text
):
assert
type
(
text
)
i
s
type
(
''
)
assert
type
(
text
)
i
n
types
.
StringTypes
if
text
[:
len
(
self
.
_error_start
)]
==
self
.
_error_start
:
if
text
[:
len
(
self
.
_error_start
)]
==
self
.
_error_start
:
errend
=
text
.
find
(
'-->'
)
errend
=
text
.
find
(
'-->'
)
if
errend
>=
0
:
if
errend
>=
0
:
...
...
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
150adf04
...
@@ -17,7 +17,7 @@ Zope object encapsulating a Page Template.
...
@@ -17,7 +17,7 @@ Zope object encapsulating a Page Template.
__version__
=
'$Revision: 1.48 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.48 $'
[
11
:
-
2
]
import
os
,
AccessControl
,
Acquisition
,
sys
import
os
,
AccessControl
,
Acquisition
,
sys
,
types
from
types
import
StringType
from
types
import
StringType
from
Globals
import
DTMLFile
,
ImageFile
,
MessageDialog
,
package_home
from
Globals
import
DTMLFile
,
ImageFile
,
MessageDialog
,
package_home
from
zLOG
import
LOG
,
ERROR
,
INFO
from
zLOG
import
LOG
,
ERROR
,
INFO
...
@@ -134,6 +134,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
...
@@ -134,6 +134,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
self
.
pt_setTitle
(
title
)
self
.
pt_setTitle
(
title
)
self
.
pt_edit
(
text
,
content_type
)
self
.
pt_edit
(
text
,
content_type
)
REQUEST
.
set
(
'text'
,
self
.
read
())
# May not equal 'text'!
REQUEST
.
set
(
'text'
,
self
.
read
())
# May not equal 'text'!
REQUEST
.
set
(
'title'
,
self
.
title
)
message
=
"Saved changes."
message
=
"Saved changes."
if
getattr
(
self
,
'_v_warnings'
,
None
):
if
getattr
(
self
,
'_v_warnings'
,
None
):
message
=
(
"<strong>Warning:</strong> <i>%s</i>"
message
=
(
"<strong>Warning:</strong> <i>%s</i>"
...
@@ -141,9 +142,18 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
...
@@ -141,9 +142,18 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
return
self
.
pt_editForm
(
manage_tabs_message
=
message
)
return
self
.
pt_editForm
(
manage_tabs_message
=
message
)
def
pt_setTitle
(
self
,
title
):
def
pt_setTitle
(
self
,
title
):
self
.
_setPropValue
(
'title'
,
str
(
title
))
charset
=
getattr
(
self
,
'management_page_charset'
,
None
)
if
type
(
title
)
==
types
.
StringType
and
charset
:
def
pt_upload
(
self
,
REQUEST
,
file
=
''
):
try
:
title
.
decode
(
'us-ascii'
)
title
=
str
(
title
)
except
UnicodeError
:
title
=
unicode
(
title
,
charset
)
elif
type
(
title
)
!=
types
.
UnicodeType
:
title
=
str
(
title
)
self
.
_setPropValue
(
'title'
,
title
)
def
pt_upload
(
self
,
REQUEST
,
file
=
''
,
charset
=
None
):
"""Replace the document with the text in file."""
"""Replace the document with the text in file."""
if
SUPPORTS_WEBDAV_LOCKS
and
self
.
wl_isLocked
():
if
SUPPORTS_WEBDAV_LOCKS
and
self
.
wl_isLocked
():
raise
ResourceLockedError
,
"File is locked via WebDAV"
raise
ResourceLockedError
,
"File is locked via WebDAV"
...
@@ -151,7 +161,12 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
...
@@ -151,7 +161,12 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
if
type
(
file
)
is
not
StringType
:
if
type
(
file
)
is
not
StringType
:
if
not
file
:
raise
ValueError
,
'File not specified'
if
not
file
:
raise
ValueError
,
'File not specified'
file
=
file
.
read
()
file
=
file
.
read
()
if
charset
:
try
:
unicode
(
file
,
'us-ascii'
)
file
=
str
(
file
)
except
UnicodeDecodeError
:
file
=
unicode
(
file
,
charset
)
self
.
write
(
file
)
self
.
write
(
file
)
message
=
'Saved changes.'
message
=
'Saved changes.'
return
self
.
pt_editForm
(
manage_tabs_message
=
message
)
return
self
.
pt_editForm
(
manage_tabs_message
=
message
)
...
...
lib/python/Products/PageTemplates/www/ptEdit.zpt
View file @
150adf04
...
@@ -121,6 +121,17 @@ to view or download the current text.
...
@@ -121,6 +121,17 @@ to view or download the current text.
<input type="file" name="file" size="25" value="">
<input type="file" name="file" size="25" value="">
</td>
</td>
</tr>
</tr>
<tr tal:condition="context/management_page_charset|nothing">
<td align="left" valign="top">
<div class="form-label">
Encoding
</div>
</td>
<td align="left" valign="top">
<input name="charset" value=""
tal:attributes="value here/management_page_charset|default" />
</td>
</tr>
<tr>
<tr>
<td></td>
<td></td>
<td align="left" valign="top">
<td align="left" valign="top">
...
...
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