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
c1189cd6
Commit
c1189cd6
authored
Aug 15, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to output headers.
parent
40ad95a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
9 deletions
+56
-9
lib/python/OFS/Document.py
lib/python/OFS/Document.py
+56
-9
No files found.
lib/python/OFS/Document.py
View file @
c1189cd6
"""Document object"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
from
STPDocumentTemplate
import
HTML
from
Globals
import
shared_dt_globals
,
HTMLFile
from
Globals
import
HTMLFile
from
string
import
join
,
split
,
strip
import
AccessControl.ACL
import
regex
class
Document
(
HTML
,
AccessControl
.
ACL
.
RoleManager
):
"""A Document object"""
...
...
@@ -14,17 +15,22 @@ class Document(HTML, AccessControl.ACL.RoleManager):
icon
=
'OFS/Document_icon.gif'
__state_names__
=
HTML
.
__state_names__
+
(
'title'
,
'__roles__'
)
shared_globals
=
shared_dt_globals
manage_edit__allow_groups__
=
{
None
:
None
}
def
document_template_form_header
(
self
):
try
:
roles
=
join
(
self
.
__roles__
)
except
:
roles
=
''
return
(
"""<br>Title:
<input type=text name=title SIZE="50" value="%s">
<br>Roles:
<input type=text name=roles SIZE="50" value="%s">
<P>"""
%
(
self
.
title
,
roles
))
return
(
"""<table>
<tr><th>Title:</th><td>
<input type=text name=title SIZE="50" value="%s"></td></tr>
<tr><th>Roles:</th><td>
<input type=text name=roles SIZE="50" value="%s"></td></tr>
</table>"""
%
(
self
.
title
,
roles
))
def
index_html
(
self
,
REQUEST
,
PARENTS
,
RESPONSE
):
"""Run the document as a web object with possible HTTP headers"""
return
decapitate
(
self
(
PARENTS
[
1
],
REQUEST
),
RESPONSE
)
def
manage_edit
(
self
,
data
,
title
,
roles
,
REQUEST
=
None
):
"""Edit method"""
...
...
@@ -80,3 +86,44 @@ class DocumentHandler:
n
=
i
[
'id'
]
t
.
append
((
n
,
getattr
(
self
,
n
)))
return
t
def
decapitate
(
html
,
RESPONSE
=
None
,
header_re
=
regex
.
compile
(
'
\
(
\
('
'[^
\
0
- <>:]+:[^
\
n
]*
\
n
'
'
\
|
'
'
[
\
t
]
+
[
^
\
0
-
][
^
\
n
]
*
\
n
'
'
\
)
+
\
)[
\
t
]
*
\
n
\
([
\
0
-
\
377
]
+
\
)
'
),
space_re=regex.compile('
\
([
\
t
]
+
\
)
'),
name_re=regex.compile('
\
([
^
\
0
-
<>
:]
+
\
):
\
([
^
\
n
]
*
\
)
'),
):
if header_re.match(html) < 0: return html
headers, html = header_re.group(1,3)
headers=split(headers,'
\
n
')
i=1
while i < len(headers):
if not headers[i]:
del headers[i]
elif space_re.match(headers[i]) >= 0:
headers[i-1]="%s %s" % (headers[i-1],
headers[i][len(space_re.group(1)):])
del headers[i]
else:
i=i+1
for i in range(len(headers)):
if name_re.match(headers[i]) >= 0:
k, v = name_re.group(1,2)
v=strip(v)
else:
raise ValueError, '
Invalid
Header
(
%
d
):
%
s
' % (i,headers[i])
RESPONSE.setHeader(k,v)
return html
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