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
4b53a994
Commit
4b53a994
authored
Dec 11, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made unittests pass
parent
a7ad52c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
+25
-13
lib/python/Products/PageTemplates/ZopePageTemplate.py
lib/python/Products/PageTemplates/ZopePageTemplate.py
+21
-10
lib/python/Products/PageTemplates/pt/ptEdit.pt
lib/python/Products/PageTemplates/pt/ptEdit.pt
+1
-1
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
...thon/Products/PageTemplates/tests/testZopePageTemplate.py
+3
-2
No files found.
lib/python/Products/PageTemplates/ZopePageTemplate.py
View file @
4b53a994
...
...
@@ -214,7 +214,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
setCookie("dtpref_rows", rows, path='
/
', expires=e)
setCookie("dtpref_cols", cols, path='
/
', expires=e)
REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
return self.
manage_main
()
return self.
pt_editForm
()
def ZScriptHTML_tryParams(self):
"""Parameters to test the script with."""
...
...
@@ -242,7 +242,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
}
return c
security.declareProtected(view_management_screens, '
manage_main
', '
read
',
security.declareProtected(view_management_screens, '
read
',
'
ZScriptHTML_tryForm
')
def _exec(self, bound_names, args, kw):
...
...
@@ -331,10 +331,6 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
security.declareProtected(view_management_screens, 'document_src')
def document_src(self, REQUEST=None, RESPONSE=None):
"""Return expanded document source."""
print 'src', self.read()
if RESPONSE is not None:
RESPONSE.setHeader('Content-Type', 'text/plain')
if REQUEST is not None and REQUEST.get('raw'):
...
...
@@ -399,11 +395,11 @@ InitializeClass(FSZPT)
ZopePageTemplate.pt_editForm = FSZPT('pt_editForm', os.path.join(package_home(globals()),'pt', 'ptEdit.pt'))
# this is scary, do we need this?
ZopePageTemplate.manage = ZopePageTemplate.
manage_main = ZopePageTemplate.
pt_editForm
ZopePageTemplate.manage = ZopePageTemplate.pt_editForm
manage_addPageTemplateForm= FSZPT('manage_addPageTemplateForm', os.path.join(package_home(globals()), 'pt', 'ptAdd.pt'))
def manage_addPageTemplate(self, id, title='',
file=None, encoding='utf-8', submit
=None, RESPONSE=None):
def manage_addPageTemplate(self, id, title='',
text=None, file=None, encoding='utf-8', submit=None, REQUEST
=None, RESPONSE=None):
"
Add
a
Page
Template
with
optional
file
content
.
"
if file:
...
...
@@ -411,8 +407,23 @@ def manage_addPageTemplate(self, id, title='', file=None, encoding='utf-8', subm
text = file.read()
encoding = sniffEncoding(text)
content_type, dummy = guess_content_type(filename, text)
elif REQUEST and REQUEST.has_key('file'):
f = REQUEST['file']
filename = f.filename
text = f.read()
encoding = sniffEncoding(text)
headers = getattr(f, 'headers')
if headers.has_key('content_type'):
content_type = headers['content_type']
else:
content_type, dummy = guess_content_type(filename, text)
else:
text = open(_default_content_fn).read()
if hasattr(text, 'read'): # assume file
text= text.read()
if text is None:
text = ''
text = text or open(_default_content_fn).read()
encoding = 'utf-8'
content_type = 'text/html'
...
...
@@ -423,7 +434,7 @@ def manage_addPageTemplate(self, id, title='', file=None, encoding='utf-8', subm
if RESPONSE:
if submit == "
Add
and
Edit
":
RESPONSE.redirect(zpt.absolute_url() + '/
manage_main
')
RESPONSE.redirect(zpt.absolute_url() + '/
pt_editForm
')
else:
RESPONSE.redirect(self.absolute_url() + '/manage_main')
else:
...
...
lib/python/Products/PageTemplates/pt/ptEdit.pt
View file @
4b53a994
...
...
@@ -53,7 +53,7 @@
<tr>
<td align="left" valign="middle" class="form-label">Encoding</td>
<td>
<input type="text" readonly name="encoding" tal:attributes="value context/pt_encoding"/>
<input type="text" readonly name="encoding" tal:attributes="value context/pt_encoding"
style="background-color: #bbbbbb; "
/>
</td>
</tr>
...
...
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
4b53a994
...
...
@@ -12,6 +12,7 @@ import Zope2
import
transaction
from
Testing.makerequest
import
makerequest
from
Products.PageTemplates.ZopePageTemplate
import
_default_content_fn
class
ZPTRegressions
(
unittest
.
TestCase
):
...
...
@@ -34,9 +35,9 @@ class ZPTRegressions(unittest.TestCase):
def
testAddWithoutParams
(
self
):
pt
=
self
.
_addPT
(
'pt1'
)
default_text
=
open
(
pt
.
_default_content_fn
).
read
()
default_text
=
open
(
_default_content_fn
).
read
()
self
.
assertEqual
(
pt
.
title
,
''
)
self
.
assertEqual
(
pt
.
document_src
()
,
default_text
)
self
.
assertEqual
(
pt
.
document_src
()
.
strip
(),
default_text
.
strip
()
)
def
testAddWithRequest
(
self
):
"""Test manage_add with file"""
...
...
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